196 points · by ingve · 4y ago · 97 comments
I was waiting for the Mac Studio to drop to come to a conclusion, since it's plausible one ANE could've been disabled for power reasons on the laptops... but with both secondary ANEs in each die in the M1 Ultra off, and with no reports of anyone seeing the first ANE being disabled instead (which could mean it's a yield thing), I'm going to go ahead and say there was a silicon bug or other issue that made the second ANE inoperable or problematic, and they just decided to fuse it off and leave it as dead silicon on all M1 Max/Ultra systems.
Sony pulled a similar trick on their A7 series cameras, and enabled more advanced AF features just with a firmware upgrade. It made the bodies "new" and pushed them at least half a generation forward. It's not the same thing, I know, but it feels similar enough for me.
A big design with many cores, such as CPU or GPU cores, may have manufacturing defects that makes one or more cores bad. Or it may be on one side or another of a tolerance range and not be able to work at higher power or higher frequency. These parts may get "binned" into a lower performance category, with some cores disabled (because a flaw prevents the core from working) or with reduced maximum performance states.
These are still "good" parts, and can be sold at a lower cost with lower performance, while the "better" and "best" parts will pass more tests and be able to have more or all portions of the chip enabled.
So it's not so much to work around a "bug" which might be a common flaw to all part designs, rather to work around manufacturing tolerance and allow more built parts to be useful rather than garbage.
I can take my old D70s today and take beautiful photos, even with it's 6MP sensor, however a newer body would be much more flexible.
Could it be overheating if the ANE's are not used the right way?
It would be reasonable to assume that if both engines work, then the second is always the one to be disabled. Therefore to have the second enabled you'd need to find one where the first engine has failed, and has no other chip killing faults. Depending on the yield TSMC gets, these could be quite rare, so you'd have to have quite a large survey to find them.
Or as other people have noted, it could be an errata meaning the second core is broken, as this isn't the only possible reason.
The linked posting notes that they were able to get the ANE to draw 49 mW. Is this such a significant amount of power that its worth permanently disabling for laptop power draw? Or is there likely much more power being used elsewhere to support ANE in addition to the 49 mW that can be measured directly?
...maybe Apple disabled it for a reason, y'know?
[0]: https://github.com/geohot/tinygrad/tree/master/accel/ane
https://www.youtube.com/watch?v=mwmke957ki4
https://www.youtube.com/watch?v=H6ZpMMDvB1M
I wonder why Apple didn't provide low-level API's to access the hardware? It may have various restrictions. I recall Apple also didn't provide proper API's to access OpenCL frameworks on iOS, but some people found workarounds to access that as well. Maybe they only integrate with a few limited but important use cases, TensorFlow, Adobe that they can control.
Could it be that using the ANE in the wrong way overheats the M1?
One of the earliest lessons along this line was Itanium. Itanium exposing so much of the underlying architecture as a binary format and binary ABI made evolution of the design extremely difficult later on, even if you could have magically solved all the compiler problems back in 2000. Most machine learning accelerators are some combination of a VLIW and/or systolic array design. Most VLIW designers have learned that exposing the raw instruction pipeline to your users is a bad idea not because it's impossibly difficult to use (compilers do in fact keep getting better), but because it makes change impossible later on. This is also why we got rid of delay slots in scalar ISAs, by the way; yes they are annoying but they also expose too much of the implementation pipeline, which is the much bigger issue.
Many machine learning companies take similar approaches where you can only use high-level frameworks like Tensorflow to interact with the accelerator. This isn't something from Apple's playbook, it's common sense once you begin to design these things. In the case of Other Corporations, there's also the benefit that it helps keep competitors away from their design secrets, but mostly it's for the same reason: exposing too much of the implementation details makes evolution and support extremely difficult.
It sounds crass but my bet is that if Apple exposed the internal details of the ANE and later changed it (which they will, 100% it is not "done") the only "outcome" would be a bunch of rageposting on internet forums like this one. Something like: "DAE Apple mothershitting STUPID for breaking backwards compatibility? This choice has caused US TO SUFFER, all because of their BAD ENGINEERING! If I was responsible I would have already open sourced macOS and designed 10 completely open source ML accelerators and named them all 'Linus "Freakin Epic" Torvalds #1-10' where you could program them directly with 1s and 0s and have backwards compatibility for 500 years, but people are SHEEP and so apple doesn't LET US!" This will be posted by a bunch of people who compiled "Hello world" for it one time six months ago and then are mad it doesn't "work" anymore on a computer they do not yet own.
> Could it be that using the ANE in the wrong way overheats the M1?
No.
Using a high level API probably makes it easier to implement a software version for hardware that doesn't have the neural engine, like Intel Macs or older A-cores.
[1] Although this probably starts a long conversation about various GPU and ML core APIs and quite how low level they get.
I honestly don't know of a single company offering custom machine learning accelerators that let you do anything except use Tensorflow/PyTorch to interface with them, not a chance in hell any they actually will give you the underlying ISA specifics. Maybe the closest is, like, the Xilinx Versal devices or GPUs, but I don't quite put them in the same category as something like Habana, Groq, GraphCore, where the architecture is bespoke for exactly this use case, and the high level tools are there to insulate you from architectural changes.
If there are any actual productionized, in-use accelerators with low level details available that weren't RE'd from the source components, I'd be very interested in seeing it. But the trend here is very clear unless I'm missing something.
What consumer apps actually use Neural Engines?
I think something like Photoshop, maybe. But wouldn't it just train a model and use it as regular code?
I'm interested in AI, but it's a joke to me about startups and jargon more often than not.
I feels weird to add this to all chips when I can't see that much usage.
- Visual Lookup - Animoji - Face ID - recognizing "accidental" palm input while using Apple Pencil - monitoring users' usage habits to optimize device battery life and charging - app recommendations - Siri - curating photos into galleries, selecting "good" photos to show in the photos widget - identifying people's faces in photos - creating "good" photos with input from tiny camera lenses and sensors - portrait mode - language translation - on-device dictation - AR plane detection
Core ML API allows third party developers to use Neural Engine to run models
Of course if you’re using third party libraries that don’t rely on macOS APIs this won’t be happening in your app.
https://www.theverge.com/2021/12/15/22837631/apple-csam-dete...
I know that C++ is out of vogue, but last time I wrote drivers in linux and OSX (10 years ago) I left with the distinct impression that it was oversold, at least compared to C. C clunks hard and C++ addresses the worst of it. I've never had to corral a bunch of overzealous junior C++ programmers, which I suspect is where the C++ reputation comes from, but Apple went down that path and wound up with something pretty decent.
IMO today it's a shrug and 25 years ago it was forward looking.
Of course, the OSX driver code is going on 25 years old, so it's not evidence of anyone's opinion that C++ beats Rust for OS dev.
C++ when used as a better C, really is better.
The second part of the chain is that you also tailor the operations the die area support to those operations necessary in a typical neural network, further optimizing the chip.
The end result is very power-efficient execution of neural networks, which allows you to beat a GPU or CPUs power curve, improving thermals of the core, and in the case of mobile devices, optimizes battery usage.
Those efficiency wins are almost certainly worth it even if third-party developers don't use it much.
Basically it's used by anything involving machine learning:
- Speech recognition
- Face recognition
- Visual lookup (image recognition)
- Live Text (OCR)
It allows all these functions to be performed efficiently on-device rather than shipping data off to the cloud.
Hmm, it seems like there's also a new API that can use the neural engine sometimes, "ML Compute". But only for inference? https://developer.apple.com/documentation/mlcompute/mlcdevic...
Reading this makes me wonder if it's not just a placeholder for some kind of intrusive system that will neural-hash everything you own, but I'm sure I'm just being paranoid.
It’s also actively counter-productive: if they wanted to do this sort of tracking, they could just have done what all of their competitors do and send the data straight to their servers. This is hardware (and thus expenses) which is only necessary because of their stance on privacy, and avoiding off-device work.
It however turns out that a _lot_ of customer apps today don't use those accelerators at all.
(and about the attempt at using BNNS functions, that's not offloaded, it runs on the host CPU cores w/ the AMX tightly bound accelerator)
So when running a neural net iOS / macOS needs to make a decision about where to run each net. Even if a net has layers in it that are a perfect match for the ANE, there’s still a trade off from having move the workload back and forth between a CPU core and the ANE (although the unified memory should eliminate a big chunk of this cost).
It might be that in the general case it’s not worth the latency hit from using mixed processors when running net that isn’t 100% ANE compatible, or could just be that Apple haven’t got round to implementing the logic needed to gracefully spilt workloads across the ANE and a CPU core. Which would make sense, because they’ve got the time and expertise to ensure all their nets fit within the ANE. Something that’s difficult for 3rd party devs to do, because they don’t have access to detailed ANE docs.
The Asahi project is putting a deliberate low priority on the ANE but I have seen some other small reverse engineering attempts.
I think some use of the ANE outside of Apple APIs will be possible soon.
That would seem like the logical conclusion. Perhaps there are hardware bugs/shortcomings that makes it very hard to use for the neural network API. Perhaps the software team is just behind and still building that.