[Proposal] MiniCPM adapter (MiniCPMForCausalLM) — I'm working on it

オープン
#1,992 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@pablocs116 がすでに取り組んでいます。

2026年11月6日 から。

  • #1994 @pablocs116 による — オープン

評価

この issue はまだ評価されていません。

説明

Proposal

Add a TransformerBridge architecture adapter for MiniCPM (MiniCPMForCausalLM, model_type: minicpm, loaded via trust_remote_code). I'm working on this and will open a PR against dev.

Motivation

MiniCPMForCausalLM is listed in the architecture gap registry (71 models, ~928k downloads, relevancy 69.7) and isn't in the adapter factory yet. No existing issue or PR covers it.

Pitch

Scope: dense MiniCPM checkpoints only.

Validation checkpoints:

  • openbmb/MiniCPM4-0.5B (primary)
  • openbmb/MiniCPM-1B-sft-bf16 (if it fits my hardware; CPU only)

The architecture is Llama-shaped (RMSNorm, RoPE/LongRoPE, GQA, gated SiLU MLP, tied embeddings) with three µP-style scalings, which map onto existing Granite-adapter machinery:

  • scale_emb: embedding output multiplier
  • scale_depth / sqrt(num_hidden_layers): residual-branch multiplier
  • hidden_size / dim_model_base: hidden state divided before lm_head (logit scaling)

Under transformers v5 the remote code needs a few loading-time patches, handled in the adapter's prepare_loading / prepare_model the same way the Baichuan and InternLM2 adapters do:

  1. is_torch_fx_available was removed from transformers.utils.import_utils and the remote code still imports it.
  2. _tied_weights_keys is the v4 list form; v5 expects a dict.
  3. The rotary buffers (inv_freq, cos_cached, sin_cached) are non-persistent and come out of v5 loading uninitialized. The model still runs but produces garbage, so they're recomputed after load.
  4. forward raises if use_cache=True without a Cache object.

With those fixes, MiniCPM4-0.5B loads and generates correctly on transformers 5.8.1.

Out of scope:

  • MiniCPM4-8B / MiniCPM4.1-8B: sparse (InfLLM-v2) attention
  • MiniCPM3 (MiniCPM3ForCausalLM): a different class with MLA attention
  • MiniCPM-S and BitCPM variants: not validated
Alternatives

Waiting for upstream to update the remote code for v5. The patches are small and isolated, so I'd rather not block on that.

Checklist
  • I have checked that there is no similar issue in the repo (required)
主要言語
Python
スター
3.9k
フォーク
708
平均マージ
1日 4時間
マージ済み PR(30日)
87

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TransformerLensOrg/TransformerLens のほかの issue

TransformerLensOrg/TransformerLens の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。