kellyvv/phoneclaw/mlx-swift
- community
Checking that the SKILL.md file is still in the repository.
MLX Swift - High-performance ML framework for Apple Silicon with lazy evaluation, automatic differentiation, and unified memory
Install
npx vskill@latest install kellyvv/phoneclaw/mlx-swiftSKILL.md
MLX Swift Framework
MLX Swift is Apple's high-performance machine learning framework designed specifically for Apple Silicon. It provides NumPy-like array operations with lazy evaluation, automatic differentiation, and unified CPU/GPU memory.
When to Use This Skill
- Array operations on Apple Silicon (MLXArray)
- Building neural networks (MLXNN)
- Training models with automatic differentiation
- Custom Metal kernels via MLXFast
- Performance optimization with JIT compilation
Architecture Overview
Key File Reference
| Purpose | File Path | |
|---|---|---|
| Core array | Source/MLX/MLXArray.swift | |
| Operations | Source/MLX/Ops.swift | |
| Transforms | Source/MLX/Transforms.swift | |
| Factory methods | Source/MLX/Factory.swift | |
| Neural layers | Source/MLXNN/*.swift | |
| Optimizers | Source/MLXOptimizers/Optimizers.swift | |
| Fast ops | Source/MLX/MLXFast.swift | |
| Custom kernels | Source/MLX/MLXFastKernel.swift | |
| Wired memory coordinator | Source/MLX/WiredMemory.swift | |
| GPU working-set helper | Source/MLX/GPU+Metal.swift |
Quick Start
Basic Array Creation
Array Properties
Basic Operations
Building a Neural Network
Training Loop
Primary Workflow: Array Operations
See arrays.md for detailed array creation and indexing.
Creation Functions
Indexing
Shape Manipulation
Secondary Workflow: Neural Networks
See neural-networks.md for complete layer reference.
Built-in Layers
Module Property Wrappers
Loss Functions
Tertiary Workflow: Training
See transforms.md for automatic differentiation details.
Gradient Computation
Optimizers
See optimizers.md for all optimizers.
Compilation for Performance
Quaternary Workflow: Wired Memory Coordination
See wired-memory.md for full policy, hysteresis, and admission guidance.
Best Practices
DO
- Use lazy evaluation: MLX arrays are computed lazily. Call
eval()strategically to control memory and compute. - Batch eval calls:
eval(a, b, c)is more efficient than separate calls. - Use `@ModuleInfo` for all module properties to enable quantization and updates.
- Use actors for concurrent code: Encapsulate MLX state within actors for thread safety.
- Use namespaced functions:
MLXRandom.uniform(),FFT.fft(),Linalg.inv(). - Use ticket-based wired memory coordination: Prefer
WiredMemoryTicket.withWiredLimitandWiredMemoryManager.shared.
DON'T
- Don't share MLXArrays across tasks: MLXArray is NOT Sendable by design.
- Don't use deprecated module imports: Use
import MLXnotimport MLXRandom. - Don't forget to eval(): Unevaluated arrays can accumulate large compute graphs.
- Don't mutate arrays directly: Use operations that return new arrays.
- Don't call deprecated wired-limit APIs: Avoid
GPU.withWiredLimit(...)andMemory.withWiredLimit(...).
Deprecated Patterns
| If you see... | Use instead... | |
|---|---|---|
import MLXRandom | import MLX then MLXRandom.uniform() or free function uniform() | |
import MLXFFT | import MLX then FFT.fft() | |
import MLXLinalg | import MLX then Linalg.inv() | |
GPU.activeMemory | Memory.activeMemory | |
GPU.withWiredLimit(...) | WiredMemoryTicket(...).withWiredLimit { ... } via WiredMemoryManager | |
Memory.withWiredLimit(...) | WiredMemoryTicket(...).withWiredLimit { ... } | |
repeat(_:count:) | repeated(_:count:) | |
addmm() | addMM() | |
LogSoftMax | LogSoftmax | |
SoftMax | Softmax |
See deprecated.md for the complete migration guide.
Swift Concurrency Notes
MLX has specific concurrency behavior:
- MLXArray is NOT Sendable: This is intentional. Arrays contain references to compute graphs.
- evalLock protects eval/stream creation: The global lock serializes evaluation and stream operations.
- Lazy operations are NOT thread-safe: Don't share arrays across tasks without proper synchronization.
- Use actors to encapsulate MLX state: Create and use MLXArrays within the same actor.
- Use wired-memory tickets for concurrent inference: Coordinate active/reservation budgets through the shared manager.
See concurrency.md for thread safety details.
Reference Documentation
- Arrays - Array creation, properties, indexing
- Operations - Math ops, broadcasting, reductions
- Transforms - grad, vmap, compile, eval
- Neural Networks - Layers and modules
- Optimizers - Training optimizers
- Custom Layers - Building custom modules
- Custom Kernels - Metal kernels with MLXFast
- Wired Memory - Ticket-based wired limit coordination
- Concurrency - Thread safety guide
- Deprecated - Migration guide
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingPackages/mlx-swift/skills/mlx-swift/SKILL.md
Popularity
- Repository stars
- 1,129
- Repository forks
- 152
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kellyvv/phoneclaw/mlx-swift)