Repository navigation
helios: add 1-hop closed-ring RoCE prefill proxy opcodes - #649
Open
FujitsuPolycom wants to merge 1 commit into
Open
FujitsuPolycom wants to merge 1 commit into
FujitsuPolycom wants to merge 1 commit into
Conversation
On switchless closed RoCE rings of three or more ranks (such as four-node
DGX Spark GB10 rings), large prefill reduce-scatter and shard-gather
collectives previously used the two-shot pipelined proxy path (op kinds 3
and 4). That path routes non-neighbor transfers through multi-hop CPU
mailboxes, adding host copies and saturating relay links. Adding
bidirectional 1-hop ring proxy opcodes lets each rank stream half of every
payload clockwise and half counter-clockwise directly to its adjacent ring
neighbors across all rails and queue-pair lanes without CPU mailbox relays
or region layout changes.
What changed in helios/native/roce_proxy.c:
- Defined 1-hop closed-ring prefill opcodes KIND_RING_RS (7),
KIND_RING_AG (8), and KIND_RING_RSAG (9) below KIND_RING2_STEP1 (5) and
KIND_RING2_STEP2 (6).
- Extended credit_phases() so cross-family transitions between two-shot
pipe ops (1, 3, 4) and 1-hop ring ops (7, 8, 9), as well as hazardous
same-family transitions (RS -> RS/RSAG and AG/RSAG -> AG), exchange
start-of-op credits before overwriting shared pipe_recv slots.
- Added ring_dir_shard_bounds(), ring_ag_arrived(), and run_ring_bidir_op()
plus proxy_main() dispatch for op kinds 7, 8, and 9. Before: closed-ring
prefill reduce-scatter and shard-gather ops had no direct-neighbor ring
proxy path and proxy_main() rejected kinds 7..9 as unknown. After:
run_ring_bidir_op() validates closed-ring geometry, 16-byte alignment,
chunk coverage, and half-shard capacity (widest * 16 <= shard_cap / 2),
forwards arrived AG chunks zero-copy 1-hop, posts RS and AG-step-0
stripes to direct CW/CCW neighbors across all rails, checks CTRL_ERROR
and proxy shutdown guards, and drains all outstanding sends before
setting CTRL_PIPE_DONE.
- Compatibility: ROCE_ABI_VERSION remains 14; roce_layout, roce_blob_t,
RING_WINDOW (8), opcodes 0..6, and helios/src/execution/roce.rs are
unchanged so existing ABI 9/10/11/14 exported cores load and serve
identically. Cores exported with opcodes 7/8/9 require a serving runtime
containing this change; running them on an un-upgraded ABI-14 binary
fails loudly on first replay (unknown op kind 7/8).
Result:
- Enables native flare run serving of companion b12x 1-hop closed-ring
reduce-scatter, shard-gather, and fused all-reduce kernels on closed
rings of 3..16 ranks with zero ABI or core-format bump.
- Live multi-node GPU serving throughput was not re-measured in isolation
on this commit; earlier 4x DGX Spark hardware measurements of identical
run_ring_bidir_op transfer logic (paired with companion b12x closed-ring
kernels) are reported separately in the PR description.
Evidence:
- Strict C build: gcc -O2 -std=gnu11 -shared -fPIC -Wall -Wextra -Werror
helios/native/roce_proxy.c -libverbs -lpthread -> 0 warnings, 0 errors.
- Local scratch C unit harness (not committed in this PR) compiled against
archived helios/native/roce_proxy.c: verified ROCE_ABI_VERSION == 14,
RING_WINDOW == 8, opcodes 5..9, credit_phases() 10x10 transition matrix
(including KIND_RING2_STEP1/2 -> KIND_RING_RS/AG/RSAG and pipe <->
ring_bidir), ring_dir_shard_bounds() partitioning across world 3..16,
ring_ag_arrived(), and run_ring_bidir_op() negative bounds (including
half_cap overflow with shard_cap=256) plus CTRL_ERROR and running == 0
abort guards.
- Rust release tests on clean git archive:
- helios (--features roce --lib execution::roce): 30 passed, 0 failed
(6 execution::roce::tests + 24 execution::roce_fabric::tests).
- helios (--features runtime-core,server): 1813 passed, 83 ignored,
0 failed.
- flare: 245 passed, 4 ignored, 0 failed.
- flare-cli: 227 passed, 3 ignored, 0 failed.
- Core boundary: CUDA_VISIBLE_DEVICES="" pytest
tests/preparation/test_core_boundary.py -v -> 4 passed, 0 failed.
- Merge check: git merge-tree --write-tree origin/main HEAD -> 0 conflicts.
- Limitations: live multi-node RDMA hardware replay and flare run serving
on this exact commit have not been executed yet and require companion
b12x kernels emitting opcodes 7/8/9.
Discord: Dooner
Design-Signed-Off-By: Antigravity (gemini-4-neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
FujitsuPolycom
added a commit
to FujitsuPolycom/hyperflare-recipes
that referenced
this pull request
Nov 30, 2026
On multi-host closed-ring RoCEv2 deployments (such as 4x NVIDIA DGX Spark GB10 with 48 SMs), DeepSeek-V4.1 row-sharded prefill previously kept reduce-scatter collectives on the main CUDA stream (`row_shard_roce`), leaving 44 of 48 SMs idle during 4-CTA RoCE collectives (~20.5% of a 16K prefill chunk). Enabling half-chunk multi-stream overlap (`row_shard_dma`) atop the RoCE gather-overlap plumbing from local-inference-lab#106 hides closed-ring RoCE reduce-scatter and gather transfers behind local MoE and dense GEMM compute while keeping every collective strictly serialized on one auxiliary stream (`finish` before the next `start`) in deterministic rank order, preserving RoCE epoch lockstep ordering. Because persistent W4A8 routed-expert kernels occupy all SMs and cannot be preempted by stream priority, reserving 4 SMs (`reserve_sms=4`, leaving 44 MoE SMs + 4 RoCE SMs = 48 SMs on GB10) prevents tail-wave serialization. What changed: - `hyperflare_recipes/components/collectives.py`: - Before: After local-inference-lab#106 added `flare::roce_reduce_scatter_dep`, `_gather_shards_exec`, and RoCE support in `ConcurrentGatherShards`, `ConcurrentReduceScatter` still rejected RoCE channels, `PreparedGatherShards` still raised `ValueError` on non-empty RoCE graph-ordering `dependencies`, and `PreparedChunkedGatherShards` chained multi-chunk dependencies only for PCIe DMA. - After: Added `flare::roce_gather_shards_dep` with its fake registration, accepted RoCE row-shard channels in `ConcurrentReduceScatter` (matching `ConcurrentGatherShards`'s `row_shard_surfaces` check, `ScratchArena.register_parallel`, and zero caller scratch validation), dispatched RoCE `dependencies` in `PreparedGatherShards`, and chained multi-chunk `deps=(output,)` for RoCE in `PreparedChunkedGatherShards`. - `hyperflare_recipes/recipes/deepseek41/decoder.py`: - Before: `PreparedDecoder` enabled half-chunk `row_shard_dma` and `layer_pipelined` only for PCIe DMA runtimes, and `PreparedLayer` reserved `reserve_sms=2` unconditionally in `row_shard_dma`. - After: Added `_is_roce_overlap_runtime(runtime)` (requiring `_roce(runtime)`, `row_shard_surfaces(runtime)`, and `getattr(runtime, "ring_rs_ag", False)`), enabled `row_shard_dma` and encoder-layer `layer_pipelined` for qualifying closed-ring RoCE runtimes when encoder Engram layers carry `projection_full`, and set `reserve_sms=4 if _roce(runtime) else 2` on `PreparedRoutedExperts` in `row_shard_dma`. Decoder suffix layers, non-row-shard paths, local-inference-lab#106's `row_shard_roce` gather-overlap fallback, and local-inference-lab#112's ring2/DSpark/shared-expert scheduling remain unchanged. - Tests (`test_row_shard_collectives.py`, `test_deepseek41_moe_sm_reservation.py`, `test_deepseek41_roce_prefill_overlap.py`): - Verified `roce_reduce_scatter_dep`, `roce_gather_shards_dep`, and multi-chunk chaining via `make_fx`, `ConcurrentReduceScatter` and `ConcurrentGatherShards` RoCE registration and validation, `_is_roce_overlap_runtime` gating (ABI 14), `reserve_sms=4` on RoCE vs `2` on PCIe DMA in `PreparedLayer` (updating the mock to local-inference-lab#113's public `b12x.moe.fused_moe` contract), and `PreparedDecoder` selection vs `row_shard_roce` fallback. - Compatibility: `uv.lock` and `[tool.uv.sources]` are untouched. Against pinned FlashInfer (`cc532fdeac98`), `ring_rs_ag` is false, so `_is_roce_overlap_runtime` returns `False`, preserving existing `row_shard_roce` preparation and signed model cores until `NVIDIA/hyperflare-inference#649` and `local-inference-lab/flashinfer#195` land and `uv.lock` advances. Result: - Isolated 4-rank CUDA-graph overlap measurements on 4x DGX Spark GB10 (SM121 TP4, 100 replays each, 0 deadlocks, 0-ULP RoCE parity): - `W4A8(M=4096, reserve_sms=4) || RING_RS(40 MiB)`: `14.90 -> 13.86 ms` (`-1.04 ms` net vs `reserve_sms=0` serial; `90.0%` overlap efficiency; `reserve_sms=0` regressed to `16.20 ms`). - `W4A8(M=8192, reserve_sms=4) || RING_RS(80 MiB)`: `25.04 -> 23.07 ms` (`-1.97 ms` net vs `reserve_sms=0` serial; `+0.01 ms` contention). - `DenseGemm(4096x5120x5120) || RING_RS(40 MiB)`: `3.97 -> 3.14 ms` (`-0.83 ms`, `57.6%` overlap efficiency). - Combined-stack `flare run` serving observation (paired with `NVIDIA/hyperflare-inference#649` and `local-inference-lab/flashinfer#195`; not attributable to this change alone, and measured on non-matched prompt lengths relative to the earlier serial RoCE baseline): warm-Engram prefill observed `12,073.4 tok/s` (`15,999` tok / `1,325.2 ms`) at 16K and `12,891.0 tok/s` (`127,649` tok / `9,902.2 ms`) at 128K, with 15-cell sustained decode parity (`153.90 tok/s` geomean, `0` errors); a matched-ISL A/B on exact split commits is pending. Evidence: - Clean `git archive HEAD` CPU verification atop live `main` (`964b11a6b704`, including local-inference-lab#106, local-inference-lab#112, and local-inference-lab#113; `ignition` `d3d0e783555c`, `flashinfer-python` `cc532fdeac98`): - `git merge-tree --write-tree origin/main HEAD`: 0 conflicts; `git diff --check`: clean; 0 CRLF bytes across all 5 touched files. - `uvx ruff==0.12.8 check` on all 5 touched files: 0 errors; `uvx ruff==0.12.8 format --check` on `tests/recipes/test_deepseek41_roce_prefill_overlap.py`: clean. - CPU `pytest` (`CUDA_VISIBLE_DEVICES=""`) across 9 collective and DeepSeek-V4.1 prefill test files: 180 passed, 19 CUDA-only skipped, 0 failed (`test_row_shard_collectives.py` 29 passed, `test_deepseek41_moe_sm_reservation.py` 7 passed, `test_deepseek41_roce_prefill_overlap.py` 5 passed), plus 3 `local-inference-lab#112` regression suites (`test_deepseek41_expert_overlap.py`, `test_dspark_context_shard.py`, `test_packed_speculation.py`): 165 passed, 1 skipped, 0 failed. - Limitations: Local verification ran on CPU without GPU execution. The 4x DGX Spark GB10 microbenchmarks and signed `flare run` measurements were collected on equivalent combined-stack source; standalone matched-ISL GPU re-qualification after `flashinfer#195` lands and `uv.lock` advances, plus non-GB10 topologies (SM120/SM103, other TP widths), remain untested here. Discord: Dooner Design-Signed-Off-By: Antigravity (gemini-4-neon); design-review=6fcc Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
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.
Why
On closed switchless RoCE rings of
3+ranks (such as4×DGX Spark / NVIDIA GB10 nodes over dual200 GbElinks), large prefillreduce_scatter(KIND_REDUCE_SCATTER = 3) andgather_shards(KIND_GATHER_SHARDS = 4) routed non-adjacent transfers through 2-hop CPU mailboxes, adding host memory copies and saturating relay links. Adding 1-hop bidirectional closed-ring opcodes lets each rank send clockwise and counter-clockwise chunk halves strictly1hop across all rails and lanes with zero CPU relays while keepingROCE_ABI_VERSION = 14unchanged for existing exported cores.What changed
Scoped to
helios/native/roce_proxy.c(+281 / -3lines):KIND_RING_RS = 7,KIND_RING_AG = 8,KIND_RING_RSAG = 9):0..6covered one-shot (0), two-shot (1), variable all-gather (2), 2-hop reduce-scatter (3), 2-hop shard-gather (4), and 2-step ring all-reduce (KIND_RING2_STEP1 = 5,KIND_RING2_STEP2 = 6);credit_phases()guarded only two-shotpipetransitions (1, 3, 4).7..9belowKIND_RING2_STEP2 = 6uand extendscredit_phases()to guard both hazardous same-family reuse (7 -> 7/9onCREDIT_RS,8/9 -> 8onCREDIT_AG) and cross-family transitions between two-shotpipeops (1, 3, 4) and 1-hop ring ops (7, 8, 9) over sharedpipe_recv(RING2ops5..6use one-shotrecvslots and require0pipe credits).ring_dir_shard_bounds(),ring_ag_arrived(),run_ring_bidir_op(),proxy_main()):proxy_main()rejected op kinds7..9as unknown.7..9intorun_ring_bidir_op()with closed-ring (c->ring != NULL && !c->ring_open && world >= 3), 16-byte alignment,nbytes <= pipe_bytes,(world - 1) * chunks <= ROCE_MAX_CHUNKS, coverage,widest * 16 <= shard_cap / 2, andCTRL_ERROR/c->runningabort guards; prioritizes zero-copy 1-hop forwarding forgather_shardsand stripes across all rails viapost_striped().ROCE_ABI_VERSIONremains14.roce_layout,roce_blob_t,RING_WINDOW(8), opcodes0..6, andhelios/src/execution/roce.rsare unchanged; existing ABI9,10,11, and14cores load and serve identically.Result & gains
Paired with the companion
b12x1-hop closed-ring CuTe kernels on4×DGX Spark GB10 SM121 (2×200 GbEclosed ring,BF16,3rounds ×20–30iterations on an earlier prototype with identicalrun_ring_bidir_oplogic):3/4)run_ring_bidir_op)40 MiBreduce_scatter1.920 ms1.297 ms-32.4%(1.48×)80 MiBreduce_scatter3.788 ms2.605 ms-31.2%(1.45×)40 MiBgather_shards1.961 ms1.307 ms-33.4%(1.50×)80 MiBgather_shards3.819 ms2.591 ms(48.6 GB/sbidirectional)-32.2%(1.47×, ~97% line rate)flare runcontext (withlocal-inference-lab/flashinfer#195+ companionhyperflare-recipesreserve_sms=4overlap on4×GB10 TP4 DeepSeek-V4.1-Flash; NOT from this PR alone): Warm-Engram prefill observed12,073.4 tok/s(15,999tok /1,325.2 ms) at16K,12,809.2 tok/sat64K, and12,891.0 tok/sat128K(unmatched-ISL reference vs an earlier9,867.3 tok/sserial 2-hop baseline on14,196tokens; matched-ISL A/B pending).Supporting evidence and limitations
Verified on clean
git archive ac32e33e632cf232806c261bc7ad7ef911eada41atopmain(ec957867db624237e79711bd73da301e64df6119):gcc -O2 -std=gnu11 -shared -fPIC -Wall -Wextra -Werror helios/native/roce_proxy.c -libverbs -lpthreadpassed (0warnings); an external scratch C harness (outside the repo, not committed) verified ABI14,RING_WINDOW == 8, opcodes5..9, all10×10credit_phases()transitions (5..6 -> 7..9& cross-family1,3,4 <-> 7,8,9),ring_dir_shard_bounds()acrossW = 3..16, multi-railring_ag_arrived(), negative bounds (incl.half_capoverflow atshard_cap = 256),CTRL_ERROR, andc->running == 0aborts.git archive ac32e33e63):helios --features roce --lib execution::roce::tests6 passed;--lib execution::roce30 passed;helios --features runtime-core,server1,813 passed, 83 ignored, 0 failed;flare245 passed, 4 ignored, 0 failed;flare-cli227 passed, 3 ignored, 0 failed;tests/preparation/test_core_boundary.py4 passed, 0 failed.git merge-tree --write-tree origin/main ac32e33e632c0 conflicts (c0d24f6e7a6c4adeb39cd781c5241a52950f4e0b).flare runserving have not yet run on exact commitac32e33e63; hardware qualification requires pairing withlocal-inference-lab/flashinfer#195. Exported cores using opcodes7..9fail loudly (unknown op kind 7/8) on un-upgraded ABI-14 binaries;W != 4(3, 5..16) and non-SM121 RoCE NICs are unbenchmarked on hardware; scheduling-sim and TLA+/Kani proofs are N/A since onlyhelios/native/roce_proxy.cchanged.Stack and merge order
NVIDIA/hyperflare-inference, lands 1st): Adds ABI-14 opcodes7/8/9inhelios/native/roce_proxy.csoflare runsupports them before preparation emits them.local-inference-lab/flashinfer#195(lands 2nd): Adds lockstep_roce_proxy.cdispatch andb12xCuTe 1-hopreduce_scatter/gather_shards/all_reducekernels.local-inference-lab/hyperflare-recipes#114(lands 3rd): Advancesuv.lockand enables closed-ring RoCEreserve_sms=4Compute ∥ RoCE overlap.Reproduction commands (plain local NVMe verified)
Discord: Dooner