
Mlx Fine Tuning
- 9 installs
- 4 repo stars
- Updated April 11, 2026
- 89jobrien/steve
mlx-fine-tuning is a Claude Code skill for LoRA fine-tuning of LLMs with the MLX framework on Apple Silicon, covering model conversion, training, and adapter export.
About
mlx-fine-tuning is a Claude Code skill for fine-tuning large language models with the MLX framework on Apple Silicon. It walks through environment validation, converting HuggingFace models to MLX format, configuring LoRA adapters, selecting hyperparameters by dataset size, and exporting adapters. Note: the skill is marked DEPRECATED as of 2026-01-20. A developer uses it to train a local LoRA on an M-series Mac without dedicated GPU hardware.
- LoRA fine-tuning on Apple Silicon (M1/M2/M3/M4) via MLX unified memory
- Ships validate_environment.py and hyperparameter_optimizer.py scripts
- Deprecated as of 2026-01-20 (deprecated_in in frontmatter)
Mlx Fine Tuning by the numbers
- 9 all-time installs (skills.sh)
- Ranked #1,569 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
- Data as of Jul 28, 2026 (Skillselion catalog sync)
mlx-fine-tuning capabilities & compatibility
Free; runs locally on Apple Silicon with no cloud GPU cost.
- Capabilities
- llm fine tuning · lora training · model conversion · hyperparameter tuning
- Use cases
- token optimization
- Platforms
- macOS
- Pricing
- Free
What mlx-fine-tuning says it does
Comprehensive skill for fine-tuning Large Language Models using MLX framework on Apple Silicon (M1/M2/M3/M4).
MLX only works on Apple Silicon (M1/M2/M3/M4) running macOS natively.
Focus on LoRA (Low-Rank Adaptation) for parameter-efficient fine-tuning without requiring expensive GPU hardware.
npx skills add https://github.com/89jobrien/steve --skill mlx-fine-tuningAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 9 |
|---|---|
| repo stars | ★ 4 |
| Last updated | April 11, 2026 |
| Repository | 89jobrien/steve ↗ |
What it does
Fine-tune an LLM with LoRA using MLX on an Apple Silicon Mac, from model conversion through adapter export.
Who is it for?
Developers fine-tuning small LLMs locally on an M-series Mac with LoRA and limited memory.
Skip if: Non-Apple-Silicon hardware, Docker or VM environments, or teams needing a currently-maintained skill (this one is deprecated).
When should I use this skill?
Setting up MLX fine-tuning, converting HuggingFace models to MLX, configuring LoRA adapters, or benchmarking fine-tuned models on Apple Silicon.
What you get
A trained LoRA adapter for a local LLM, exported to safetensors or HuggingFace format.
- fine-tuned LoRA adapter
- converted MLX model
- benchmark comparison
By the numbers
- 8-step workflow (environment validation through adapter management)
- 3-tier hyperparameter guidance by dataset size
- 4 reference files
Files
MLX Fine-Tuning
Comprehensive skill for fine-tuning Large Language Models using MLX framework on Apple Silicon (M1/M2/M3/M4).
Purpose
Enable efficient LLM fine-tuning on Apple Silicon using MLX's unified memory architecture and Metal GPU acceleration. Focus on LoRA (Low-Rank Adaptation) for parameter-efficient fine-tuning without requiring expensive GPU hardware.
When to Use This Skill
Invoke this skill when:
- Setting up MLX fine-tuning on Apple Silicon
- Converting models from HuggingFace to MLX format
- Configuring LoRA adapters for fine-tuning
- Optimizing hyperparameters for specific datasets
- Troubleshooting memory or performance issues
- Benchmarking fine-tuned models
- Managing and exporting adapters
Platform Requirements
Critical: MLX only works on Apple Silicon (M1/M2/M3/M4) running macOS natively.
- Architecture must be
arm64(verify withuname -m) - Cannot run in Docker or virtual machines
- Requires macOS 11.0 or later
Workflow
1. Environment Validation
First, validate the environment using the provided script:
python scripts/validate_environment.pyThis checks:
- Apple Silicon architecture
- MLX installation
- Metal GPU availability
- Memory capacity
2. Model Preparation
Convert HuggingFace models to MLX format or use pre-converted models:
# Option A: Use pre-converted model from MLX Community
--model mlx-community/Qwen2.5-3B-Instruct-4bit
# Option B: Convert from HuggingFace
uv run mlx_lm.convert \
--hf-path Qwen/Qwen2.5-3B-Instruct \
--mlx-path models/Qwen2.5-3B-Instruct-mlx \
--quantize # Optional: for 4-bit quantization3. Data Preparation
Prepare training data in MLX chat format (JSONL):
{"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is machine learning?"},
{"role": "assistant", "content": "Machine learning is..."}
]}Save as train.jsonl and valid.jsonl in your data directory.
4. Hyperparameter Selection
Load references/hyperparameter_guidelines.md for detailed guidance based on dataset size.
Quick reference:
- Small datasets (<1k samples): LR 2e-5, 200-500 iterations, 4-8 layers
- Medium datasets (1k-10k): LR 1e-5, 500-1000 iterations, 8-16 layers
- Large datasets (10k+): LR 5e-6, 1000-2000 iterations, 16-32 layers
5. Training Execution
Run fine-tuning with mlx_lm:
uv run python -m mlx_lm lora \
--model models/Qwen2.5-3B-Instruct-mlx \
--train \
--data ./data \
--batch-size 1 \
--iters 500 \
--learning-rate 1e-5 \
--num-layers 8 \
--adapter-path adapters/my-lora \
--save-every 100 \
--grad-checkpoint # Enable for memory efficiency6. Memory Optimization
If encountering memory issues, load references/memory_optimization.md for techniques:
- Gradient checkpointing (
--grad-checkpoint) - Batch size reduction
- Model quantization (4-bit)
- Layer count reduction
7. Evaluation and Testing
Test the fine-tuned model:
# Interactive generation
uv run python -m mlx_lm lora \
--model models/Qwen2.5-3B-Instruct-mlx \
--adapter-path adapters/my-lora \
--prompt "Your test prompt"
# Benchmark comparison
uv run python scripts/hyperparameter_optimizer.py \
--model models/Qwen2.5-3B-Instruct-mlx \
--adapter adapters/my-lora \
--test-samples 208. Adapter Management
Export and merge adapters:
# Export to safetensors format
uv run mlx_lm.fuse \
--model models/base-model \
--adapter-path adapters/my-lora \
--save-path models/fused-model
# Convert back to HuggingFace format
uv run mlx_lm.convert \
--mlx-path models/fused-model \
--hf-path models/hf-exportTroubleshooting
For common issues, load references/common_issues.md. Quick solutions:
- Memory errors: Reduce batch size to 1, enable gradient checkpointing
- Slow training: Verify Metal GPU usage with
mx.default_device() - Training instability: Lower learning rate, increase warmup ratio
- Format errors: Validate data format matches MLX chat structure
Advanced Techniques
Multi-Phase Training with LR Decay
# Progressive learning rate schedule
--lr-schedule "400:2e-5,400:1e-5,200:2e-6"A/B Testing Configurations
Use scripts/hyperparameter_optimizer.py to test multiple configurations:
python scripts/hyperparameter_optimizer.py \
--config-file configs/experiment.yaml \
--parallel-runs 4Monitoring Training
Track key metrics:
- Training/validation loss curves
- Memory usage (
mx.metal.get_active_memory()) - Token throughput
- Gradient norms
Best Practices
1. Start Small: Test with few iterations before full training 2. Checkpoint Frequently: Use --save-every to avoid losing progress 3. Monitor Memory: Track unified memory usage throughout training 4. Validate Often: Check validation loss to detect overfitting early 5. Compare Performance: Always benchmark against base model 6. Version Control: Use descriptive names for adapter directories 7. Document Experiments: Log all hyperparameters and results
Resource References
- Load
references/hyperparameter_guidelines.mdfor detailed parameter selection - Load
references/memory_optimization.mdfor memory management techniques - Load
references/common_issues.mdfor troubleshooting guide - Load
references/mlx_api_reference.mdfor MLX-specific functions
Output Artifacts
Training produces:
adapters/*/adapters.safetensors- LoRA weightsadapters/*/adapter_config.json- Configuration- Training logs with loss curves
- Checkpoint saves at specified intervals
Integration with Pipelines
For programmatic training, integrate with pipeline systems:
from training.mlx import TrainConfig, TrainPipeline
config = TrainConfig(
model="mlx-community/Qwen2.5-3B-Instruct-4bit",
train_data="data/train.jsonl",
iters=500,
learning_rate=1e-5,
num_layers=8,
grad_checkpoint=True
)
pipeline = TrainPipeline(config)
result = pipeline.execute()# Example Asset File
This placeholder represents where asset files would be stored.
Replace with actual asset files (templates, images, fonts, etc.) or delete if not needed.
Asset files are NOT intended to be loaded into context, but rather used within
the output Claude produces.
Example asset files from other skills:
- Brand guidelines: logo.png, slides_template.pptx
- Frontend builder: hello-world/ directory with HTML/React boilerplate
- Typography: custom-font.ttf, font-family.woff2
- Data: sample_data.csv, test_dataset.json
## Common Asset Types
- Templates: .pptx, .docx, boilerplate directories
- Images: .png, .jpg, .svg, .gif
- Fonts: .ttf, .otf, .woff, .woff2
- Boilerplate code: Project directories, starter files
- Icons: .ico, .svg
- Data files: .csv, .json, .xml, .yaml
Note: This is a text placeholder. Actual assets can be any file type.
Reference Documentation for Mlx Fine Tuning
This is a placeholder for detailed reference documentation. Replace with actual reference content or delete if not needed.
Example real reference docs from other skills:
- product-management/references/communication.md - Comprehensive guide for status updates
- product-management/references/context_building.md - Deep-dive on gathering context
- bigquery/references/ - API references and query examples
When Reference Docs Are Useful
Reference docs are ideal for:
- Comprehensive API documentation
- Detailed workflow guides
- Complex multi-step processes
- Information too lengthy for main SKILL.md
- Content that's only needed for specific use cases
Structure Suggestions
API Reference Example
- Overview
- Authentication
- Endpoints with examples
- Error codes
- Rate limits
Workflow Guide Example
- Prerequisites
- Step-by-step instructions
- Common patterns
- Troubleshooting
- Best practices
#!/usr/bin/env python3
"""Validate MLX fine-tuning environment on Apple Silicon.
This script checks:
- Apple Silicon architecture
- MLX installation and version
- Metal GPU availability
- Memory capacity
- Python version compatibility
"""
import platform
import subprocess
import sys
def check_architecture():
"""Check if running on Apple Silicon."""
arch = platform.machine()
is_apple_silicon = arch == "arm64"
print(f"Architecture: {arch}")
if is_apple_silicon:
print("✓ Apple Silicon detected (M1/M2/M3/M4)")
else:
print("✗ Not Apple Silicon - MLX requires arm64 architecture")
return is_apple_silicon
def check_macos():
"""Check if running on macOS."""
system = platform.system()
is_macos = system == "Darwin"
print(f"\nOperating System: {system}")
if is_macos:
version = platform.mac_ver()[0]
print(f"✓ macOS {version}")
else:
print("✗ Not macOS - MLX requires macOS")
return is_macos
def check_mlx_installation():
"""Check if MLX is installed and get version."""
try:
import mlx
import mlx.core as mx
print("\nMLX Installation:")
print(f"✓ MLX version: {mlx.__version__}")
# Check mlx-lm separately
try:
import mlx_lm # noqa: F401
print("✓ mlx-lm installed")
except ImportError:
print("✗ mlx-lm not installed")
print(" Install with: uv add 'mlx-lm>=0.12.0'")
return False
# Test basic MLX functionality
test_array = mx.array([1, 2, 3])
_ = test_array * 2
print("✓ MLX core functionality working")
return True
except ImportError as e:
print("\nMLX Installation:")
print(f"✗ MLX not installed or import error: {e}")
print(" Install with: uv add 'mlx>=0.21.0' 'mlx-lm>=0.12.0'")
return False
except Exception as e:
print(f"✗ MLX functionality error: {e}")
return False
def check_metal_gpu():
"""Check Metal GPU availability."""
try:
import mlx.core as mx
device = mx.default_device()
print("\nGPU Status:")
print(f"Default device: {device}")
if str(device) == "gpu":
print("✓ Metal GPU available and active")
return True
print("✗ GPU not active - check Metal support")
return False
except Exception as e:
print("\nGPU Status:")
print(f"✗ Cannot check GPU: {e}")
return False
def check_memory():
"""Check system memory capacity."""
try:
import mlx.core as mx
# Get memory info using sysctl
result = subprocess.run(
["sysctl", "-n", "hw.memsize"],
check=False, capture_output=True,
text=True
)
if result.returncode == 0:
mem_bytes = int(result.stdout.strip())
mem_gb = mem_bytes / (1024**3)
print("\nSystem Memory:")
print(f"Total RAM: {mem_gb:.1f} GB")
if mem_gb >= 16:
print("✓ Sufficient memory for most fine-tuning tasks")
elif mem_gb >= 8:
print("⚠ Limited memory - use gradient checkpointing and small batch sizes")
else:
print("✗ Insufficient memory - MLX fine-tuning may fail")
# Check MLX memory if available
try:
active_mem = mx.metal.get_active_memory() / (1024**3)
print(f"Active MLX memory: {active_mem:.2f} GB")
except Exception:
pass
return mem_gb >= 8
print("\nSystem Memory:")
print("✗ Could not determine memory capacity")
return False
except Exception as e:
print("\nSystem Memory:")
print(f"✗ Memory check failed: {e}")
return False
def check_python_version():
"""Check Python version compatibility."""
version = sys.version_info
print("\nPython Version:")
print(f"Python {version.major}.{version.minor}.{version.micro}")
if version.major == 3 and version.minor >= 9:
print("✓ Python version compatible")
return True
print("✗ Python 3.9+ required for MLX")
return False
def check_uv_installation():
"""Check if uv is installed."""
try:
result = subprocess.run(
["uv", "--version"],
check=False, capture_output=True,
text=True
)
if result.returncode == 0:
print("\nPackage Manager:")
print(f"✓ uv installed: {result.stdout.strip()}")
return True
print("\nPackage Manager:")
print("✗ uv not found")
return False
except FileNotFoundError:
print("\nPackage Manager:")
print("✗ uv not installed")
print(" Install with: curl -LsSf https://astral.sh/uv/install.sh | sh")
return False
def suggest_model_sizes(mem_gb):
"""Suggest appropriate model sizes based on memory."""
print("\nRecommended Model Sizes:")
if mem_gb >= 32:
print("✓ Can handle 7B-13B models comfortably")
print("✓ 3B models with large batch sizes")
elif mem_gb >= 16:
print("✓ Can handle 3B-7B models")
print("⚠ Use gradient checkpointing for 7B+")
elif mem_gb >= 8:
print("✓ Can handle 1B-3B models")
print("⚠ Use 4-bit quantization for larger models")
else:
print("✗ Limited to very small models (<1B)")
def main():
"""Run all validation checks."""
print("=" * 60)
print("MLX Fine-Tuning Environment Validation")
print("=" * 60)
checks = {
"Architecture": check_architecture(),
"macOS": check_macos(),
"Python": check_python_version(),
"MLX": False,
"GPU": False,
"Memory": False,
"uv": check_uv_installation()
}
# Only check MLX-specific items if on Apple Silicon macOS
if checks["Architecture"] and checks["macOS"]:
checks["MLX"] = check_mlx_installation()
if checks["MLX"]:
checks["GPU"] = check_metal_gpu()
checks["Memory"] = check_memory()
# Memory capacity suggestions
try:
result = subprocess.run(
["sysctl", "-n", "hw.memsize"],
check=False, capture_output=True,
text=True
)
if result.returncode == 0:
mem_gb = int(result.stdout.strip()) / (1024**3)
suggest_model_sizes(mem_gb)
except Exception:
pass
# Summary
print("\n" + "=" * 60)
print("Validation Summary:")
print("=" * 60)
all_passed = all(checks.values())
critical_passed = checks["Architecture"] and checks["macOS"] and checks["MLX"]
for check, passed in checks.items():
status = "✓" if passed else "✗"
print(f"{status} {check}")
print("\n" + "=" * 60)
if all_passed:
print("✅ Environment fully ready for MLX fine-tuning!")
elif critical_passed:
print("⚠️ Environment partially ready - some optional features missing")
else:
print("❌ Environment not ready - critical requirements missing")
print("\nRequired fixes:")
if not checks["Architecture"]:
print("- Need Apple Silicon Mac (M1/M2/M3/M4)")
if not checks["macOS"]:
print("- Need to run on macOS")
if not checks["MLX"]:
print("- Need to install MLX: uv add 'mlx>=0.21.0' 'mlx-lm>=0.12.0'")
return 0 if critical_passed else 1
if __name__ == "__main__":
sys.exit(main())
Related skills
FAQ
What hardware does mlx-fine-tuning require?
MLX only works on Apple Silicon (M1/M2/M3/M4) running macOS natively on arm64; it cannot run in Docker or virtual machines.
What fine-tuning method does it use?
LoRA (Low-Rank Adaptation) for parameter-efficient fine-tuning without expensive GPU hardware.
Is this skill still maintained?
No, the frontmatter marks it DEPRECATED as of 2026-01-20.