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

Đang mở
#1,992 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@pablocs116 đang làm issue này rồi.

Từ ngày 6/11/2026.

  • #1994 của @pablocs116 — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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)
Ngôn ngữ chính
Python
Star
3.9k
Fork
708
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
87

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TransformerLensOrg/TransformerLens

Tất cả issue của TransformerLensOrg/TransformerLens

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.