Skip to content
SurogateSurogateDocs
↑↓ to move↵ to openesc to close

Fine-tuning MiniCPM5 and Spark-X2.5

This 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.

Pick an example, replace its dataset with your own (see Datasets), and run:

bash
surogate sft examples/sft/minicpm5/minicpm5-lora-bf16.yaml
# Or:
surogate sft examples/sft/spark/spark-lora-bf16.yaml

To 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:

yaml
lora_target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]

Spark uses different attention projection names:

yaml
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.

Checkpoints are saved under output_dir. To merge a saved adapter into a standalone safetensors checkpoint, use surogate merge:

bash
surogate merge \
--base-model XHToken/Spark-X2.5-1.7B \
--checkpoint-dir output/spark/step_00000100 \
--output merged-spark

For 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:

bash
surogate serve merged-spark --tool-call-parser spark25

Spark serving currently needs a merged checkpoint; you can’t load a separate adapter at serving time.

Next: Inference covers serving options and supported quantizations.