Repository navigation
[HIP] [FlyDSL] DeepSeek-V4.1-Flash: MegaMoEV2 DSpark draft BF16 return and small-input route, EP8 / EP4 small-input bucket tables, H64 attention scalar loads - #9076
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
…aft MoE, its EP8 small-input route, EP8 / EP4 small-input bucket tables DSpark draft MoE (128 routed experts, topk 3, the shared expert computed apart): - Every route returns BF16 rows, the precision of the default MoE backend's MoRI combine. V41_FLASH_DRAFT_LAYOUTS lists the draft MoE on 1, 2, 4 and 8 ranks; BF16_RETURN_LAYOUTS is that set. The staged route's p2p_quant "auto" resolves to "none" at every capacity for them (it picked fp8_blockwise_1x32 from P2P_FP8_MIN_MTPR, i.e. at the draft instance's prefill capacity), and the FP8-only aligned-pair Stage2 gives way to the plain Stage2 of the same bucket. An explicit p2p_quant is kept. - The EP8 layout (8, 16, 5120, 2304) is a fused layout of the small-input kernel only (SMALL_M_ONLY_LAYOUTS; large_m_layout_mtpr() gives it no large-input capacity, MegaMoEV2 and LargeMRuntime skip it): calls up to 512 rows a rank take the small-input route, larger ones the staged route. Its tune is the 48-expert EP8 small-input tune with bf16_rows_always (FusedStage1Knobs, default off): every rank sends BF16 GEMM2 rows instead of the rows-received choice of FP8 or BF16 rows. The small-input kernel dispatches it into fixed slots, as the 48-expert layout. - The target-model layouts keep every config field. EP8 / EP4 V4.1-Flash small-input bucket tables (A8W4, their layouts only): - _V41_FLASH_EP8_SMALL_KNOBS: one CTA a CU at 8 and 16 tokens, en_order 7 at 16 to 256 tokens, 32 producer CTAs at 32 tokens. - _V41_FLASH_EP4_SMALL_KNOBS: 32 producer CTAs (96 at 128 tokens), SGPR head pointers and en_order 7 at 32, 64 and 128 tokens. - en_order (FusedStage1Knobs, default 0): the GEMM1 (bit 1) and GEMM2 (bit 2) units of the run of one expert's m-tiles that lies wholly in an XCD's slice go in (expert, n)-major order; bit 4 reads those units' weights through the cache. A bijection on the units: every tile computes as before. - The knobs change neither what the ranks exchange nor what a tile computes; the outputs are those of the configs without the tables, bit for bit. bf16_rows_always and en_order reach the kernel factory only when set, so the other configs keep their kernels and cache keys. AOT: the default FlyDSL MegaMoE build also covers the draft MoE instances (EP8 / EP4 / EP2, MTPR 8192, 16384 and 32768). Tests: - tests/test_mega_moe_v41_draft_layout.py: layout gate, no large-input capacity, the route for every max_tokens, the small-input configs, one launch protocol, the staged BF16 return at every capacity on every EP width, the target layouts' returns unchanged, fixed-slot dispatch. - tests/test_mega_moe_v41_small_knobs.py: the tables set only schedule knobs, change only their buckets, keep one launch protocol, leave A4W4, EP2 and V4-Pro alone; the new knobs reach the factory only when set. - tests/test_mega_moe_gfx950_route_plan.py: pinned digests of the EP8 / EP4 V4.1-Flash fused configs updated for the tables (bf16_rows_always and en_order enter the pinned table only when set). - tests/test_aot_drivers.py: the draft profiles. - op_tests/multigpu_tests/test_mega_moe_v41.py: --check draft (configs, the small-input route against the staged route and the fp32 reference on uniform and skewed routes, staged calls against the reference, an FP8-return instance told apart) and --check tables (every case with and without the tables, bit for bit), on 8 / 4 / 2 ranks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…CSR indptr / positions as scalar loads attention_64rows.cuh, bit for bit the outputs before: - The CSR indptr and positions reads are kernel-invariant and wave-uniform: load_uniform() reads them through the constant address space, so they are scalar loads (lgkmcnt) instead of vector loads that sit in the in-order vmcnt queue behind the large Q / row-index loads. - prepare_q_direct loads the RoPE coefficients of the two rotated fragments once per lane, outside the lane-divergent branch (16-byte loads when cos / sin are aligned), and selects the rotated or unrotated values per lane. Co-Authored-By: Claude Opus 5.5 <[email protected]>
55a019f to
60f9646
Compare
Conflicts with #9076 (DeepSeek-V4.1-Flash DSpark draft layouts, EP8 / EP4 small-input bucket tables), resolved by keeping both sides: - mega_moe_config.py: the EP8 hidden-7168 large_m tune next to main's bucket tables and draft tune. The EP8 small-input bucket table applies to the V4.1-Flash EP8 layout only, so Kimi-K2.6 A8W4 keeps the EP8 V4.1-Flash tune without it, as before the merge. - mega_moe_large_m.py: the LargeMRuntime layout error names both the K2.6 layout and main's small-input-only layouts. - aot/flydsl/mega_moe.py: the K2.6 jobs next to main's draft jobs. - tests: the AOT job count (main's 66 plus 3 K2.6 jobs); the K2.6 small_m check compares against the EP8 V4.1-Flash tune without its table. Kimi-K2.6 and DeepSeek-V4-Pro select the same configs as before the merge, and their AOT kernels are byte-identical (except the nondeterministic prepare kernels); against main only V4-Pro A8W4 large_m at MTPR 1024..16384 differs, as before. Co-authored-by: Cursor <[email protected]>
- Update the image from rocm/atom-dev:nightly_202611101510 (ATOM e5b74bc86) to nightly_202612031117@sha256:ef8293cd19b40344b4e755f7b0934bb961c4ee8e844758b7de84a7ce5e8cf7b9 (ATOM 10e8c1ea6, AITER ed1163f82, Mooncake 206d6340, ROCm 7.2.4) in the master config, and the AToMesh frontend container_image from sha256:160a4ec49379e7f1980a4e783254366b1d5c643b012abca57a21c0bcbbfe83a7 to the same tag and digest. - Replace plain TP2 at concurrency [1, 2, 16, 32], DTP2 (DP attention) at 64, DEP2 (DP attention plus expert parallelism) at [128, 256] and plain TP4 at [1, 2, 4, 8, 32] with plain TP8 at [1, 2, 4], plain TP4 at [4, 8, 16, 32], DEP4 at 64 and DEP8 at [128, 256, 384, 512]. Every TP2, DTP2 and DEP2 point and TP4 c1 and c2 are dropped; TP8 c1, c2 and c4, TP4 c16, DEP4 c64 and DEP8 c128 to c512 are new. - TP8 c1 runs max-num-seqs 2, decode graphs [1, 2] and ATOM_PREFILL_DECODE_INTERVAL=1000000, and TP8 c2 and c4 run ATOM_PREFILL_DECODE_INTERVAL=192, the settings TP2 and TP4 used at those concurrencies. TP4 c4 (192) and c32 (16) are unchanged; TP4 c8 moves from the MXFP8 to a BF16 KV cache (interval 192), and the new TP4 c16 also runs a BF16 KV cache with interval 96. - DEP8 runs MegaMoE (moe-backend mega) with AITER_MEGA_SHARED_IN=1, adaptive prefill admission, 4 API servers, share_cache DP routing with lockstep placement (--dp-share-cache-lockstep), online EPLB without redundant experts (load window 200, rebalance interval 800, 4 layers per chunk), decode graphs 1 to 48 plus 56, 64, 72, 80, 96 and 128, ATOM_PREFILL_DECODE_INTERVAL=0, ATOM_DP_SESSION_AFFINITY=0, ATOM_DP_LB_REQ_EQUIV=512, ATOM_FRONTEND_PREFIX_HASH=1, ATOM_DP_LM_HEAD_MODE=off, ATOM_GRAPH_SIDE_STREAMS=0, GPU_MAX_HW_QUEUES=5 and MORI_SHMEM_HEAP_SIZE=16G. - DEP8 offloads KV to CPU DRAM (kv-offloading dram) through ATOM_KV_OFFLOAD=mooncake_store: a Mooncake master and two NUMA-bound 256 GiB Mooncake Store owners on rdma0-7 of the inference node, 1024 MiB load and 256 MiB save pools, OFFLOAD_MIN_LOAD_TOKENS and OFFLOAD_MIN_SAVE_TOKENS 512, OFFLOAD_MAX_PENDING_SAVES 8, one QP per endpoint, destination-device affinity, the memlock soft limit raised to the hard limit before the worker starts and a 3600 s health-check window. - DEP4 c64 runs the DEP8 settings on 4 GPUs with 2 API servers and two 128 GiB Store owners. The DP points no longer use least_tokens routing, session affinity or the X-Dynamo-Session-Id header from AIPerf. - Framework changes in the new ATOM that matter here: share_cache lockstep DP placement (ROCm/ATOM#3837, opt-in since #4074), adaptive prefill admission (#3647), the target shared expert handed to the MegaMoE routed call through AITER shared_in (#3894) with its MXFP8 input taken from the FFN seam (#3940), one-launch MegaMoE decode routing including the 48-expert layout (#3938) and route selection (#3187), EPLB on the pre-decoder layers and empty-window skip (#3186, #3952), the DSpark draft tail and DP-sharded draft argmax (#4104, #3939), ATOM_DP_LM_HEAD_MODE and the idle-rank LM head (#3353, #4025), and event-driven Store loads with a failed-save retry cap (#3772, #3781); AITER ed1163f82 (ROCm/aiter#9076) returns BF16 from the DSpark draft MegaMoE. - Draft data type unchanged: the DSpark draft (mtp.0-2 in the target checkpoint) runs as shipped at both images, with FP8 E4M3 32x32 UE8M0 block-scaled attention, shared-expert and main_proj weights run as MXFP8, MXFP4 routed experts with MXFP8 activations (a8w4, through MegaMoE at DEP4 and DEP8), and BF16 gate, norms and the shared LM head. The draft attends in BF16 over the target's KV pool, which is MXFP8 except at TP4 c8 and c16 (BF16). - 镜像从 rocm/atom-dev:nightly_202611101510(ATOM e5b74bc86)更新为 nightly_202612031117@sha256:ef8293cd19b40344b4e755f7b0934bb961c4ee8e844758b7de84a7ce5e8cf7b9(ATOM 10e8c1ea6、AITER ed1163f82、Mooncake 206d6340、ROCm 7.2.4),用于 master 配置;AToMesh 前端 container_image 从 sha256:160a4ec49379e7f1980a4e783254366b1d5c643b012abca57a21c0bcbbfe83a7 改为同一标签和 digest。 - 用 TP8 [1, 2, 4]、TP4 [4, 8, 16, 32]、DEP4 64 和 DEP8 [128, 256, 384, 512] 替换 TP2 [1, 2, 16, 32]、DTP2(DP attention)64、DEP2(DP attention 加专家并行)[128, 256] 和 TP4 [1, 2, 4, 8, 32]。所有 TP2、DTP2、DEP2 点以及 TP4 c1、c2 被移除;TP8 c1、c2、c4,TP4 c16,DEP4 c64 和 DEP8 c128 到 c512 为新增。 - TP8 c1 使用 max-num-seqs 2、decode 图 [1, 2] 和 ATOM_PREFILL_DECODE_INTERVAL=1000000,TP8 c2、c4 使用 ATOM_PREFILL_DECODE_INTERVAL=192,即 TP2 和 TP4 在这些并发下原来的设置。TP4 c4(192)和 c32(16)不变;TP4 c8 的 KV cache 从 MXFP8 改为 BF16(interval 192),新增的 TP4 c16 同样使用 BF16 KV cache,interval 96。 - DEP8 使用 MegaMoE(moe-backend mega)并设置 AITER_MEGA_SHARED_IN=1,自适应 prefill 准入,4 个 API server,带 lockstep 放置的 share_cache DP 路由(--dp-share-cache-lockstep),无冗余专家的在线 EPLB(load window 200、rebalance interval 800、每块 4 层),decode 图 1 到 48 加 56、64、72、80、96、128,ATOM_PREFILL_DECODE_INTERVAL=0、ATOM_DP_SESSION_AFFINITY=0、ATOM_DP_LB_REQ_EQUIV=512、ATOM_FRONTEND_PREFIX_HASH=1、ATOM_DP_LM_HEAD_MODE=off、ATOM_GRAPH_SIDE_STREAMS=0、GPU_MAX_HW_QUEUES=5 和 MORI_SHMEM_HEAP_SIZE=16G。 - DEP8 通过 ATOM_KV_OFFLOAD=mooncake_store 将 KV 卸载到 CPU DRAM(kv-offloading dram):推理节点上一个 Mooncake master 和两个绑定 NUMA 的 256 GiB Mooncake Store owner(rdma0-7),1024 MiB 加载池和 256 MiB 保存池,OFFLOAD_MIN_LOAD_TOKENS 和 OFFLOAD_MIN_SAVE_TOKENS 为 512,OFFLOAD_MAX_PENDING_SAVES 为 8,每个端点一个 QP,目标设备亲和,worker 启动前把 memlock 软限制提升到硬限制,健康检查窗口 3600 秒。 - DEP4 c64 在 4 张 GPU 上使用 DEP8 的设置,2 个 API server 和两个 128 GiB Store owner。DP 点不再使用 least_tokens 路由、会话亲和性或 AIPerf 的 X-Dynamo-Session-Id 头。 - 新 ATOM 中与本模型相关的框架变化:share_cache lockstep DP 放置(ROCm/ATOM#3837,自 #4074 起需显式开启)、自适应 prefill 准入(#3647)、目标层共享专家经 AITER shared_in 交给 MegaMoE 路由调用(#3894),其 MXFP8 输入取自 FFN 接缝(#3940)、单次启动的 MegaMoE decode 路由(含 48 专家布局,#3938)和路由选择(#3187)、decoder 之前层的 EPLB 和空窗口跳过(#3186、#3952)、DSpark draft 尾部与 DP 分片 draft argmax(#4104、#3939)、ATOM_DP_LM_HEAD_MODE 与空闲 rank 的 LM head(#3353、#4025)、事件驱动的 Store 加载和失败保存重试上限(#3772、#3781);AITER ed1163f82(ROCm/aiter#9076)使 DSpark draft MegaMoE 返回 BF16。 - Draft 数据类型不变:DSpark draft(目标 checkpoint 中的 mtp.0-2)在新旧镜像上都按发布精度运行,FP8 E4M3 32x32 UE8M0 块缩放的 attention、共享专家和 main_proj 权重以 MXFP8 运行,MXFP4 路由专家配 MXFP8 激活(a8w4,DEP4 和 DEP8 经 MegaMoE),BF16 的 gate、norm 和共享 LM head。draft 在目标的 KV 池上以 BF16 做 attention,该 KV 池除 TP4 c8 和 c16(BF16)外均为 MXFP8。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Rs (#9202) * [CI] Skip torchrun CLI test in Multi-GPU suite; auto-label multigpu PRs test_mega_moe_v41.py (#9076) requires --check {draft,tables} and is meant to be run via torchrun, so the bare python3 invocation in aiter_test.sh fails with argparse exit 2. Skip it in the bulk Multi-GPU run, like test_mori_smoke.py. Add actions/labeler to auto-apply ci:multi-gpu when a PR touches op_tests/multigpu_tests/**, so the Multi-GPU lane runs on such PRs instead of leaking failures to main. Co-Authored-By: Claude Code <[email protected]> * [CI] Fix labeler workflow: contents:read, fork guard, no label sync - permissions: add contents: read — the job has no checkout step, so actions/labeler fetches .github/labeler.yml via the contents API, and a permissions block that names any scope sets unlisted scopes to none; without it every run 403s and no label is ever applied - gate the job on non-fork PRs — fork PRs get a read-only GITHUB_TOKEN on pull_request events, so the add-label call would 403 with a red X - sync-labels: false — sync would strip a manually-added ci:multi-gpu on PRs not touching op_tests/multigpu_tests/**, killing the in-flight multi-GPU run (aiter-test.yaml re-checks the label after the build) - add trailing newlines to both new files, matching repo convention Co-Authored-By: Claude Code <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Code <[email protected]>
Summary
DeepSeek-V4.1-Flash on gfx950, three parts:
V41_FLASH_DRAFT_LAYOUTSon 1 / 2 / 4 / 8 ranks (=BF16_RETURN_LAYOUTS). Onmainits staged route'sp2p_quant="auto"pickedfp8_blockwise_1x32fromP2P_FP8_MIN_MTPRon, so the draft instance (prefill capacity) returned FP8 rows; the default MoE backend's MoRI combine returns BF16. For these layouts "auto" now resolves to"none"at every capacity (the FP8-only aligned-pair Stage2 gives way to the plain Stage2 of the same bucket); an explicitp2p_quantis kept.FUSED_LAYOUTSas a small-input-only layout (SMALL_M_ONLY_LAYOUTS,large_m_layout_mtpr();MegaMoEV2andLargeMRuntimegive it no large-input kernel): up to 512 rows a rank it takes the small-input kernel, above that the staged route. Its tune is the 48-expert EP8 tune withbf16_rows_always(newFusedStage1Knobsfield, default off): every rank sends BF16 GEMM2 rows. Fixed-slot dispatch as the 48-expert layout.en_order7 at 16..256 tokens, 32 producer CTAs at 32 tokens.en_order7 at 32, 64, 128 tokens.en_order(newFusedStage1Knobsfield, default 0): GEMM1 (bit 1) / GEMM2 (bit 2) units of the run of one expert's m-tiles that lies wholly in an XCD's slice go in (expert, n)-major order; bit 4 reads those units' weights through the cache. A bijection on the units: every tile computes the same.bf16_rows_always/en_orderreach the kernel factory only when set, so every other config keeps its kernel and AOT cache key. Other layouts (EP2, V4-Pro, A4W4, …) are unchanged.fused_norm_rope_attn_rope_castH64 (attention_64rows.cuh): CSR indptr / positions read through the constant address space (scalar loads, off the vmcnt queue);prepare_q_directloads the RoPE coefficients of the rotated fragments outside the lane-divergent branch. Bit for bit the same outputs.No new environment variables.
Validation
All on gfx950 (MI355X), FlyDSL 0.5.3.
Bit-exactness
forward()of the V4.1-Flash target layouts, this branch (tables on) vsmain, every route (staged / small-input / large-input, uneven and idle ranks, 2 layers): EP8 288/288 and EP4 144/144 rank outputs identical.op_tests/multigpu_tests/test_mega_moe_v41.py --check tables: every case (uniform, hot-expert, Zipf routes at each table bucket) with and without the tables, bit for bit: EP8 38/38, EP4 20/20 PASS.main.Draft BF16 return (
test_mega_moe_v41.py --check draft, MTPR 16384)p2p_quant"none", no aligned pair, small-inputbf16_rows_alwayson every bucket, no large-input kernel); small-input route vs staged route relL2 = 0.000000 on 12 uniform / skewed cases (including hot routes whose rank would pick FP8 rows by the rows it receives); relL2 vs the fp32 reference 0.052; staged calls 1..4096 rows 0.052 vs reference, 0.0267 away from an instance built with the FP8 return (FP8 return: 0.058 vs reference). 21/21 PASS.AOT: after the FlyDSL MegaMoE replay of the draft (EP8 / EP4 / EP2, MTPR 16384) and target (EP8 / EP4, MTPR 8192 and 128) profiles, production instances launched at every small-input bucket and staged / large sizes with
AITER_FLYDSL_AOT_RUNTIME_BUILD=0: 0 misses on all 7 profiles (an empty cache directory gives 40 on the same run).Routes suite (
test_mega_moe_v2.py --suite routes --network v41_flash --check-time-acc): EP8 and EP4 ALL PASS.CPU tests (GPU hidden):
tests/test_mega_moe_v41_draft_layout.py,tests/test_mega_moe_v41_small_knobs.py,tests/test_mega_moe_gfx950_route_plan.py,tests/test_aot_drivers.py,tests/test_flydsl_aot_cache.py,tests/test_flydsl_aot_launch.py: 357 passed, 1 skipped. The EP8 / EP4 V4.1-Flash pinned config digests are updated for the tables;bf16_rows_always/en_orderenter the pinned tables only when set, so the other digests are unchanged.With aiter#8878 (open,
shared_in): this branch and #8878 merge without conflicts in either order; on the merged tree the routes suite withshared_inpasses on EP8 (fused 59/59, 0 bad elements) and EP4 (30/30), and the tables / draft checks pass.Performance (microbenchmark)
MegaMoEV2 small-input route, µs per layer call, CUDA-graph replays, 4 layers × 4 rotated weight copies, the tune without the table interleaved in the same process (2 + 2 rounds each), max over ranks; outputs bit-identical. "decode" = routes recorded from a DeepSeek-V4.1-Flash DEP8 decode step (EPLB placement), uniform / Zipf 1.2 / hot-expert are synthetic.
EP8 (8 ranks, 48 experts a rank):
(At 120 / 240 rows the decode routes repeat the recorded step's rows.) Bucket 512 keeps the current tune: no candidate was ahead on all four route kinds.
EP4 (4 ranks, 96 experts a rank):
EP8 draft MoE: the small-input route replaces the staged route up to 512 rows a rank (same BF16 outputs).
Attention (
fused_norm_rope_attn_rope_cast, H64, µs per call,main→ this branch): 31.26 → 31.12, 27.76 → 27.59, 32.25 → 32.07, 25.01 → 24.83, 23.77 → 23.43 (5 decode shapes).🤖 Generated with Claude Code