feat(rosetta): Architecture::InternLm2 variant + internlm2 family (closes #1589)#1686
Merged
Conversation
…oses #1589) InternLM2 / InternLM2.5 (Shanghai AI Lab; InternLM2ForCausalLM) is LLaMA-derivative architecturally (GQA + RoPE + SwiGLU + RMSNorm) but uses renamed tensor subtrees throughout: HF → APR canonical model.tok_embeddings.weight → model.embed_tokens.weight model.layers.N.attention.wqkv.weight → self_attn.qkv_proj.weight (fused) model.layers.N.attention.wo.weight → self_attn.o_proj.weight model.layers.N.feed_forward.w1.weight → mlp.gate_proj.weight model.layers.N.feed_forward.w2.weight → mlp.down_proj.weight (note: w2=down) model.layers.N.feed_forward.w3.weight → mlp.up_proj.weight (note: w3=up) model.layers.N.attention_norm.weight → input_layernorm.weight model.layers.N.ffn_norm.weight → post_attention_layernorm.weight output.weight → lm_head.weight Adds `Architecture::InternLm2` variant + `internlm2_map_name` (50 LOC) + YAML covering InternLM2-7B/2.5-7B and InternLM2-20B (shared 92544 vocab, RoPE θ=1000000, 8 K/V groups). `from_model_type` adds "internlm2" / "internlm2_5" / "internlm2.5" recognizers. Verified: - pv validate clean - FALSIFY-PARITY-002, FALSIFY-MF-006, FALSIFY-MF-011 pass - All 13764 aprender-core --lib tests pass Out of scope (separate tickets): - Fused wqkv splitter at conversion layer (InternLM2 packs Q/K/V interleaved per GQA group, distinct from GPT-NeoX concat layout) - is_inference_verified() returns false until splitter is wired
This was referenced May 15, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-authors PR #1674 (InternLM2 rosetta variant) on a clean cherry-pick
onto current
main— the original branch developed unresolvableinterleaving conflicts with the FalconClassic + BLOOM variants once
those landed in parallel.
Adds:
Architecture::InternLm2enum variant inconverter_types.rsinternlm2_map_namefunction mapping HuggingFacemodel.tok_embeddings/wqkv/wo/w1/w2/w3/attention_norm/ffn_norm/outputto the APR canonicalmodel.embed_tokens/self_attn.qkv_proj/o_proj/mlp.gate_proj/down_proj/up_proj/input_layernorm/post_attention_layernorm/lm_headlayoutfrom_model_type("internlm2" | "internlm2_5" | "internlm2.5")→
Some(Architecture::InternLm2)is_llm()includes InternLm2;display_name()returns "InternLM2"contracts/model-families/internlm2.yaml(123-line family contract,InternLM2-7B / 2.5-7B / 20B; shared 92544 vocab, RoPE θ=1000000,
8 K/V groups)
Out of scope (separate tickets):
interleaved per GQA group — distinct from GPT-NeoX concat layout)
is_inference_verified()returns false until splitter is wiredVerified
pv validate contracts/model-families/internlm2.yaml→ 0 errorsaprender-core --libtests passcargo checkCloses #1589. Supersedes #1674.
🤖 Generated with Claude Code