# MLX

An array framework for machine learning on Apple silicon, with a NumPy-like Python API and matching C++, C and Swift APIs, plus higher-level packages that follow PyTorch.

MLX is an array framework for machine learning on Apple silicon, built by Apple's machine learning research team. Its Python API closely follows NumPy, with matching C++, C and Swift APIs, and higher-level packages such as mlx.nn and mlx.optimizers that follow PyTorch conventions for building more complex models.

MLX supports composable function transformations for automatic differentiation, automatic vectorization and computation graph optimization. Computation is lazy, so arrays are materialized only when needed, and computation graphs are built dynamically, so changing an argument's shape does not trigger slow recompilation. Arrays live in a unified memory model shared across the CPU and GPU, so operations can run on either device without copying data.

It installs from PyPI, with separate packages for macOS, a CUDA backend on Linux, and a CPU-only Linux build. Example applications include transformer language model training, large-scale text generation and LoRA fine-tuning, Stable Diffusion image generation, and speech recognition with Whisper.

Website: https://ml-explore.github.io/mlx/
