Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion aiter/configs/model_configs/dsr1_tuned_grouped_fmoe.csv
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ gfx1250,256,1024,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4
gfx1250,256,2048,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,128,256,256,128,256,256,1,4,1,4,2,2,1,1,0,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,,0,0
gfx1250,256,4096,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,128,256,256,128,256,256,1,4,1,4,3,3,1,1,0,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,149.8,0,0
gfx1250,256,4096,7168,2048,64,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,128,256,256,128,256,256,1,4,1,4,3,3,1,1,0,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,149.8,0,0
gfx1250,256,32768,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,128,256,256,128,256,256,1,4,1,4,2,2,1,1,0,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,,0,0
gfx1250,256,32768,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,256,256,256,256,256,256,2,2,2,2,4,4,1,1,0,-1,4,-1,4,2,1,1,0,1,0,0,0,1,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,1359.51,0,0
gfx1250,256,8,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,16,256,256,16,512,128,1,4,1,4,3,3,1,1,1,-1,-1,-1,-1,-1,-1,1,1,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,0,0,0
gfx1250,256,32,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,16,256,256,16,512,128,1,4,1,4,3,3,1,1,1,-1,-1,-1,-1,-1,-1,1,1,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,0,0,0
gfx1250,256,64,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,16,256,256,16,512,128,1,4,1,4,3,3,1,1,1,-1,-1,-1,-1,-1,-1,1,1,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,0,0,0
gfx1250,256,128,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,16,256,256,16,512,128,1,4,1,4,3,3,1,1,1,-1,-1,-1,-1,-1,-1,1,1,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,0,0,0
gfx1250,256,256,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,16,256,256,16,512,128,1,4,1,4,3,3,1,1,1,-1,-1,-1,-1,-1,-1,1,1,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,0,0,0
gfx1250,256,512,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,16,256,256,16,512,128,1,4,1,4,3,3,1,1,1,-1,-1,-1,-1,-1,-1,1,1,0,0,0,0,0,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,0,0,0
gfx1250,256,8192,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,256,256,256,256,256,256,2,2,2,2,4,4,1,1,0,1,4,1,4,1,1,1,1,1,1,0,512,1,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,233.57,,
gfx1250,256,16384,7168,2048,65,-1,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,1,QuantType.per_1x32,1,0,256,256,256,256,256,256,2,2,2,2,4,4,1,1,0,2,2,1,4,2,2,1,0,1,0,0,0,1,grouped_gemm1_fp4_gugu,grouped_gemm2_fp4,0,0,0
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def _build(owner: str, group, rank: int):
ca.world_size = WORLD
ca.device = torch.device("cpu")
ca._fly_rms = None
ca._is_gfx1250 = False # This CPU stand-in has no gfx1250 DCP inbox.
ca._init_fly_rms()
return ca._fly_rms is not None

Expand Down
60 changes: 30 additions & 30 deletions op_tests/tuning_tests/test_grouped_ep_fused_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
_IMPORT_ERR = e

try:
from aiter.ops.flydsl.kernels.mega_moe_gfx1250.mega_moe import (
from aiter.ops.flydsl.kernels.mega_moe_gfx1250.stages.dispatch_compact import (
_compact_gemm_align_m,
)
except Exception: # noqa: BLE001
Expand Down Expand Up @@ -69,18 +69,24 @@ def setUpClass(cls):

def test_ep_fused_rows_selected(self):
cases = [
(1024, 65, "2", "2"),
(2048, 65, "2", "2"),
(4096, 65, "3", "3"),
(4096, 64, "3", "3"),
(32768, 65, "2", "2"),
*(
(token, 65, "16", "16", "3", "3")
for token in (8, 32, 64, 128, 256, 512)
),
(1024, 65, "128", "128", "2", "2"),
(2048, 65, "128", "128", "2", "2"),
(4096, 65, "128", "128", "3", "3"),
(4096, 64, "128", "128", "3", "3"),
(8192, 65, "256", "256", "4", "4"),
(16384, 65, "256", "256", "4", "4"),
(32768, 65, "256", "256", "4", "4"),
]
for token, experts, buffers, buffers2 in cases:
for token, experts, tile_m, tile_m2, buffers, buffers2 in cases:
with self.subTest(token=token, experts=experts):
row = _row(token, experts, True)
self.assertIsNotNone(row)
self.assertEqual(str(row.get("tile_m")), "128")
self.assertEqual(str(row.get("tile_m2")), "128")
self.assertEqual(str(row.get("tile_m")), tile_m)
self.assertEqual(str(row.get("tile_m2")), tile_m2)
self.assertEqual(str(row.get("num_buffers")), buffers)
self.assertEqual(str(row.get("num_buffer_stage2")), buffers2)
# The merged CSV stores the flag as "1.0"; lookup normalizes it.
Expand All @@ -96,36 +102,30 @@ def test_plain_lookup_keeps_generic_rows(self):
self.assertNotEqual(str(row.get("tile_m")), "128")
self.assertNotIn(str(row.get("ep_fused")), ("1", "1.0"))

def test_token_512_stays_default(self):
self.assertIsNone(_row(512, 65, True))

def test_compact_plan_uses_ep_fused_tile(self):
if _compact_gemm_align_m is None:
self.skipTest("compact align import failed")
os.environ.pop("AITER_TDM_TILE_M", None)
os.environ.pop("AITER_TDM_TILE_M2", None)
config = SimpleNamespace(
dispatch_wire="fp4",
max_recv=32768,
hidden_dim=7168,
experts_per_rank=65,
geometry=SimpleNamespace(inter_dim=2048),
recipe=SimpleNamespace(
compute=SimpleNamespace(
activation=ActivationType.Silu,
quant_type=QuantType.per_1x32,
)
),
)
align = _compact_gemm_align_m(
config,
activation=ActivationType.Silu,
quant_type=QuantType.per_1x32,
inter_dim=2048,
recv_bound=32768,
)
self.assertEqual(align, 128)
align_512 = _compact_gemm_align_m(
config,
activation=ActivationType.Silu,
quant_type=QuantType.per_1x32,
inter_dim=2048,
recv_bound=512,
)
self.assertEqual(align_512, 64)
with mock.patch.dict(os.environ):
os.environ.pop("AITER_TDM_TILE_M", None)
os.environ.pop("AITER_TDM_TILE_M2", None)
for token, expected in ((32768, 256), (512, 16)):
with self.subTest(token=token):
self.assertEqual(
_compact_gemm_align_m(config, recv_bound=token), expected
)


class GroupedNonEpTokenFallbackTest(unittest.TestCase):
Expand Down
Loading