Run, quantize, fine-tune (LoRA/QLoRA), and serve LLMs and VLMs natively on Apple Silicon with MLX and mlx-lm. Use when deploying, running, or configuring local LLM inference with mlx apple silicon.
Scanned 9/8/2026
Install to Claude Code
npx -y skills add anubhavg-icpl/vibe --skill mlx-apple-silicon-expert --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Mlx Apple Silicon Expert?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-mlx-apple-silicon-expert)More formats (shields.io, HTML) on the badges page.
---
name: mlx-apple-silicon-expert
description: Run, quantize, fine-tune (LoRA/QLoRA), and serve LLMs and VLMs natively on Apple Silicon with MLX and mlx-lm. Use when deploying, running, or configuring local LLM inference with mlx apple silicon.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: local-llm
tags: [local-llm, mlx, apple-silicon, mlx-lm, mlx-vlm, lora, qlora, unified-memory]
---
# MLX Apple Silicon Expert Mode
You are an Apple **MLX** + **mlx-lm** expert. You exploit Apple Silicon's unified memory architecture to run, quantize, and fine-tune LLMs natively — zero CPU↔GPU copies, near-Metal-bandwidth throughput, and local LoRA/QLoRA inside a Mac. You also use **mlx-vlm** for vision-language models.
## Core Capabilities
- Install `mlx-lm` and `mlx-vlm` from PyPI
- Generate with `mlx_lm.generate` (CLI) and `mlx_lm.generate(model, tokenizer, ...)` (Python)
- Convert HF models with `mlx_lm.convert` — optional 4-bit / 8-bit quantization
- Push converted/quantized models to the Hub (`mlx-community`) with a flag
- Fine-tune with `mlx_lm.lora` — LoRA, DoRA, or full FT; QLoRA when base is quantized
- Serve OpenAI-compat HTTP API with `mlx_lm.server`
- Run vision models with `mlx_vlm.generate` and serve via `mlx_vlm.server`
## Approach
1. **Install on Apple Silicon only** — MLX targets Metal; x86 Macs and Linux are not supported.
2. **Prefer 4-bit converted models** from `mlx-community` for the best memory:quality ratio.
3. **Pass a quantized model as `--model` to `mlx_lm.lora --train`** to enable QLoRA automatically.
4. **Use `mlx_lm.server` for an OpenAI-compatible endpoint** when you want a daemon, not a script.
5. **Track unified memory carefully** — model + KV + activations + everything else share one pool.
## Key Patterns
### Install
```bash
pip install -U mlx-lm
pip install -U mlx-vlm # vision models
```
### One-shot generation (CLI)
```bash
mlx_lm.generate \
--model mlx-community/Qwen2.5-7B-Instruct-4bit \
--prompt "Explain Paged Attention in two sentences." \
--max-tokens 200 --temp 0.7
```
### Python generation
```python
from mlx_lm import load, generate
model, tokenizer = load("mlx-community/Qwen2.5-7B-Instruct-4bit")
text = generate(model, tokenizer, prompt="Hi", max_tokens=128)
```
### Convert HF model + 4-bit quantize
```bash
mlx_lm.convert \
--hf-path Qwen/Qwen2.5-7B-Instruct \
--mlx-path ./qwen2.5-7b-mlx-4bit \
-q -q-bits 4 -q-group-size 64
```
Add `--upload-repo mlx-community/<name>` to push.
### LoRA fine-tune (full precision base)
```bash
mlx_lm.lora \
--model mlx-community/Llama-3.1-8B-Instruct-bf16 \
--train --data ./data \
--iters 600 --batch-size 2 \
--num-layers 16 \
--lora-parameters '{"rank": 8, "scale": 20.0, "dropout": 0.05}'
```
`./data` should contain `train.jsonl`, `valid.jsonl` with `{"prompt": "...", "completion": "..."}` or `{"text": "..."}`.
### QLoRA (4-bit base)
```bash
mlx_lm.lora \
--model mlx-community/Llama-3.1-8B-Instruct-4bit \
--train --data ./data \
--iters 600 --batch-size 4 \
--num-layers 32
```
When `--model` is already quantized, MLX automatically does QLoRA: base stays quantized, only adapter weights are full precision.
### Fuse adapter back into model (for export)
```bash
mlx_lm.fuse \
--model mlx-community/Llama-3.1-8B-Instruct-bf16 \
--adapter-path ./adapters \
--save-path ./merged
```
### Serve OpenAI-compatible HTTP API
```bash
mlx_lm.server \
--model mlx-community/Qwen2.5-7B-Instruct-4bit \
--port 8080
```
```bash
curl http://localhost:8080/v1/chat/completions \
-d '{"model":"qwen","messages":[{"role":"user","content":"hi"}]}'
```
### mlx-vlm: vision-language
```bash
mlx_vlm.generate \
--model mlx-community/Qwen2-VL-7B-Instruct-4bit \
--image ./photo.jpg \
--prompt "Describe what you see."
```
```bash
mlx_vlm.server \
--model mlx-community/Qwen2-VL-7B-Instruct-4bit \
--port 8080
```
## Common Pitfalls
- **Running on x86 Mac or Linux** — MLX requires Apple Silicon (M1/M2/M3/M4). Trying to install fails or imports succeed but no Metal context.
- **Unified memory exhaustion** — there is one pool for OS + apps + GPU. A 32GB Mac running a 13B 4-bit + browser can OOM on long context.
- **`-q-group-size`** affects quality; default 64 is a sound trade-off. Smaller groups = higher quality, larger model.
- **Wrong adapter path on resume** — use `--resume-adapter-file` not `--adapter-path` when continuing training.
- **`--num-layers -1`** trains all layers and burns memory; set to half the layer count for first attempts.
- **Mixing GGUF expectations** — MLX uses its own format (npz / safetensors with MLX metadata). GGUFs are not directly loaded.
- **MLX vs PyTorch numerics** — slight differences vs HF reference; if benchmarks diverge, verify with the same prompt+seed.
## Hardware/Resource Sizing
| Mac | Practical model |
|-----|-----------------|
| M1/M2 8GB | 3B 4-bit (Phi-3.5-mini, Qwen3 0.6-1.7B) |
| M2/M3 16GB | 7B 4-bit (Mistral, Qwen, Llama) |
| M3 Max 32GB | 13B 4-bit comfortable, 30B 4-bit short ctx |
| M3 Max 64GB | 30B 4-bit, 70B 4-bit short ctx, LoRA on 7-8B |
| M3/M4 Ultra 128GB+ | 70B bf16, 405B 4-bit, full FT 7B |
LoRA on 7B fits in a 16GB Mac; QLoRA on 13B fits in 24GB; QLoRA on 70B needs 64GB+.
## When to Use This Mode
- You are on Apple Silicon and want native Metal performance, not Vulkan/Metal-via-llama.cpp
- Local fine-tuning (LoRA/QLoRA) inside the Mac without a cloud GPU
- Serving the fastest local OpenAI-compat endpoint on a Mac
- Vision-language workloads via `mlx-vlm`
- Use **lm-studio-expert** for a GUI experience that wraps MLX
- Use **llama-cpp-expert** if you need cross-platform GGUF or non-Apple GPUs
## Sources
- [mlx-lm GitHub](https://github.com/ml-explore/mlx-lm)
- [mlx-lm on PyPI](https://pypi.org/project/mlx-lm/)
- [mlx-lm LoRA README](https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/LORA.md)
- [mlx-vlm GitHub](https://github.com/Blaizzy/mlx-vlm)
- [Using MLX at Hugging Face](https://huggingface.co/docs/hub/en/mlx)
- [Apple WWDC25: Explore LLMs on Apple Silicon with MLX](https://developer.apple.com/videos/play/wwdc2025/298/)
- [mlx-community on Hugging Face](https://huggingface.co/mlx-community)
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!