[AMD] [GLM-5.3-Flash Day 0] Honor fused and per-expert names in quark exclude (#39317)

Co-authored-by: Yikai Zhang <ykzhang12@gmail.com>
Co-authored-by: Thomas Wang <thomawan@amd.com>
Co-authored-by: Kevin Mi <45493463+kevin-mii@users.noreply.github.com>
Co-authored-by: Kevin Mi <mikevin920@yahoo.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Raiden Makoto
2026-09-21 21:26:42 -07:00
committed by GitHub
co-authored by Yikai Zhang Thomas Wang Kevin Mi Kevin Mi Claude Fable 5.1
parent 018b73c7a0
commit e1daf68304
2 changed files with 56 additions and 5 deletions
@@ -115,5 +115,46 @@ class TestE8M0ToF32(CustomTestCase):
self.assertTrue(torch.isnan(out[2]).item())
QKV_MAPPING = {"qkv_proj": ["q_proj", "k_proj", "v_proj"]}
class TestShouldIgnoreLayerFusedNames(CustomTestCase):
"""An `exclude` entry naming an already-fused module, or naming experts
individually, must exclude the fused module SGLang builds; otherwise an
MXFP4-packed parameter is allocated for a BF16 tensor and loading aborts."""
# ---- Bug-catchers: must FAIL on unfixed code ---------------------------
def test_directly_excluded_fused_qkv_is_ignored(self):
name = "visual.blocks.0.attn.qkv_proj"
self.assertTrue(
should_ignore_layer(name, ignore=[name], fused_mapping=QKV_MAPPING)
)
def test_per_expert_excludes_ignore_the_fused_moe_module(self):
layer = "model.layers.6.mlp.experts"
ignore = [
f"{layer}.{i}.{proj}"
for i in range(3)
for proj in ("down_proj", "gate_proj", "up_proj")
]
self.assertTrue(
should_ignore_layer(layer, ignore=ignore, fused_mapping=QKV_MAPPING)
)
# ---- Guards: behavior that must NOT change -----------------------------
def test_unrelated_moe_layer_is_not_ignored(self):
# a prefix match must not bleed into a neighboring layer index
ignore = ["model.layers.6.mlp.experts.0.down_proj"]
self.assertFalse(
should_ignore_layer(
"model.layers.7.mlp.experts",
ignore=ignore,
fused_mapping=QKV_MAPPING,
)
)
if __name__ == "__main__":
unittest.main()