Repository navigation
Perf/epv2 combine push fp4 - #719
Merged
Merged
Conversation
Each rank quantizes its post-expert rows to MXFP4 (e2m1, one e8m0 scale per 32 elements, aiter's RoundUp scale rule) and TDM-stores them into the owners' landing slots; each owner reduces what landed for its own tokens. Rows are spread so every SIMD holds ceil(total / SIMDs) of them at any token count. Selected by combine_mode=scatter on the hip backend. The MORI_PUSH_* knobs are compile-time; a build that sets none of them gets the shipped configuration (MORI_PUSH_DEFAULTS), and -DMORI_PUSH_DEFAULTS=0 restores the all-off baseline for measurement builds. The gather (pull) path is unchanged: EpArgs keeps its layout (the push plan takes its own EpPushArgs), and the dispatch and gather-combine kernels disassemble identically to main's. bench_ep.py: COMB_MODE=push, with an exact check of the quantized wire against the scale rule the kernel was built with.
The quantized-reduce check's reference and bound, run as torch ops on the device, came out wrong for whole 32-element groups now and then (a reference no e2m1 code makes, NaN for a finite input, a bound exceeded by an output equal to the reference bit for bit), each time on rows where the kernel's output matched a host recomputation exactly. The check now runs on the host, a chunk of tokens at a time; PUSH_QCHECK_DEV=1 also runs it on the device and prints how far its counts are from the host's. The bound now counts a NaN as out of bounds, and the first inexact element of every rank is printed, by rank 0 alone.
Only lines 59c9cd9 and 10467c5 added are touched: C++ token streams (cpp -fpreprocessed) and Python ASTs are unchanged. Co-authored-by: Cursor <[email protected]>
The shipped values are the only path now; the alternatives and timing probes the knobs selected are removed. gather and dispatch compile to the same code as main. Co-authored-by: Cursor <[email protected]>
The host WAVE can read 64 where the gfx1250 kernel runs 32 wide; hidden 7168 was rejected as not a multiple of 2048. Co-authored-by: Cursor <[email protected]>
One combine kernel with v1's stage order: stage the input, synchronize across devices, reduce. quant_type='fp4_blockwise' sets EpCfg.combineFp4, which turns UseP2PRead off. Stage 1 quantizes each received row to MXFP4 and TDM-stores it into the owner's landing row. Stage 2 keeps the push path's own report/release signalling (every block reports to every peer, the last block of each rank releases the others): the shared EpCrossDeviceBarrier1250x measured 2.4 us slower at 512 tokens and 14 us at 16384. Stage 3 reduces the landed rows. EpArgs is unchanged: the landing rows and the signal words sit in out_tok behind its maxRecv staging rows. This drops the separate push-send kernel, EpPushArgs, the ep_combine_push plan and the profiler hooks.
The fp4 combine's stage 2 is now EpCrossDeviceBarrier1250x, the same barrier the gather uses, and the push path's own report/release signalling is gone. For worldSize up to the wave size the barrier no longer has block 0 poll the arrival count and fan the release out: the last block to arrive signals the peers, and every block waits on the peers' signals itself. The fp4 path takes release-only fences, since its rows are system-scope TDM stores and stage 3 invalidates before reading them; the gather keeps its fences. The wide-EP path is unchanged.
…_blockwise stays MXFP4 quant_type='fp4_blockwise' is still the MXFP4 combine (E2M1, an e8m0 scale per 32 elements) and the default fp4 one. quant_type='fp4_blockwise_fp32' selects v1's format instead: E2M1 with an fp32 scale (amax / 6) per 128 elements, the same wire bytes a row. It sets combineFp4F32Scale in EpRequest and EpCfg, off by default, so every other Cfg renders as before. Its send divides the scale and the inverse once a block a row rather than in every lane of every load. Both fp4 combines now build every combine variant their schedule can select, take their own tuned geometry (gfx1250, EP4, hidden 7168, topk 6), and copy a caller's input into out_tok, since the kernel may load rows below max_recv before it has read total_recv. The comments the branch added are dropped. Co-authored-by: Cursor <[email protected]>
zhangfei829
added a commit
that referenced
this pull request
Oct 1, 2026
#719 made the op copy the fp4 combine input into out_tok first (up to 65536 x 7168 bf16 a layer), because the first row load of each warp in the send stage is speculative and could read past a caller buffer shorter than the receive capacity. PUSH never exposes that buffer to peers, so the copy is not needed: a warp whose first row is at or past totalRecvTokenNum now returns before loading, and the input goes straight to the kernel. Gather and dispatch machine code is unchanged.
zhangfei829
added a commit
that referenced
this pull request
Oct 1, 2026
…rrier #719 made the gather and fp4 combines share one cross-device barrier in which every block polls the peers' signals. On hosts whose local VRAM is mapped MTYPE_NC (f01) that made the gather combine 10-17 us slower than before #719. The gather combine gets #719's parent's barrier back word for word; the fp4 combine keeps #719's barrier, so its machine code is unchanged.
zhangfei829
added a commit
that referenced
this pull request
Oct 1, 2026
fix(ep/v2): fp4 push combine reads the input in place; restore the pre-#719 gather barrier fp4 push combine no longer copies the expert output into out_tok (the first row load is bounded by totalRecvTokenNum). Gather combine gets its pre-Perf/epv2 combine push fp4 #719 cross-device barrier back (PULL ct=512: 52.4 -> 34.9 us); fp4 keeps Perf/epv2 combine push fp4 #719's barrier.
QizhouZhang97
pushed a commit
that referenced
this pull request
Oct 9, 2026
…al (#727) FieldCount.MatchesEpCfg pinned 12. #719 grew EpCfg to 14 (combineFp4, combineFp4F32Scale) and #723 to 15 (selfFirst), and both updated only the header's own assert. CCO CI stops at this test on every run since #723 (#719's run had already stopped at an earlier step), so the ops-v2 EP8 steps have not run on main since 8bffec7. Count the VisitFields walk instead. That is the invariant the test is there for, and unlike the header's MORI_JIT_ASSERT_FIELD_COUNT it also catches a field left out of VisitFields. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
perf(ep/v2): gfx1250 FP4 push combine
quant_type="fp4_blockwise_fp32": v1's format (E2M1 + fp32 scale per 128). Same wire bytes.
ct=16384 -245 us. bf16 gather combine 0.8-1.5 us faster up to ct=1024; dispatch unchanged.