Skip to content

pmetal train

Fine-tune a model with LoRA/QLoRA/DoRA. Supports SFT on any supported architecture with automatic hardware detection and kernel tuning.

Terminal window
pmetal train \
--model <MODEL> \
--dataset <DATASET> \
--output <OUTPUT_DIR> \
[OPTIONS]
Terminal window
# Basic LoRA fine-tuning
pmetal train \
--model Qwen/Qwen3-0.6B \
--dataset train.jsonl \
--output ./output \
--lora-r 16 --batch-size 4 --learning-rate 2e-4
# QLoRA with 4-bit quantization
pmetal train \
--model meta-llama/Llama-3.2-1B \
--dataset train.jsonl \
--output ./output \
--quantization nf4 --lora-r 16
# DoRA with custom schedule
pmetal train \
--model Qwen/Qwen3-0.6B \
--dataset train.jsonl \
--dora --lr-schedule cosine_with_restarts
# From a config file
pmetal train --config training.yaml
ParameterDefaultDescription
--modelrequiredHuggingFace model ID or local path
--datasetrequiredPath to training dataset (JSONL, Parquet, CSV)
--output./outputOutput directory for weights and logs
--lora-r16LoRA rank
--lora-alpha32.0LoRA scaling factor (2× rank)
--batch-size1Micro-batch size
--learning-rate2e-4Learning rate
--max-seq-len0Max sequence length (0 = auto-detect)
--epochs1Number of training epochs
--max-grad-norm1.0Gradient clipping
--quantizationnoneQLoRA method: nf4, fp4, int8
--gradient-accumulation-steps4Gradient accumulation steps
--no-anefalseDisable ANE training
--embedding-lrNoneSeparate LR for embeddings
--no-metal-fused-optimizerfalseDisable Metal fused optimizer
--lr-schedulecosineconstant, linear, cosine, cosine_with_restarts, polynomial, wsd
--no-gradient-checkpointingfalseDisable gradient checkpointing
--gradient-checkpointing-layers4Layers per checkpoint block
--warmup-steps100Learning rate warmup steps
--weight-decay0.01AdamW weight decay
--no-sequence-packingfalseDisable sequence packing
--dorafalseEnable DoRA (Weight-Decomposed LoRA)
--configPath to YAML configuration file

Training data is auto-detected:

  • ShareGPT: {"conversations": [{"from": "human", "value": "..."}, ...]}
  • Alpaca: {"instruction": "...", "input": "...", "output": "..."}
  • OpenAI/Messages: {"messages": [{"role": "user", "content": "..."}, ...]}
  • Reasoning: {"problem": "...", "thinking": "...", "solution": "..."}
  • Simple: {"text": "..."}
  • Parquet: Standard text columns or reasoning formats

Training produces:

  • lora_weights.safetensors — LoRA adapter weights
  • training_metrics.jsonl — Per-step metrics log
  • checkpoint/ — Resumable checkpoints (if training is interrupted)