Skip to content

[BUG] Regression from #4373 fix: explicit trust_remote_code=True now loads remote code for natively supported Phi-3.5-MoE / Phi-tiny-MoE / MPT / MiniMax-M2, because the class-name comparison is case/naming sensitive #4453

Closed

Description

@Qubitium

Severity: medium. Kind: regression from d01e8fd (#4373). Confirmed at 489aed6.

gptqmodel/utils/hf.py _checkpoint_remote_layout_overrides_native treats the remote layout as overriding the native one whenever remote_class_name != native_model_cls_name. Remote class names often differ from the transformers native class only in spelling, e.g. PhiMoEForCausalLM vs PhimoeForCausalLM.

A/B of the decision over all 149 local checkpoints that have an auto_map found 6 that flipped from native (def6e61) to remote (HEAD):

  • Ling-2.6-flash (intended)
  • Phi-3.5-MoE-instruct
  • Phi-tiny-MoE-instruct
  • mpt-7b-instruct
  • MiniMax-M2-bf16
  • MiniMax-M2-GPTQMODEL-W4A16
GPTQModel.load("microsoft/Phi-tiny-MoE-instruct", quantize_config=QuantizeConfig(bits=4), trust_remote_code=True)
# HEAD:     ImportError: ... requires ... einops, flash_attn   (remote modeling file)
# def6e61:  loads natively as PhimoeForCausalLM

Even when the remote code imports cleanly, the remote module tree may not match the GPTQModel definition, which was written for the native tree.

Expected: prefer remote code only on a real layout mismatch (like the Ling MLA marker), not on any difference in class name.


Found during an AI-assisted review (Claude Code, round 13) of 489aed6; repros were run at that commit (A/B against def6e61 where noted) on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Activity

  1. added
    bug
    on Nov 16, 2026
  2. Qubitium commented on Nov 16, 2026

    @Qubitium
    CollaboratorAuthor

    An independent reviewer confirmed this at 489aed6. More detail:

    Remote class (auto_map) Native class HEAD load result
    PhiMoEForCausalLM PhimoeForCausalLM ImportError: This modeling file requires ... flash_attn (def6e61: loads native)
    MPTForCausalLM MptForCausalLM ImportError: cannot import name 'LlamaDynamicNTKScalingRotaryEmbedding'
    MiniMaxM2ForCausalLM MiniMaxForCausalLM (local MiniMax-M2-bf16, model_type minimax) TypeError: 'NoneType' object is not subscriptable in remote LlamaRotaryEmbedding(rope_config) (def6e61: loads native)
    • The repo's own test now fails. tests/models/test_minimax_m2.py sets TRUST_REMOTE_CODE=True, so it fails at load.
    • Users following the model card hit it. Phi-3.5-MoE's model card tells users to pass trust_remote_code=True.
    • Possible fix. A case-insensitive class-name comparison would avoid the Phi/MPT cases. Relying only on real layout markers (e.g. q_lora_rank) would avoid all of them. Note that MiniMax-M2 vs MiniMax differ by more than case.

    (AI-assisted review, round 13 at 489aed6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions