6 ms·
Inside the M4 Apple Neural Engine, Part 1: Reverse Engineering
- poszlem 8mo agoGenuine question, not trying to throw a shade or anything, but are those cores actually useful with the state of apple intelligence being what it is?
- rahkiin 8mo agoThey are also used by ML models that are deeply integrated in macos and ios without you knowing. Like object and text detection in images.
- geerlingguy 8mo agoAnd help in Photos, Final Cut Pro, and other apps.
- willis936 8mo agoI wish they would (or wouldn't if they are) hook it up to the ios keyboard.
- esafak 8mo agoYou can convert your own ML models to MLX to use them; Apple Intelligence is not the only application.
- nullstyle 8mo agoMLX does not run on NPUs AFAIK; just gpu and cpu. You have to use CoreML to officially run code on the neural engine.
- mirsadm 8mo agoEven then there is no transparency on how it decides what runs on the ANE/GPU etc
- sroussey 8mo agoCorrect. OS level stuff get first priority, so you can’t count on using it.
- znagengast 8mo agoTurns out third party actually gets priority for ANE
- llm_nerd 8mo agohttps://dennisforbes.ca/blog/microblog/2026/02/apple-neural-engine-and-you/ https://dennisforbes.ca/blog/microblog/2026/02/apple-neural-...
- malshe 8mo agoThis is a nice article. Thanks for sharing.
- stetrain 8mo agoApple's OSes run a lot of local ML models for many tasks that aren't branded as Apple Intelligence, and they have done so for many years now.
- dagmx 8mo agoIf you strip away the branding, Apple has and continues to ship a ton of algorithms that likely use the ANE and end users can use CoreML to do the same. Just some things that people will likely take for granted that IIRC Apple have said use the ANE or at least would likely benefit from it: object recognition, subject extraction from images and video, content analysis, ARKit, spam detection, audio transcription.
- sroussey 8mo agoDon’t forget FaceID and many of the image manipulation. And while everyone else went to more powerful giant LLMs, Apple moved most of Siri from the cloud to your device. Though they do use both (which you can see when Siri corrects itself during transcription—you get the local Siri version corrected later by the cloud version).
- mschuster91 8mo agoIIRC, FaceID has been a thing before ML entered the picture.
- dagmx 8mo agoFaceID was introduced along side the ANE. It was its reason d’être when introduced.
- deleted 8mo ago[deleted]
- love2read 8mo agoThis article was clearly written by a human (and AI) but still has a few "LLMisms" such as: - The key insight - [CoreML] doesn't XXX. It YYY. With that being said, this is a highly informative article that I enjoyed thoroughly! :) The article links to their own Github repo: https://github.com/maderix/ANE https://github.com/maderix/ANE
- walthamstow 8mo agoWe've got about a year before so many people are interacting with LLMs on a daily basis that its style starts to reverse infect human speech and writing
- Angostura 8mo agoMy honest take? You're probably right
- sholladay 8mo agoYou are absolutely right. Here is why you are correct: - I see what you did there. - You are always right.
- pixl97 8mo agoThis said, there were people that talked like this before LLMs, it didn't develop this whole cloth.
- DrScientist 8mo agoExactly. LLM's are mimics. People seem to be going around pointing out that people talk like parrots, when in reality it's parrots talk like people.
- pixl97 8mo agoI mean, it's both. Did you develop your own whole language at any point to describe the entire world? No, you, me, and society mimic what is around us. Humans have the advantage, at least at this point, of being a continuous learning device so we adapt and change with the language use around us.
- mattlangston 8mo agoThe future is bright for software engineers. The big takeaway isn't reverse engineering the ANE per se, but what Manjeet could do with his software engineering skills when accelerated by AI. This is a good example of the present state of software engineering. Not future state - present state.
- techpulse_x 8mo ago[flagged]
- Octoth0rpe 8mo agoPart 2 has benchmarks: https://maderix.substack.com/p/inside-the-m4-apple-neural-engine-615?r=1afltp https://maderix.substack.com/p/inside-the-m4-apple-neural-en... 6.6 FLOPS/W, plus the ability to completely turn off when not in use, so 0W at idle.
- AceJohnny2 8mo agoBut not 38 TOPS that Apple claims, with the weak explanation of > Apple’s “38 TOPS INT8” is computed as 19 TFLOPS FP16 × 2, following the industry convention of counting INT8 operations as 2× the FP16 rate. But the hardware doesn’t actually execute INT8 operations twice as fast. Why would Apple follow that convention when the hardware explicitly doesn't seems like a more straight-faced lie that I expect from Apple
- Shebanator 8mo agoYou assume the marketing folks actually talk with the hardware folks. More likely its a big game of telephone....
- AceJohnny2 8mo agothere's an apocryphal story that when one of Apple's chips was nearing 10B transistors, marketing asked the chip folks if they could round it up to 10B for their copy. The chip folks were confounded, and said no they didn't have any uncounted transistors to round it up, and they didn't approve of claiming 10B transistors when it wasn't. (This was a while ago. I see the M4 is at 28 B) Which is why I'm all the more surprised that Apple would claim 2x more ANE TOPS than it can really does.
- Sephr 8mo agoYou're off by a factor of a trillion. It's 6.6 TFLOPS/W.
- Octoth0rpe 8mo agoWell, better to be off by that much here than on my next jira ticket size estimate. thanks
- kamranjon 8mo agoI have always wondered if the neural engine could be used for training - pretty excited for part 3 of this to see if the juice is actually worth the squeeze
- juancn 8mo agoIn principle most if not all inference hardware should be usable for training. Efficiency is the question.
- eleventyseven 8mo ago> Throughout this series, “we” refers to maderix (human) and Claude Opus 4.6 (by Anthropic) working as a pair. The reverse engineering, benchmarking, and training code were developed collaboratively Sure, "collaboratively." Why would I ever trust a vibe coded analysis? How do I, a non expert in this niche, know that Opus isn't pulling a fast one on both of us? LLMs write convincing bullshit that even fools experts. Have you manually verified each fact in this piece? I doubt it. Thanks for the disclaimer, it saved me from having to read it.
- withinboredom 8mo agoClaude likes to hide bad benchmarks from you, so it will show you where you are clearly winning. You even see some weird benchmarks in the article.
- Anonbrit 8mo agoHumans also write endless amounts of convincing bullshit, and have done since time immemorial. False papers and faked results have been a growing scourge in academia before LLMs were a thing, and that's just counting the intentional fraud - the reproducibility crisis in science, especially medical and psychological science, affects even the best designed and well intentioned of studies. Humans also make mistakes and assumptions while reverse engineering, so it will always need more engineers to go through the results, test things
- this-is-why 8mo agoAgreed. Now is our chance to start pushing back on this. Don’t patronize this. Just glad author admitted it. Next time they won’t tho.
- brookst 8mo agoYou’d feel better if it was two people you don’t know? Because obviously any random person is 100% accurate, never mistaken, never making shit up? I don’t understand the mindset, I really don’t. Why are humans held to such a lower standard?
- 8mo ago
- LatencyKills 8mo agoI worked on the Xcode team for years and know the lengths Apple goes to make this stuff difficult to figure out. I just wanted to say that you’ve done an excellent job and am looking forward to the 3rd installment.
- RetpolineDrama 8mo ago>I worked on the Xcode team for years Why did you guys remove the ability to detach the console and move it to another window?
- estimator7292 8mo ago[flagged]
- tiffanyh 8mo agoWould you mind explaining more. “Difficult” because of lack of documentation? Or difficult because of purposefully obfuscating things?
- LatencyKills 8mo agoThere's a lot you can do at build time to make reverse engineering harder than just stripping symbol information.
- bri3d 8mo agoThis seems odd to me. I have never seen obfuscation techniques in first party Apple software - certainly not in Espresso or ANECompiler and overall nowhere at all except in media DRM components (FairPlay). Apple are really the major OS company _without_ widespread use of a first party obfuscator; Microsoft have WarBird and Google have PairIP.
- LatencyKills 8mo ago> Apple are really the major OS company _without_ widespread use of a first party obfuscator You might want to look into techniques like control-flow flattening, mixed boolean–arithmetic transformations, opaque predicates, and dead code injection — Apple uses all of these. The absence of a publicly named obfuscator doesn’t mean Apple doesn’t apply these methods (at least during my time there). Ever wonder why Apple stopped shipping system frameworks as individual .dylib files? Here’s a hint: early extraction tools couldn’t preserve selector information when pulling libraries from the shared cache, which made the resulting decompiled pseudocode unreadable.
- daoistmonk 8mo agoTangential: Is anyone doing something similar to accelerate the support matrix of Linux on anything higher than M2?
- GeekyBear 8mo agoThe recent news is that Apple is supposedly replacing the Core ML framework with an updated version that will make it easier to integrate third party LLMs into your apps. > the company is also planning a few other software-based AI upgrades, including a new framework called Core AI. The idea is to replace the long-existing Core ML with something a bit more modern. https://www.bloomberg.com/news/newsletters/2026-03-01/apple-touch-screen-macbook-pro-fall-2026-details-cheap-macbook-launch-core-ai-mm7rcg48 https://www.bloomberg.com/news/newsletters/2026-03-01/apple-...
- reverius42 8mo agoI scoffed, thinking "more modern? It's pretty recent, right?" and then I realized it's coming up on 10 years old and in AI years that's like 70 years, isn't it. I wonder to what extent this is a branding exercise; the framework that will replace Core ML could have just as easily been called "Core ML", except the current hotness is "AI" and not "ML".
- GeekyBear 8mo agoIf I had to guess, I'd say that Core AI is going to be an ease of use wrapper around MLX.
- behnamoh 8mo agoIt's insane that the source code of ANE is not available even to the MLX team, possibly one of the reasons Awni (MLX project head) left Apple.
- mathisfun123 8mo ago[flagged]
- behnamoh 8mo agoYes I haven't worked at a hardware company, nothing to be ashamed of!
- timcobb 8mo agoI'm not op but I don't think op meant to shame, I understand the construction "tell me you're... without telling me" as a way to highlight that something is unexpected to people who haven't done something, that is that something is particularly unintuitive without some special experience.
- webdevver 8mo agohe did a reddit (cringe) and now must be punished for it (the text becomes an absolutely fucking unreadable shade of light grey)
- webdevver 8mo agoactually, it really is not neccesarily a 'hardware company' thing. ive been in 'hardware companies' where the rtl was just as available for viewing as the rest of the firmware/software. in big hardware companies, things start getting siloed, but that probably has more to do with big companies (seemingly invariably) operating as a union of fiefdoms (dunbar-number-ification?)
- mathisfun123 8mo ago> It's insane that the source code of ANE is not available even to the MLX team no it's not insane - it's completely mundane policy. that's my point - that you're calling something out as insane with exactly zero experience (which is the actually insane thing...).
- FL33TW00D 8mo agoUnreadable Claude slop
- mayhemducks 8mo agoI never realized just how much hardware engineering Apple dedicated to enabling people to type faster with their thumbs!
- giancarlostoro 8mo agoReverse Engineering with AI is only going to get better. I have seen some crazy things friends of mine have done with Claude alone. Let's just says SaaS isn't the only industry that could one day suffer.
- msie 8mo agoI remember the good old days when Apple was desperate for developers and produced great documentation and there were a lot of great 3rd-party books too. You can't just give out awards in hopes that someone will make that great app.
- ericol 8mo ago> human intuition driving the exploration This, a thousand times this. For me, what AI brings is augmented humans. Just as we don't calculate on paper anymore, what is the reason of doing things by hand when a machine in X times better. Want to code by hand, as artisans of old? Suit yourself. I, for one, love the smell of burning chrome.
- grey-area 8mo agoIf only they could fix the iOS autocomplete, which is getting worse with every iteration.
- deleted 8mo ago[deleted]
- zozbot234 8mo agoMuch of this information we already knew the very basics of from documentation of the M1/M2 ANE as accessed via bare-metal from Asahi Linux, but it's nice to see confirmation and it being explored in further depth. Note that according to OP Parts 1/2 for very large matmuls CoreML adds little to no overhead compared to the lower-level interface, so there seems to be plenty of scope for supporting ANE for prefill in local AI frameworks. Decode is generally memory-bandwidth limited unless context is very large, and the ANE requires special handling (converting from matmul to 1x1 convolution as described here is wasteful of memory bandwidth, as is potentially dequantizing to INT8/FP16 in memory) so it's less of a clear win.
- notepad0x90 8mo agoI've been guilty of this myself, but every other comment here is like "What about <insert something unrelated to the topic but related to apple>".
- saagarjha 8mo agoI think they’re fairly reasonable now at least
- blobbers 8mo agoCan someone help me understand when these neural engines kick in in open source software? I typically use python ML libraries like lightgbm, sklearn, xgboost etc. I also use numpy for large correlation matrices, covariance etc. Are these operations accelerated? Is there a simple way to benchmark? I see a lot of benchmarks on what look like C functions, but today in my jobs I rely on higher level libraries. I don't know if they perform any better on apple HW, and unless they have a flag like use_ane I'm inclined to think they do better. Of course chatgpt suggested I benchmark an Intel Mac vs. newer apple silicon. Thanks chatgpt, there's a reason people still hate AI.
- zozbot234 8mo ago> when these neural engines kick in in open source software? It mostly doesn't because NPUs are bespoke and vendor-specific (which incents neglect by software devs working on open source numerics and ML/AI infrastructure), and the Apple ANE is no exception. Part of this effort is most likely about fixing that for the specific case of the Apple ANE.
- blobbers 8mo agoPart of which effort? The Reverse engineering is so it can be used blog article? I just think: great it seems like I'm paying for a hardware accelerator that makes Siri go faster. And I use siri on my laptop exactly 0 times in the last infinite years.
- bri3d 8mo agoIt also makes a lot of really useful features like on device OCR, captions, voice isolation, temporal antialiasing in metalfx, an enormous host of things in the apple pro apps, etc. work
- blobbers 8mo agoYeah, I don't use any of those features. So it sounds like its for folks who are creatives running lightroom or apple movie, or some kind of apple sound program? I'm a dev, not a creative, unfortunately. I don't use other people's software, I generally write my own (or used to before Claude took over my world).
- rayiner 8mo agoHoly crap, 32MB of SRAM on the chip for AI.
- Geee 8mo agoIs it really worth having separate GPU and NE? Seems redundant and weird compared to what Nvidia is doing, i.e. "GPUs are good NEs", or is that not really true?
- jasonwatkinspdx 8mo agoNo, GPUs are not what you'd design for neural networks from first principles. They were adopted for that because they offered far more parallelism than general purpose cpus, not because they're ideal. That's why Google et all designed TPUs that have a very different internal structure. Most TPU designs have been based around systolic arrays, which for matrix ops have a quadratic speedup. A typical design is a 128x128 array of MAC units. You shift weights along one dimension, parameters along the other. It takes 128 cycles to shift a full matrix input in, then 128 cycles to shift the answer back out, but during those 256 cycles you got 16,384 MAC operations done, for a factor of 64 speedup. The other big appeal of this design is it's way simpler than GPUs. The memory access patterns are predictable, there's no threads or thread divergence, etc. So it can be way more efficient in silicon, not just in area but especially in power efficiency. There's other ideas for architectures besides this basic systolic array idea. If you want to learn about them, a good place would be the HotChips presentations of the last few years: https://hc2025.hotchips.org https://hc2025.hotchips.org and similar domain names for prior years.
- 0-_-0 8mo agoWhen you already have a GPU in a system, adding tensor cores to it is much more efficient than adding a separate NPU which needs to replicate all the data transfer pipelines and storage buffers that the GPU already has. Besides, Nvidia's tensor cores are systolic.
- jasonwatkinspdx 8mo agoNo, if that were the case, then Google would have made GPUs + NN cores vs TPUs. There's far more microarchitectural complexity in GPUs that actually isn't efficient for NN structures. "Systolic array" actually means something more specific than "repeated structures on a die." Again, I'd suggest referencing the various HotChips presentations. It's a really interesting topic area. Or the original TPU v1 paper for the basics.
- vdivyanshu 8mo agoI went digging down the rabbit hole over the last 6 hours on what compute around training can be extracted from M4/M5 Neural Engine chips: - was able to offload @karpathy's NanoGpt training run(partially) on Apple Neural Engine. - moved the Classifier & Softmax layers directly onto the ANE - Classifier is 10x faster, and Softmax is 34x faster - fixed memory exhaustion: original repo had an ARC memory leak that capped training at ~119 compile loads per process. - patched the C-bridge, allowing continuous, stable training Repo - https://github.com/vipuldivyanshu92/ANEgpt https://github.com/vipuldivyanshu92/ANEgpt
- bytesandbits 8mo agoincredible work
- 3abiton 8mo agoThat's the best kind of "benders"
- nbardy 8mo agoWhy does apple want to make this hardware hard to access? What actual benefits do they get? I guess they can have their own models run faster than the competition on their hardware? But they don't even really have anything that consumers use on the ANE as far as I can tell and local LLMs are taking off on macs and could really benefit from this
- owlbite 8mo agoI suspect main benefits are they have no need to maintain the hardware or software for any longer than it makes sense for their own needs, and don't have to handhold users through a constantly evolving minefield of performance and technical capabilities.
- instahotstar 8mo agoReally impressive reverse engineering work. I’m curious how much of the Neural Engine’s instruction set is undocumented versus inferred experimentally. Also wondering how Apple balances power efficiency vs peak throughput in the M4 compared to previous generations.
- cedws 8mo agoI’m surprised that Claude assisted with this reverse engineering work. I used Codex recently for a similar purpose and got an account warning. Initially refused to do it, and then I was able to trick it. Seems I might have to make the jump back.
- asimovDev 8mo agowow really? I used Copilot for reverse engineering an application couple months back and it was eager to help, happily consuming wireshark logs and whatnot
- cedws 8mo agoYes, apparently OpenAI is super paranoid about 5.3 Codex being abused so if you trip their safety mechanism you have to verify your ID.
- heggenhougen 8mo ago[flagged]
- basedcapitalll 8mo ago[dead]