[diffusion] Enable lossless Cosmos3 Super T2I QK fusion on Hopper TP2 (#40486)

This commit is contained in:
Xiaoyu Zhang
2026-09-25 18:01:06 +08:00
committed by GitHub
parent a749d84303
commit 2f5c9ac43d
3 changed files with 28 additions and 10 deletions
@@ -88,12 +88,11 @@ def _can_enable_t1_fused_qk_norm_rope(
return False
if is_blackwell:
return True
return (
is_hopper
and (hidden_act != "relu2" or hidden_size == 2048)
and tp_size == 1
and sp_size == 1
)
if not is_hopper or sp_size != 1:
return False
if tp_size == 1:
return hidden_act != "relu2" or hidden_size == 2048
return tp_size == 2 and hidden_act == "silu" and hidden_size == 5120
# -----------------------------------------------------------------------------
@@ -1728,8 +1727,8 @@ class Cosmos3OmniTransformer(CachableDiT, LayerwiseOffloadableModuleMixin):
# The T=1 fused path is faster on Blackwell. It also benefits the
# single-GPU Hopper Nano (SwiGLU) and Edge (2048-wide dense) workloads,
# while the Hopper Cosmos3-Super (dense MLP) multi-GPU workload remains on the split
# path because that shape regresses with the fusion.
# as well as TP2 Super-Text2Image (SwiGLU). The older dense-MLP Super
# workload remains on the split path because that shape regresses.
enable_t1_fused_qk_norm_rope = T == 1 and _can_enable_t1_fused_qk_norm_rope(
is_blackwell=current_platform.is_blackwell(),
is_hopper=current_platform.is_hopper(),
@@ -140,6 +140,24 @@ class TestCosmos3T1FusedQKNormRoPE(unittest.TestCase):
def test_hopper_dense_mlp_disabled(self):
self.assertFalse(self._can_enable(is_hopper=True, hidden_act="relu2"))
def test_hopper_super_t2i_tp2_enabled(self):
self.assertTrue(self._can_enable(is_hopper=True, hidden_size=5120, tp_size=2))
def test_hopper_super_t2i_unsupported_topologies_disabled(self):
for overrides in (
{"hidden_act": "relu2"},
{"hidden_act": "gelu"},
{"hidden_size": 4096},
{"tp_size": 4},
{"sp_size": 2},
{"is_compiled": True},
{"is_hopper": False},
):
with self.subTest(overrides=overrides):
settings = dict(is_hopper=True, hidden_size=5120, tp_size=2)
settings.update(overrides)
self.assertFalse(self._can_enable(**settings))
def test_hopper_edge_single_gpu_enabled(self):
self.assertTrue(
self._can_enable(is_hopper=True, hidden_act="relu2", hidden_size=2048)
@@ -162,7 +180,7 @@ class TestCosmos3T1FusedQKNormRoPE(unittest.TestCase):
self._can_enable(is_hopper=True, hidden_act="relu2", hidden_size=4096)
)
def test_hopper_tensor_parallel_disabled(self):
def test_hopper_other_tensor_parallel_shapes_disabled(self):
self.assertFalse(self._can_enable(is_hopper=True, tp_size=2))
def test_hopper_sequence_parallel_disabled(self):