Unity ML-Agents Toolkit lets Unity games and simulations serve as environments for training AI agents with reinforcement and imitation learning.
ml-explore/mlx-swift
Swift API for MLX, the array framework for machine learning on Apple silicon, letting Swift developers run ML research and experiments.
- Stars
- 2,066
- Forks
- 371
- Open issues
- 56
- Last commit
- 20 hours ago
What is it?
MLX Swift wraps MLX, an array framework for machine learning on Apple silicon, so that Swift code can use the same array, neural network and optimizer building blocks. It is distributed as a Swift package that exposes libraries such as MLX, MLXNN, MLXOptimizers and MLXRandom.
The package can be added through Xcode or SwiftPM and built with xcodebuild, which is needed to compile Metal shaders on macOS. A CMake build is also provided, including a native Linux path with a CPU backend and an optional CUDA GPU backend.
LLM and VLM implementations live in a separate mlx-swift-lm project, and the mlx-swift-examples repository contains sample apps such as an MNIST trainer, a chat app and a Stable Diffusion example.
Key features
- 01Provides Swift access to the MLX array framework for Apple silicon
- 02Ships MLX, MLXNN, MLXOptimizers and MLXRandom as separate Swift package products
- 03Installable via Xcode or SwiftPM, with xcodebuild needed for Metal shaders
- 04CMake build with native Linux support, including CPU and CUDA GPU backends
Use cases
- Running machine learning experiments natively in Swift on a Mac or iOS device
- Building an on-device app that trains or runs small neural networks on Apple silicon
- Porting MLX Python research code to a Swift codebase
Quick start
- 1
Add the mlx-swift package to your Package.swift
.package(url: "https://github.com/ml-explore/mlx-swift", from: "0.10.0") - 2
Add the MLX, MLXNN and MLXOptimizers libraries as target dependencies
- 3
Clone the repo and pull the submodules before building locally
git submodule update --init --recursive - 4
Build and run the tests with Xcode's command-line tool
xcodebuild test -scheme mlx-swift-Package -destination 'platform=OS X'
Things to know
- Targets Apple silicon; the main Metal GPU backend is macOS-focused.
- SwiftPM on the command line cannot build the Metal shaders, so the full build requires Xcode.
- Linux builds use the CPU backend by default, and CUDA support is Linux-only.
Topics
FAQ
- What is mlx-swift?
- Swift API for MLX, the array framework for machine learning on Apple silicon, letting Swift developers run ML research and experiments. MLX Swift wraps MLX, an array framework for machine learning on Apple silicon, so that Swift code can use the same array, neural network and optimizer building blocks. It is distributed as a Swift package that exposes libraries such as MLX, MLXNN, MLXOptimizers and MLXRandom.
- Is mlx-swift free to use? What license does it have?
- mlx-swift is open source under the MIT license. Check the license terms before using it in commercial products.
- Is mlx-swift still maintained?
- Actively maintained. The last commit to mlx-swift was on Oct 19, 2026.
- What can I use mlx-swift for?
- Running machine learning experiments natively in Swift on a Mac or iOS device Building an on-device app that trains or runs small neural networks on Apple silicon Porting MLX Python research code to a Swift codebase
- How do I install mlx-swift?
- Add the mlx-swift package to your Package.swift: .package(url: "https://github.com/ml-explore/mlx-swift", from: "0.10.0") Add the MLX, MLXNN and MLXOptimizers libraries as target dependencies Clone the repo and pull the submodules before building locally: git submodule update --init --recursive Build and run the tests with Xcode's command-line tool: xcodebuild test -scheme mlx-swift-Package -destination 'platform=OS X'
- Where can I get mlx-swift?
- The source code and installation instructions are on GitHub: https://github.com/ml-explore/mlx-swift
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Swift and Metal runtime that runs the 26B Gemma 4 26B-A4B model on Apple Silicon Macs with about 2 GB of RAM by streaming experts from SSD.
Free online chapter-by-chapter companion for Qiu Xipeng's Chinese deep learning textbook, in a full edition and a general-reader edition, with PDFs and errata.
A free, open-source macOS app that plays Wallpaper Engine scene, video and web wallpapers from the Steam Workshop on Apple silicon Macs.
Pools the devices you own into one AI cluster so large models can run locally across multiple Macs and other machines.
A minimal deep learning framework with a PyTorch-like tensor API, autograd, a compiler, and support for many accelerator backends.