Fine-tuning MiniCPM5 and Spark-X2.5
EngineSurogate EngineThis guide gets you from a MiniCPM5 or Spark-X2.5 checkpoint to a trained LoRA adapter and a merged model you can serve. Train from the Hugging Face safetensors checkpoints. Supported checkpoints include openbmb/MiniCPM5-1B, openbmb/MiniCPM5-2B, XHToken/Spark-X2.5-1.7B, and XHToken/Spark-X2.5-4B. Model dimensions are read from config.json, so a local checkpoint directory works too. GGUF files are for serving only.
Start a LoRA run
Section titled “Start a LoRA run”Pick an example, replace its dataset with your own (see Datasets), and run:
surogate sft examples/sft/minicpm5/minicpm5-lora-bf16.yaml# Or:surogate sft examples/sft/spark/spark-lora-bf16.yamlTo train the larger checkpoint, change only the model field to openbmb/MiniCPM5-2B or XHToken/Spark-X2.5-4B, then adjust the sequence length and batch size to fit your GPU memory (Memory lists the options). Both examples use BF16 and activation recomputation.
MiniCPM5 uses these LoRA targets:
lora_target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]Spark uses different attention projection names:
lora_target_modules: [q_k_v_proj, out_proj, gate_proj, up_proj, down_proj]You can also use lora_target_modules: [all] (see LoRA Settings). For Spark, q_k_v_proj trains the query, key and value projection together. The attention gate is not a LoRA target; only full fine-tuning updates it.
For full fine-tuning, set lora: false and start with learning_rate: 1e-5. It needs more memory, for gradients and optimizer state.
Use the trained model
Section titled “Use the trained model”Checkpoints are saved under output_dir. To merge a saved adapter into a standalone safetensors checkpoint, use surogate merge:
surogate merge \ --base-model XHToken/Spark-X2.5-1.7B \ --checkpoint-dir output/spark/step_00000100 \ --output merged-sparkFor a MiniCPM5 adapter, pass the matching MiniCPM5 model and checkpoint directory instead. Spark adapters use the checkpoint’s native projection names, so PEFT can load them too.
Serve the merged Spark checkpoint with:
surogate serve merged-spark --tool-call-parser spark25Spark serving currently needs a merged checkpoint; you can’t load a separate adapter at serving time.
Next: Inference covers serving options and supported quantizations.