transformer_lens.model_bridge.supported_architectures.minicpm3 module

MiniCPM3 architecture adapter.

OpenBMB’s MiniCPM3 (MiniCPM3ForCausalLM, native in transformers), e.g. openbmb/MiniCPM3-4B: DeepSeek-V2’s Multi-head Latent Attention (q LoRA + compressed KV with decoupled rope) with every layer a dense gated MLP, plus MiniCPM’s muP scalings. Two things differ from the DeepSeek MLA family:

  • RoPE is the half-split cos/sin variant. The HF rotary module returns a (cos, sin) tuple and the config has no rope_interleave, so MLAAttentionBridge already takes the half-split path.

  • Each sublayer output is multiplied by scale_depth / sqrt(num_hidden_layers) before the residual add, so blocks are scaled-residual MLA blocks.

class transformer_lens.model_bridge.supported_architectures.minicpm3.MiniCPM3ArchitectureAdapter(cfg: Any)

Bases: DeepSeekMLAFamilyArchitectureAdapter

Architecture adapter for MiniCPM3ForCausalLM models.

The three muP scalings are all applied by the HF forward:

  • embeddings are multiplied by scale_emb inside MiniCPM3ScaledWordEmbedding, so hook_embed already sees the product (no output_contribution_scale);

  • each sublayer output is multiplied by scale_depth / sqrt(num_hidden_layers) (hook_attn_out / hook_mlp_out expose the product);

  • the final hidden state is divided by hidden_size / dim_model_base before lm_head (reproduced by output_logits_scale).

component_mapping: ComponentMapping | None
output_logits_scale() → float

Match MiniCPM3’s lm_head(h / (hidden_size / dim_model_base)).

lm_head is bias-free, so dividing its output equals dividing its input.

prepend_bos: bool | None = True
uses_split_attention: bool
weight_processing_conversions: Dict[str, ParamProcessingConversion | str] | None