[AMD] Fix Quark Shared Experts Fusion Gate after load-time-override Removal (#35200)

This commit is contained in:
Colin Z
2026-08-17 22:10:01 -07:00
committed by GitHub
parent 9401db3f29
commit ea27e3ddab
6 changed files with 70 additions and 23 deletions
@@ -86,6 +86,29 @@ class TestDeepseekV4SharedExpertFusionPolicy(CustomTestCase):
SimpleNamespace(n_shared_experts=2), None
)
def test_mixed_precision_quant_vetoes_even_when_enforced(self):
"""A precision mismatch causes crash when shared expert fusion is enabled,
so --enforce-shared-experts-fusion must not override it. Guards the gap
where the enforce early-return skipped the quant check entirely."""
self._publish(enforce=True)
mixed = SimpleNamespace(
get_name=lambda: "quark", can_fuse_shared_expert=lambda: False
)
self.assertIn(
"higher precision",
DeepseekV4ForCausalLM.shared_experts_fusion_disable_reason(
SimpleNamespace(n_shared_experts=1), mixed
),
)
matched = SimpleNamespace(
get_name=lambda: "quark", can_fuse_shared_expert=lambda: True
)
self.assertIsNone(
DeepseekV4ForCausalLM.shared_experts_fusion_disable_reason(
SimpleNamespace(n_shared_experts=1), matched
)
)
def test_dspark_entry_class_uses_the_v4_gate(self):
"""A DSV4 DSpark draft must inherit the target's default fusion policy."""
self._publish(enforce=False)
@@ -117,6 +117,25 @@ class TestDeepseekV2Gate(_FusionGateCase):
self._reason(DeepseekV2ForCausalLM, self._config(), moe_ep_size=2)
)
def test_mixed_precision_quant_vetoes_even_when_enforced(self):
"""A precision mismatch causes crash when shared expert fusion is enabled,
so --enforce-shared-experts-fusion must not override it. Guards the gap
where the enforce early-return skipped the quant check entirely."""
from sglang.srt.models.deepseek_v2 import DeepseekV2ForCausalLM
self._seed(enforce_shared_experts_fusion=True)
mixed = SimpleNamespace(
get_name=lambda: "quark", can_fuse_shared_expert=lambda: False
)
self.assertIn(
"higher precision",
self._reason(DeepseekV2ForCausalLM, self._config(), mixed),
)
matched = SimpleNamespace(
get_name=lambda: "quark", can_fuse_shared_expert=lambda: True
)
self.assertIsNone(self._reason(DeepseekV2ForCausalLM, self._config(), matched))
class TestGlmMoeLiteGate(_FusionGateCase):
def _config(self, **kw):