Repository navigation
[FlyDSL] [JIT] comm fused moe stage2 reducescatter for dsv4 dpa - #5907
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
804da03 to
d579a5f
Compare
1f1c2b0 to
82d101a
Compare
|
The reuse protection of direct RS did not prevent sorting from zeroing out; the peer read a partial data that had been zeroed out or overwritten in the next round. |
9026825 to
8b06c56
Compare
Integrate and tune the direct BF16 and Window AR/RS Stage2 communication paths for DSV4 production workloads. Improve Window producer scheduling, collective ordering, cache policy, synchronization, and graph-safe workspace lifetimes, with dynamic route scaling and native MXFP4 communication payloads for validated AR winners. Remove superseded atomic/output-shard experiments and their host/test plumbing.
8b06c56 to
8528e03
Compare
Motivation
The second MoE GEMM and its following collective form a critical serving path
for DeepSeek-V4. Executing GEMM2, all-reduce/reduce-scatter, and the
shared-expert add independently leaves avoidable launch, memory-traffic, and
synchronization overhead, while production DPA introduces ragged per-rank token
counts that fixed-layout kernels cannot represent efficiently.
This PR turns the comm-fused MoE Stage2 path into a production-ready Aiter
runtime. It provides tuned Mega, Direct, and Window collective families across
the serving token range; supports compact ragged reduce-scatter; unifies tuning
and runtime configuration; makes synchronization and backend capabilities
explicit; and preserves the existing Stage2 callback ABI for downstream users.
For the production DeepSeek-V4 shape, a clean-cache, skew-routing TP8 re-run
shows 19.88%–77.47% speedup for low-token Mega all-reduce,
41.79%–119.66% for Window all-reduce, and 24.10%–86.77% for Window
reduce-scatter. Direct reduce-scatter measured through the production-equivalent
external-reuse synchronization path improves M128, M512, and M1024 by
1.33%, 2.11%, and 6.30%, respectively. Downstream DPA serving
improves throughput by 6.39%–10.18% across concurrency 64–1024 with GSM8K
accuracy preserved.
Technical Details
Tuned Stage2 collective families
worker assignment, and drain behavior.
for validated configurations.
graph-safe workspace ownership and lifetimes.
Unified configuration and runtime selection
ordinary and comm-fused winners.
ShapeKeyand the tuner schema with collective type, shared-add, andbackend configuration metadata.
directly by the runtime.
bucket_for()helper and explicit runtime capabilities suchas
supports_ragged_mandsupports_external_reuse_sync.alias plumbing, and obsolete atomic/output-shard experiments.
Compact ragged reduce-scatter
reduce_scatter_sizesand compute each rank's reallocal_rowsandrank_offset.input compact.
can select compact or fixed-layout collection without implementation-specific
probing.
Synchronization and callback compatibility
DPA input gather can prove that every peer consumed the previous partial
buffer, allowing the production path to skip a redundant standalone wait.
that proof.
shared-expert add, and simplify the Direct reduction/add path.
before_stage2()callback and add theexplicit row-aware
before_stage2_for_rows(rows)callback. Supplying both isrejected to keep behavior unambiguous.
Commit Breakdown
9b5921ad—refactor(comm-fused-moe): load winners from tuned fmoe configs144cf44f—feat(comm-fused-moe): optimize Stage2 collective fusionf3fff4c1—feat(comm-fused-moe): support ragged reduce-scatter layoutsreduce_scatter_sizes, per-rank row/offset calculation, max-loaded-rank bucket selection, and exact local-row output. It also introduces the explicit ragged-layout capability used by downstream integrations.82d101a8—perf(comm-fused-moe): streamline direct reuse synchronization90268259—fix(comm-fused-moe): preserve Stage2 callback ABIbefore_stage2_for_rows(rows)for consumers that need the exact output size. It rejects simultaneous callback forms and guarantees that current ATOM remains compatible while the row-aware ATOM integration lands.Test Plan
Window buckets, including uneven and skewed rank distributions.
addition, compact ragged RS, fixed-layout fallback, and synchronization reuse.
production winner and focused production synchronization paths.
A/B/A/B/A/B performance and full GSM8K.
against the new Aiter runtime.
Test Result
Single-operator performance
The table below replaces the earlier CSV-derived figures with measured results
from the current branch. The common shape is
gfx950, 256 CUs, hidden size7168, local intermediate size 384, 384 experts, top-k 6, TP8. Mega and Window
were re-run with a clean Aiter/FlyDSL cache and skewed routing. Direct uses the
external-reuse synchronization contract exercised by DPA production. Each
number covers Stage2 + collective + shared-expert add; speedup is
ordinary / comm-fused - 1.M512 Direct is the average of three production-path runs. Direct numerical
error stayed at
max_abs=0.0625andrel_l2=0.0046–0.0047; Mega stayed atrel_l2=0.0134–0.0150; Window RS stayed atrel_l2=0.0264–0.0267. Window ARuses the existing FP4 aggregate validation policy (
max_abs <= 3,rel_l2 <= 0.13) and measuredrel_l2=0.1224–0.1225.Downstream DPA serving performance
DeepSeek-V4-Pro, DPA/TP8, ISL/OSL
8192/1024, random range ratio0.8,concurrency 64–1024,
concurrency x 10requests per leg, A/B/A/B/A/B:Every point completed all requested requests in all six legs. Logs confirmed
comm-fused activation on all eight ranks and Window RS selection under high
load, demonstrating that the operator gains carry through to serving.
Accuracy, correctness, and graph safety
0.9431 +/- 0.0064, strict0.9447 +/- 0.0063.0.9522 +/- 0.0059, strict0.9530 +/- 0.0058.0.94CI threshold; the comm-fused run recorded seven bucketactivations and selected the tuned M16384 Window AR path.
py_compile/compileall, and diff checks passed.Downstream compatibility validation
Current ATOM main (
8820e482) with new Aiter (90268259) completed full GSM8Kand two
8192/1024, concurrency-16 serving runs without runtime errors. Bothruns activated the comm-fused M16384 Window AR path. Against the recorded
ordinary mean, the combination delivered:
6650.58 -> 6887.73 tok/s(+3.57%).537.07 -> 489.89 ms(8.79% lower).20.73 -> 20.05 ms(3.28% lower).0.9492 +/- 0.0060/0.9500 +/- 0.0060.The callback contract was also validated directly: legacy zero-argument calls
pass, row-aware calls pass, and providing both callbacks raises the intended
error.
Compatibility and Merge Order
Merge Aiter first, then ATOM. The Aiter package declares
flydsl==0.3.4.1;the validation environment used that declared dependency.
Submission Checklist