I've found the process of porting custom ML models to iOS extremely difficult. AFAIK the only way to leverage Apple Neural Engine (and get the best performance) is to use CoreML. The only documented way to use CoreML is via coremltools, which takes a trace of a PyTorch model and attempts to translate it into a protobuf graph understood by CoreML. This process often fails and requires model changes, or worse "succeeds…
I don't understand why Apple isn't trying to integrate better with the standard tools for that field. I guess it makes sense to lock in app devs, but ML eng.? That said I've had good success with onnxruntime recently [0]. [0] https://onnxruntime.ai/docs/execution-providers/CoreML-Execu...
MLX: An array framework for Apple Silicon
31–40 of 47 posts
Re: MLX: An array framework for Apple Silicon
#32That being said, going to spend some time getting familiar with it by reimplementing Llama-2 and trying to make it fast: https://github.com/jbarrow/mlxllama
Re: MLX: An array framework for Apple Silicon
#33Re: MLX: An array framework for Apple Silicon
#34It looks like this is still missing many matrix operations like QR, SVD, einsum, etc. Is there a clear route to using these on the GPU in Python on Apple Silicon? Last I checked the PyTorch backend was still missing at least QR...
einsum seems like a reasonable thing to request, but it's hard to be performant across the entire surface exposed by the operation.
Re: MLX: An array framework for Apple Silicon
#35It looks like this is still missing many matrix operations like QR, SVD, einsum, etc. Is there a clear route to using these on the GPU in Python on Apple Silicon? Last I checked the PyTorch backend was still missing at least QR...
factorization methods are somewhat uncommonly used in deep learning (the likely target of this framework) and have compute properties (such as approximate outputs, non-deterministic number of iterations) that make them unlike the BLAS++ standard APIs. einsum seems like a reasonable thing to request, but it's hard to be performant across the entire surface exposed by the operation.
https://github.com/pytorch/pytorch/issues/77764
NVIDIA's moat is not just in providing BLAS++ operations, but extending this to a wider range of cuSPARSE, cuSOLVE, cuTENSOR, etc. Without these, it feels like Apple is just trying to play catch up with whatever is popular and unsupported...
Re: MLX: An array framework for Apple Silicon
#36Probably reading into this too much, but is this hinting at future Neural Engine support?
It’d be nice to access that without CoreML.
Re: MLX: An array framework for Apple Silicon
#37Earlier quoted context omitted.
I don't understand why Apple isn't trying to integrate better with the standard tools for that field. I guess it makes sense to lock in app devs, but ML eng.? That said I've had good success with onnxruntime recently [0]. [0] https://onnxruntime.ai/docs/execution-providers/CoreML-Execu...
The project probably at least partially serves as documentation for other platforms to integrate Silicon acceleration. It basically demonstrates how to use macOS Accelerate and Metal MPS (metal performance shaders) using C++ for Machine Learning and training optimization. Thus other platforms can simply take this backend-code and integrate it. (Pytorch basically did that already with Apple's help).
Re: MLX: An array framework for Apple Silicon
#38Earlier quoted context omitted.
Note that there is a Metal backend for PyTorch [0]. Sadly it doesn't work well with codebases that didn't account for it from the start... [0] https://developer.apple.com/metal/pytorch/
This is (partly) outdated. MPS (metal performance shaders) are now (since torch 2.x) fully integrated in standard Pytorch releases, no external backends or special torch versions are needed. There are few limitations left when compared with other backends. Instead of using 'cuda' device, one simply uses 'MPS' as device. What remains is: the optimizations Pytorch provides (especially compile() with 2.1) focus on cuda…
Re: MLX: An array framework for Apple Silicon
#39I wish there was more information as to how this differs from or improves on Jax. Flax+Jax+OpenXLA seems to finally be building some momentum so when a big player launches yet another competitor, the justification for it would be a good thing to see. What was “not good enough” with Jax? Why did it make sense to put this human time and energy there instead of doubling down on Flax/Jax/OpenXLA? How will this move the n…
The quick start guide has an overview.
> The Python API closely follows NumPy with a few exceptions. MLX also has a fully featured C++ API which closely follows the Python API.
The main differences between MLX and NumPy are:
Composable function transformations: MLX has composable function transformations for automatic differentiation, automatic vectorization, and computation graph optimization.
Lazy computation: Computations in MLX are lazy. Arrays are only materialized when needed.
Multi-device: Operations can run on any of the supported devices (CPU, GPU, …)
The design of MLX is inspired by frameworks like PyTorch, Jax, and ArrayFire. A noteable difference from these frameworks and MLX is the unified memory model. Arrays in MLX live in shared memory. Operations on MLX arrays can be performed on any of the supported device types without performing data copies. Currently supported device types are the CPU and GPU.Re: MLX: An array framework for Apple Silicon
#40This is really cool. I wonder how long it will be till we have GPT-4 quality models that run locally (if we ever will). Would open up a lot of possibilities.