Skip to content

Products / AI infrastructure

PMetal

PMetal is a Rust framework for fine-tuning large language models on Apple Silicon, with native Metal GPU and Apple Neural Engine support. It covers LoRA, QLoRA, DoRA, GRPO, knowledge distillation and 20+ model architectures, through a desktop GUI, terminal UI, CLI and Python SDK.

GitHub Talk to usRustOpen sourceApple SiliconMIT / Apache-2.0MIT / Apache-2.0
Install with Homebrew
brew install epistates/tap/pmetal
20+
LLM architectures
22
Specialized crates
13
GGUF quantization formats
12
Model merge strategies

Features

Built for production

01

LoRA, QLoRA and DoRA

Parameter-efficient fine-tuning with sequence packing for GPU utilization, rank-adaptive training and Metal-accelerated adapters.

02

GRPO and DAPO reasoning training

Group Relative Policy Optimization with custom and verifiable reward functions for training reasoning models.

03

Knowledge distillation

Transfer knowledge from large teacher models to smaller students with online, offline and progressive distillation, plus Reinforcement Learning KD (RLKD).

04

20+ model architectures

Support for Llama 3.x, Qwen 2.5 and QwQ, DeepSeek R1 and V3, Mistral and Mixtral, Gemma 2 and 3, and more.

05

Quantization and GGUF export

Export fine-tuned models to GGUF in 13 format options including Q4_K_M, Q8_0, F16 and BF16, compatible with llama.cpp and Ollama.

06

Model merging

Combine adapters or base models with 12 merge strategies, including TIES, DARE, linear interpolation, task arithmetic and model soups.

07

Distributed training across Macs

Connect multiple Apple Silicon machines on your local network. mDNS discovery finds peers, Ring All-Reduce synchronizes gradients, and checkpoint recovery handles dropped nodes. M1 through M5 machines can be mixed in one cluster.

08

Every interface

A Tauri and Svelte desktop GUI, a 9-tab terminal UI with vi-style navigation, a CLI with 20+ commands and shell completion, and a Python SDK built on PyO3 bindings.

09

Metal GPU and Neural Engine

Custom Metal Shading Language kernels for matrix multiplication, attention and gradient computation, with Apple Neural Engine offloading routed at runtime. The pipeline is designed around unified memory.

In code

See it work

Install and verify hardware detection
# Install via cargo
cargo add pmetal

# Or add to Cargo.toml
[dependencies]
pmetal = "0.3"

# Install the CLI tool
cargo install pmetal-cli

# Verify installation + hardware detection
pmetal info
LoRA fine-tuning with Metal acceleration
use pmetal::prelude::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Auto-detect Apple Silicon hardware
    let device = MetalDevice::auto()?;
    println!("Training on: {}", device.chip_name());

    // Load base model — weights stay in unified memory
    let model = ModelLoader::from_hub("meta-llama/Llama-3.2-3B")?
        .load_on(&device)
        .await?;

    // Configure LoRA adapters
    let lora_config = LoraConfig::builder()
        .rank(16)
        .alpha(32.0)
        .target_modules(["q_proj", "v_proj", "k_proj", "o_proj"])
        .dropout(0.05)
        .sequence_packing(true)   // maximise GPU utilisation
        .build();

    // Load dataset
    let dataset = Dataset::from_jsonl("train.jsonl")?
        .with_tokenizer(model.tokenizer())
        .max_seq_len(2048)
        .build()
        .await?;

    // Training configuration
    let train_config = TrainingConfig::builder()
        .epochs(3)
        .batch_size(4)
        .gradient_accumulation(8)
        .learning_rate(2e-4)
        .warmup_ratio(0.03)
        .scheduler(LRScheduler::CosineAnnealing)
        .output_dir("./lora-output")
        .build();

    // Start training — Metal kernels activate automatically
    let trainer = LoraTrainer::new(model, lora_config, train_config);
    trainer.train(dataset).await?;

    // Export to GGUF for Ollama / llama.cpp
    trainer.export_gguf("output.gguf", GgufFormat::Q4KM).await?;

    println!("Done! Model saved to output.gguf");
    Ok(())
}
Python SDK
# Install Python bindings
pip install pmetal

async def main():
    # Auto-detect Apple Silicon
    device = pm.MetalDevice.auto()
    print(f"Training on: {device.chip_name}")

    # Load model
    model = await pm.ModelLoader.from_hub(
        "meta-llama/Llama-3.2-3B"
    ).load_on(device)

    # Configure LoRA
    lora_config = pm.LoraConfig(
        rank=16,
        alpha=32.0,
        target_modules=["q_proj", "v_proj"],
        sequence_packing=True,
    )

    # Load dataset (HuggingFace datasets compatible)
    from datasets import load_dataset
    hf_dataset = load_dataset("tatsu-lab/alpaca", split="train")
    dataset = await pm.Dataset.from_huggingface(hf_dataset).build()

    # Training config
    train_config = pm.TrainingConfig(
        epochs=3,
        batch_size=4,
        learning_rate=2e-4,
        output_dir="./lora-output",
    )

    # Train — Metal acceleration is automatic
    trainer = pm.LoraTrainer(model, lora_config, train_config)
    await trainer.train(dataset)

    # Export GGUF
    await trainer.export_gguf("model.gguf", fmt=pm.GgufFormat.Q4KM)
    print("Training complete. model.gguf ready for Ollama.")

asyncio.run(main())

Own your AI

PMetal is designed so that training data, model weights and fine-tuning runs stay on hardware you control. There are no per-token API charges and no cloud component to depend on, so the cost model is the Mac hardware you already own plus electricity.

It is optimized for Apple Silicon from M1 through M5, with Metal GPU kernels and Apple Neural Engine acceleration selected at runtime.

Built for Apple Silicon

PMetal uses Metal as the foundation of the training pipeline rather than an afterthought. Custom Metal Shading Language kernels handle matrix multiplication, attention and gradient computation, and the framework uses the unified memory architecture of M-series chips so there are no host-to-device copies.

Supported chip families: M1 (Pro, Max, Ultra), M2 (Pro, Max, Ultra), M3 (Pro, Max), M4 (Pro, Max) and M5 (preview).

Modular crate architecture

The framework is split into 22 focused crates so you can compose only what a project needs.

- `pmetal`: facade crate with prelude re-exports and feature flags - `pmetal-runtime` and `pmetal-metal`: the tensor runtime (MLX plus PMetal's own Metal kernels) and Apple Neural Engine programming - `pmetal-lora`, `pmetal-trainer`, `pmetal-distill`: LoRA, DoRA and QLoRA adapters; SFT, preference, GRPO and pretraining loops; knowledge distillation - `pmetal-gguf` and `pmetal-merge`: GGUF reading, writing and quantization, and model merging - `pmetal-distributed`: training and inference across several Macs - `pmetal-models`, `pmetal-data`, `pmetal-hub`, `pmetal-cache`: architectures and checkpoints, datasets and tokenizers, Hugging Face Hub access, and KV caches - `pmetal-serve` and `pmetal-mcp`: an OpenAI- and Anthropic-compatible server, and an MCP server - `pmetal-speech` and `pmetal-vocoder`: speech to text and text to speech - `pmetal-supervisor` and `pmetal-py`: the process supervisor behind the TUI, desktop app and MCP server, and Python bindings (the desktop app lives beside the crates, in `pmetal-gui`) - `pmetal-core`, `pmetal-core-derive`, `pmetal-mhc`: shared configuration and job specs, their macros, and hyper-connection layers

Licensing and deployment

PMetal is dual-licensed under MIT and Apache-2.0, so it can be used commercially and its full source can be audited.

Epistates offers custom deployment, enterprise support and domain-specific fine-tuning on top of PMetal. Use the contact page to discuss your requirements.

Writing

Read more

Putting PMetal to work?

We help teams design, build and operate production systems on this stack.