Repository navigation
Description
Model-compatibility sweep at main @ 8f2efe5 against transformers 5.22.1:
- Inventory of all 199 MODEL_MAP keys.
- Every native text family (93 + 4 text-only variants) run end to end on a tiny random model: GPTQ 4-bit → save → reload (TORCH) → logits vs fp16 and an RTN baseline.
75 families pass: they complete, GPTQ < RTN, and no unexpected fp linears remain. Native transformers types without a definition fail with a clear error, not a silent wrong-definition fallback.
The failures are grouped by root cause. Each fix below was checked with a local patch.
A. GPT-NeoX / Pythia: quantization succeeds, then save crashes (high)
gptqmodel/utils/structure.py:1670-1698 (infer_hf_conversion_map_reversed, called from models/base.py:1007-1022) queries get_checkpoint_conversion_mapping(model_type) only. Transformers 5.22 registers GPT-NeoX's ^embed_out. → lm_head. rename under the class name:
get_checkpoint_conversion_mapping("gpt_neox") -> None
get_checkpoint_conversion_mapping("GPTNeoXForCausalLM") -> [WeightRenaming(['^embed_out\\.'] -> ['lm_head.'])]So LazyTurtle can't find lm_head.weight, and every GPT-NeoX run ends with FileNotFoundError: Offloaded tensor 'lm_head.weight' not found (utils/model.py:2362). With the class alias it passes (rel 0.068 vs RTN 0.137).
Fix: also look up type(model).__name__ / config.architectures. NemotronH_Omni_Reasoning_V3 and MtpModel are other class-keyed mappings with the same exposure. Also update gpt_neox.py:11 lm_head = "embed_out" to "lm_head".
B. monkey_patch targets mixer internals removed in 5.22, with no guard (crash)
| family | where | failure |
|---|---|---|
| falcon_mamba | falcon_mamba.py:64-70 |
imports falcon_mamba_inner_fn, which no longer exists, so GPTQModel.load fails with ImportError for every FalconMamba model |
| zamba (v1) | zamba.py:52-75 |
replacement forward calls self.slow_forward / self.cuda_kernels_forward, which 5.22's ZambaMambaMixer doesn't have (AttributeError) |
| nemotron_h | nemotron_h.py:75 |
iterates self.model.backbone.layers and calls torch_forward / cuda_kernels_forward, so the quantized reload crashes |
Fix: apply each patch only when the legacy symbol exists, as zamba2 already does (#3768). In 5.22 the native mixers pick the eager path outside training anyway.
C. Nemotron-H tree root renamed (crash)
nemotron_h.py:16 uses "backbone", but native 5.22 renames backbone. → model. via the conversion mapping. No layers are found, giving TypeError: 'NoneType' object is not subscriptable at looper/stage_inputs_capture.py:206. With a model root plus a guarded patch: 10/10 linears, rel 0.137 vs RTN 0.173.
D. Non-persistent buffers built in __init__ stay on META under LazyTurtle (crash)
- falcon_h1:
mamba.mup_vector(persistent=False, computed from config) never reaches the checkpoint, givingLazy forward direct-state materialization left META tensors under 'mamba'(looper/module_looper.py:1354). Re-registeringcompute_mup_vector(config)inafter_model_loadfixes it (rel 0.087 vs 0.145). - falcon_mamba (after B): the same error for
mixer.dt_layernorm. 5.22'sFalconMambaWeightlessRMSNorm.weightis non-persistent for{dt,b,c}_layernorm, but_restore_falcon_mamba_rms_buffers(falcon_mamba.py:25-56) only restores the legacyb_c_rms/dt_rms. Restoring{dt,b,c}_layernorm.weighttoo fixes it (rel 0.139 vs 0.174).
E. LFM2-MoE: routed experts and attention output silently left in fp16 (silent, high)
lfm2_moe.py uses self_attn.o_proj, experts.#.w1/w3/w2 and W1W3W2MoELifecycleHooks. 5.22 (after defuser) has self_attn.out_proj and experts.N.gate_proj/up_proj/down_proj. The result is 38 of 51 linears saved in fp16, including every routed expert (most of LFM2-8B-A1B), with only a coverage WARN. With out_proj:1, experts.#: gate_proj:0, up_proj:0, down_proj:1 and GateUpDownMoELifecycleHooks: 51/51 quantized, rel 0.105 vs RTN 0.148. (Dense lfm2.py already uses out_proj.)
F. GLM-4.5/4.6/4.7 and GLM-4.7-Flash: defuser MoE block incompatible with the 5.22 router (crash)
defuser 0.0.30 modeling/unfused_moe/glm4_moe.py:91 and glm4_moe_lite.py:96 pass the router's 5.22 return tuple (logits, topk_weights, topk_indices) to route_tokens_to_experts, giving AttributeError: 'tuple' object has no attribute 'sigmoid' at the first MoE layer. Unpacking the tuple fixes both (0.093 / 0.133 and 0.128 / 0.164). The fix belongs in defuser, plus a GPTQModel-side shim or version gate. (requirements.txt asks for transformers 5.22.2; this was run on 5.22.1.)
G. mllama_text_model can't load (crash, low exposure)
mllama.py:216 sets loader = AutoModelForCausalLM, but 5.22 doesn't map MllamaTextConfig. After registering MllamaForCausalLM, _resolve_language_model (mllama.py:80) only knows the VL layouts. Fix: register the class and return model.model for the text-only layout.
H. kimi_linear is bound to the K3 definition, so native Kimi-Linear can't be quantized (crash)
auto.py:271 maps kimi_linear to KimiLinearQModel, whose quantize() always raises "requires KimiK3Source" (kimi_k3.py:31-36). Native 5.22 KimiLinearForCausalLM (Kimi-Linear-48B-A3B) has no AttnRes, and its tree is mlp.experts / self_attn. Fix: dispatch on config (AttnRes / K3 fields → K3; otherwise a native Kimi-Linear tree).
I. HRM-Text calibration ignores the recurrent H/L cycles (silent, medium)
hrm_text.py:27-41 flattens the two stacks into one chain (L0, L1, H0, H1). In the real forward the L stack runs H_cycles × L_cycles (6) times, and H0's input is z_H + final_norm(z_L). Quantize-time inputs vs the real invocations:
- L0/L1 match only the first invocation (cos 1.0, then 0.45-0.86).
- H0 matches neither (cos 0.75 / 0.54).
GPTQ comes out 0.409 vs RTN 0.385, i.e. worse. Fix: accumulate Hessians over every invocation with full-model forward hooks, or replay the cycle structure.
Also
- glmasr (
glmasr.py:20-25): the tree useslanguage_model.model.layers,lm_head="language_model.lm_head"andlanguage_model.model.rotary_emb, but the definition'sAutoModelloader buildsGlmAsrModel, whose layers are atlanguage_model.layersand which has no lm_head. Layer resolution returnsNone, so quantization crashes. GLM-ASR-Nano has no remote code. - llama4:
lm_headdefaults to"lm_head", but the module islanguage_model.lm_head. - qwen2_5_omni:
pre_lm_head_norm_module="thinker.model.norm"doesn't exist. - Unverified:
mimo_v2is registered while the native HF type ismimo_v2_flash, so Hub MiMo-V2-Flash configs may resolve to no definition. DeepSeek-V4 tiny checkpoints crash with "Tensor on device meta" in the first subset forward (root cause not isolated).
🤖 Generated with Claude Code
Activity
fix(models): handle transformers 5.22 class-keyed maps, mixer guards,…
fix(models): support Transformers 5.22 trees and calibration (#4040) (#…
Qubitium commentedon Nov 14, 2026
Resolved by #4049 (sections A-D: class-keyed conversion map for GPT-NeoX/NemotronH/MtpModel, guarded
monkey_patchfor falcon_mamba/zamba/nemotron_h, nemotron_h tree root, falcon_h1/falcon_mamba non-persistent META buffers) and #4055 (sections E-I: LFM2-MoE expert tree, GLM-4.x defuser router tuple, mllama text loader, native Kimi-Linear dispatch, HRM-Text recurrent calibration, plus the glmasr/llama4/qwen2_5_omni/mimo_v2 definition fixes). #4056 additionally raises the defuser floor to 0.0.31 for the GLM-4.x router tuple.