MiniCPM-o 4.5 video-only LoRA on Hugging Face Jobs: compatibility notes and workarounds
Hi, I ran a small video-only LoRA pilot with openbmb/MiniCPM-o-4_5 using LLaMA-Factory and Hugging Face Jobs.
This is not yet a minimal bug reproduction. I wanted to share the compatibility issues and workarounds I encountered, since they may help other users trying to fine-tune MiniCPM-o 4.5 for video-text SFT without audio.
Setup
- Model:
openbmb/MiniCPM-o-4_5 - Model revision:
4382fcae8a551b54d18f18462db974ff312aa7f3 - Training framework: LLaMA-Factory
- LLaMA-Factory revision:
0b7aaf8f6a624bd89a01a155d4265ec861cbdf38 - Cloud runtime: Hugging Face Jobs, A100
- Task: video-only soccer commentary generation
- Data shape: 30-second video clips, 448p, 4 fps, no audio
- LoRA target modules:
q_proj,v_proj - Vision tower frozen: yes
- Multimodal projector frozen: yes
Issues Encountered
- Video-only training still triggered audio-related initialization paths.
- LLaMA-Factory forward arguments conflicted with MiniCPM-o remote code in this setup.
- An in-place visual embedding scatter operation caused autograd compatibility issues during training.
- For inference,
transformers==4.56.2exposed aDynamicCache.seen_tokenscompatibility issue, while pinning inference totransformers==4.51.0worked in my run. - Continuing LoRA training from a previous adapter required explicitly downloading the PEFT adapter revision locally; otherwise the adapter revision and base model revision could be mixed, causing
adapter_config.jsonlookup failure.
Workarounds Used
For training, I applied a local compatibility patch that:
- gated audio embedding calls when running video-only training;
- removed duplicate forward kwargs before calling the underlying LLM;
- replaced in-place visual embedding
scatter_with an autograd-safe non-in-place path; - patched LLaMA-Factory's MiniCPM-o config path to use
init_audio=Falsefor video-only training.
For inference, I used:
transformers==4.51.0init_vision=Trueinit_audio=Falseinit_tts=Falsegenerate_audio=Falseenable_thinking=False
Result
After these workarounds, the pipeline completed successfully. I trained a small LoRA adapter on 300 video-text samples and evaluated it on 100 frozen test clips.
This issue is mainly to ask:
- Is video-only LoRA training for MiniCPM-o 4.5 officially supported through LLaMA-Factory?
- Is
init_audio=Falsethe recommended path for video-only SFT? - Would you prefer a minimal reproduction issue, a documentation note, or a PR for this compatibility path?
I am happy to prepare a minimal reproduction or documentation PR if this direction is useful.
Thanks for the great model and open-source work.
@YuzaChongyi PTAL
Thank you for documenting these workarounds. One additional detail worth watching when training video-only LoRA on openbmb/MiniCPM-o-4_5 with lora_target: q_proj,v_proj in LLaMA-Factory:
Because PEFT matches bare leaf names (q_proj, v_proj) by suffix across the entire nn.Module tree, if apm (Whisper audio encoder) or tts sub-modules are instantiated during model loading before init_audio=False / init_tts=False gates them out, PEFT injects lora_A/lora_B into apm.layers.*.self_attn.{q_proj,v_proj} and tts.model.layers.*.self_attn.{q_proj,v_proj} alongside llm.model.layers.*.self_attn.{q_proj,v_proj}. During video-only SFT:
- Any LoRA layers attached to unexecuted
apm.*ortts.*branches receive zero gradients (||B @ A||_F = 0), inflatingadapter_model.safetensors. - When loading that adapter back at inference time with
init_audio=Falseandinit_tts=False,PeftModel.from_pretrainedcan either warn on unexpectedapm/ttskeys or fail strict key checks unlesstarget_moduleswas scoped tor"^llm\.model\.layers\.\d+\.self_attn\.(q_proj|v_proj)$"(or dead branches are pruned).
If you want to verify which submodules in your trained adapter_model.safetensors actually received non-zero updates (and strip any zero-update apm/vpm/tts layers or compress over-parameterized ranks before deployment), you can run loraspectra directly on the .safetensors file:
loraspectra audit adapter_model.safetensors
loraspectra compress adapter_model.safetensors -o adapter_clean.safetensors --exclude "apm.,tts." --energy 0.99
It parses MiniCPM-o / MiniCPM-V llm.model.*, vpm.*, and apm.* prefixes natively without needing PyTorch or GPU memory and flags any DEAD_LAYER where ||Delta W||_F == 0.