Repository navigation
fix(models): honor Ling-2.6-flash remote-code layout and declare MLA projections (#4373) - #4429
Merged
Merged
Conversation
#4373) resolve_trust_remote_code now keeps an explicit trust_remote_code=True when a natively supported checkpoint's auto_map names a different model class (or carries the bailing_hybrid q_lora_rank MLA marker), instead of force-nativizing from model_type alone. A checkpoint whose auto_map points at the installed native class still loads natively. BailingMoeQModel declares the remote attention MLA projections (q_a_proj, kv_a_proj_with_mqa, g_proj, q_b_proj, kv_b_proj, dense) and the checkpoint-owned attention norms, while the native query_key_value/dense branch keeps resolving. Add loader-decision and state_dict-based module-plan regressions and refresh the Bailing plan fixture.
Qubitium
added a commit
that referenced
this pull request
Nov 17, 2026
#4429 split the remote Ling `attention` tree into `query_key_value/q_a/kv_a/g` (0), `q_b/kv_b` (1) and `dense` (2). A Ling 2.0 layer owns no MLA pair, so block 1 resolved to no module; the `dense` block then fell back to `last_module`, which still pointed at `input_layernorm` because the preceding block ended on an absent `g_proj`. The two norm-sourced groups merged into `input_layernorm -> [query_key_value, dense]`, rescaling `attention.dense`'s input columns with no compensation (13-14% logit change). Track whether the previous block declared only modules this layer does not own and refuse the `last_module` fallback for the next block. The group is then left unscaled, which is the pre-#4429 behavior; nothing else about the selection changes.
Qubitium
added a commit
that referenced
this pull request
Nov 17, 2026
…) (#4708) #4429 split the remote Ling `attention` tree into `query_key_value/q_a/kv_a/g` (0), `q_b/kv_b` (1) and `dense` (2). A Ling 2.0 layer owns no MLA pair, so block 1 resolved to no module; the `dense` block then fell back to `last_module`, which still pointed at `input_layernorm` because the preceding block ended on an absent `g_proj`. The two norm-sourced groups merged into `input_layernorm -> [query_key_value, dense]`, rescaling `attention.dense`'s input columns with no compensation (13-14% logit change). Track whether the previous block declared only modules this layer does not own and refuse the `last_module` fallback for the next block. The group is then left unscaled, which is the pre-#4429 behavior; nothing else about the selection changes.
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
Ling-2.6-flashis registered asmodel_type=bailing_hybrid, but its checkpoint ships a remote-codeauto_mappointing atmodeling_bailing_moe.BailingMoeForCausalLM.resolve_trust_remote_codeforce-nativized any natively supportedmodel_typeunless the caller passed an explicittrust_remote_code, so the remote layout was never used and loading crashed. Even with remote code enabled,BailingMoeQModelonly declared the Ling-2.0attention.query_key_value/attention.densebranch and would have missed the remote MLA projections (q_a_proj,kv_a_proj_with_mqa,g_proj,q_b_proj,kv_b_proj) and checkpoint-owned attention norms, so those weights would never be quantized.Fixes #4373.
What Changed
gptqmodel/utils/hf.py:resolve_trust_remote_codenow honors an explicittrust_remote_code=Truewhen a natively supported checkpoint'sauto_mapnames a different model class, or when the config carries thebailing_hybrid+q_lora_rankMLA marker. A checkpoint whoseauto_mapresolves to the installed native class still loads natively (no behavior change there).gptqmodel/models/definitions/bailing_moe.py: declare the remoteattentionMLA projections and their low-rank staging order (query_key_value/q_a/kv_a/g_proj->q_b/kv_b->dense), plus the never-quantized attention norms.layer_modules_strict=Falseresolves only the branch each layer owns, so the native linear-attention branch keeps working.tests/test_ling_remote_code_4373.py), a state_dict-based module-plan test for the remote MLA layout (tests/module_tree/test_bailing_moe_remote_mla_4373.py), and refreshed Bailing plan fixture + [BUG] BailingMoe shared experts are still ungrouped:down_projis in the same subset as gate/up (incomplete fix of #4175) #4325 shared-expert assertions.Tests
PYTHONPATH=/root/work-4373 /root/venv/bin/python -m pytest \ tests/test_ling_remote_code_4373.py tests/module_tree/test_bailing_moe_remote_mla_4373.py \ tests/module_tree/test_registered_module_plans.py \ tests/module_tree/test_bailing_moe_shared_experts_4325.py \ tests/test_trust_remote_code_isolation.py -q 436 passed /root/venv/bin/python -m ruff check gptqmodel/models/definitions/bailing_moe.py \ gptqmodel/utils/hf.py tests/test_ling_remote_code_4373.py \ tests/module_tree/test_bailing_moe_remote_mla_4373.py \ tests/module_tree/test_bailing_moe_shared_experts_4325.py tests/test_bailing_hybrid_support.py All checks passed!Real Ling-2.6-flash checkpoint instantiation was not run here (no checkpoint access in this container); the loader decision and the module plan are covered by unit tests using the checkpoint's real
auto_map/config shape and a synthetic state_dict.Model Support / Module Plan
BailingMoeQModel/gptqupdated intests/module_tree/fixtures/registered_module_plans.json; every registered case is asserted bytest_registered_module_plans.py.Logic Flow Documentation
Changes the
trust_remote_coderesolution decision (native vs remote class). The decision table is documented in the docstring and covered by the new loader-decision tests; no docs page added.Review Requirements