itsmostafa/llm-engineering-skills/mlx
- community
Checking that the SKILL.md file is still in the repository.
Running and fine-tuning LLMs on Apple Silicon with MLX. Use when working with models locally on Mac, converting Hugging Face models to MLX format, fine-tuning with LoRA/QLoRA on Apple Silicon, or serving models via HTTP API.
Install
npx vskill@latest install itsmostafa/llm-engineering-skills/mlxSKILL.md
Using MLX for LLMs on Apple Silicon
MLX-LM is a Python package for running large language models on Apple Silicon, leveraging the MLX framework for optimized performance with unified memory architecture.
Table of Contents
- Core Concepts
- Installation
- Text Generation
- Interactive Chat
- Model Conversion
- Quantization
- Fine-tuning with LoRA
- Serving Models
- Best Practices
- References
Core Concepts
Why MLX
| Aspect | PyTorch on Mac | MLX | |
|---|---|---|---|
| Memory | Separate CPU/GPU copies | Unified memory, no copies | |
| Optimization | Generic Metal backend | Apple Silicon native | |
| Model loading | Slower, more memory | Lazy loading, efficient | |
| Quantization | Limited support | Built-in 4/8-bit |
MLX arrays live in shared memory, accessible by both CPU and GPU without data transfer overhead.
Supported Models
MLX-LM supports most popular architectures: Llama, Mistral, Qwen, Phi, Gemma, Cohere, and many more. Check the mlx-community on Hugging Face for pre-converted models.
Installation
Requires macOS 13.5+ and Apple Silicon (M1/M2/M3/M4).
Text Generation
Python API
Streaming Generation
Batch Generation
CLI Generation
Interactive Chat
CLI Chat
Python Chat
Model Conversion
Convert Hugging Face models to MLX format:
CLI Conversion
Python Conversion
Conversion Options
| Option | Default | Description | |
|---|---|---|---|
--q-bits | 4 | Quantization bits (4 or 8) | |
--q-group-size | 64 | Group size for quantization | |
--dtype | float16 | Data type for non-quantized weights |
Quantization
MLX supports multiple quantization methods for different use cases:
| Method | Best For | Command | |
|---|---|---|---|
| Basic | Quick conversion | mlx_lm.convert -q | |
| DWQ | Quality-preserving | mlx_lm.dwq | |
| AWQ | Activation-aware | mlx_lm.awq | |
| Dynamic | Per-layer precision | mlx_lm.dynamic_quant | |
| GPTQ | Established method | mlx_lm.gptq |
Quick Quantization
For detailed coverage of each method, see reference/quantization.md.
Fine-tuning with LoRA
MLX supports LoRA and QLoRA fine-tuning for efficient adaptation on Apple Silicon.
Quick Start
Fuse Adapter into Model
For detailed LoRA configuration and training patterns, see reference/fine-tuning.md.
MLX-LM also supports --fine-tune-type dora and --fine-tune-type full when the task needs more capacity than standard LoRA.
Serving Models
OpenAI-Compatible Server
Python Client
Best Practices
- Use pre-quantized models: Download from
mlx-communityon Hugging Face for immediate use
- Match quantization to your hardware: M1/M2 with 8GB: use 4-bit; M2/M3 Pro/Max: 8-bit for quality
- Leverage unified memory: Unlike CUDA, MLX models can exceed "GPU memory" by using swap (slower but works)
- Use streaming for UX:
stream_generateprovides responsive output for interactive applications
- Cache prompt prefixes: Use
mlx_lm.cache_promptfor repeated prompts with varying suffixes
- Limit KV cache for long generations: Use
--max-kv-sizeto cap memory at the cost of long-range quality
- Batch similar requests:
batch_generateis more efficient than sequential generation
- Start with 4-bit quantization: Good quality/size tradeoff; upgrade to 8-bit if quality issues
- Fuse adapters for deployment: After fine-tuning, fuse adapters for faster inference without loading separately
- Monitor memory with Activity Monitor: Watch memory pressure to avoid swap thrashing
- Use chat templates: Always apply
tokenizer.apply_chat_template()for instruction-tuned models
References
See reference/ for detailed documentation:
quantization.md- Detailed quantization methods and when to use eachfine-tuning.md- Complete LoRA/QLoRA training guide with data formats and configuration
External documentation:
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 repositoryCheckingskills/mlx/SKILL.md
Popularity
- Repository stars
- 18
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 31 Mar 2026, 7 months ago.
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/itsmostafa/llm-engineering-skills/mlx)