Skip to content

helios: add 1-hop closed-ring RoCE prefill proxy opcodes - #649

Open
FujitsuPolycom wants to merge 1 commit into
NVIDIA:mainfrom
FujitsuPolycom:feat/roce-ring-rs-ag-proxy
Open

FujitsuPolycom wants to merge 1 commit into
NVIDIA:mainfrom
FujitsuPolycom:feat/roce-ring-rs-ag-proxy

Conversation

@FujitsuPolycom

@FujitsuPolycom FujitsuPolycom commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Why

On closed switchless RoCE rings of 3+ ranks (such as 4× DGX Spark / NVIDIA GB10 nodes over dual 200 GbE links), large prefill reduce_scatter (KIND_REDUCE_SCATTER = 3) and gather_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 strictly 1 hop across all rails and lanes with zero CPU relays while keeping ROCE_ABI_VERSION = 14 unchanged for existing exported cores.

What changed

Scoped to helios/native/roce_proxy.c (+281 / -3 lines):

  • Opcodes & credits (KIND_RING_RS = 7, KIND_RING_AG = 8, KIND_RING_RSAG = 9):
    • Before: Opcodes 0..6 covered 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-shot pipe transitions (1, 3, 4).
    • After: Defines opcodes 7..9 below KIND_RING2_STEP2 = 6u and extends credit_phases() to guard both hazardous same-family reuse (7 -> 7/9 on CREDIT_RS, 8/9 -> 8 on CREDIT_AG) and cross-family transitions between two-shot pipe ops (1, 3, 4) and 1-hop ring ops (7, 8, 9) over shared pipe_recv (RING2 ops 5..6 use one-shot recv slots and require 0 pipe credits).
  • 1-hop ring transfer engine (ring_dir_shard_bounds(), ring_ag_arrived(), run_ring_bidir_op(), proxy_main()):
    • Before: proxy_main() rejected op kinds 7..9 as unknown.
    • After: Dispatches 7..9 into run_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, and CTRL_ERROR / c->running abort guards; prioritizes zero-copy 1-hop forwarding for gather_shards and stripes across all rails via post_striped().
  • 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; existing ABI 9, 10, 11, and 14 cores load and serve identically.

Result & gains

Paired with the companion b12x 1-hop closed-ring CuTe kernels on 4× DGX Spark GB10 SM121 (2×200 GbE closed ring, BF16, 3 rounds × 20–30 iterations on an earlier prototype with identical run_ring_bidir_op logic):

Isolated Collective 2-Hop Control (3 / 4) 1-Hop Ring (run_ring_bidir_op) Speedup
40 MiB reduce_scatter 1.920 ms 1.297 ms -32.4% (1.48×)
80 MiB reduce_scatter 3.788 ms 2.605 ms -31.2% (1.45×)
40 MiB gather_shards 1.961 ms 1.307 ms -33.4% (1.50×)
80 MiB gather_shards 3.819 ms 2.591 ms (48.6 GB/s bidirectional) -32.2% (1.47×, ~97% line rate)
  • Combined-stack flare run context (with local-inference-lab/flashinfer#195 + companion hyperflare-recipes reserve_sms=4 overlap on 4× GB10 TP4 DeepSeek-V4.1-Flash; NOT from this PR alone): Warm-Engram prefill observed 12,073.4 tok/s (15,999 tok / 1,325.2 ms) at 16K, 12,809.2 tok/s at 64K, and 12,891.0 tok/s at 128K (unmatched-ISL reference vs an earlier 9,867.3 tok/s serial 2-hop baseline on 14,196 tokens; matched-ISL A/B pending).

Supporting evidence and limitations

Verified on clean git archive ac32e33e632cf232806c261bc7ad7ef911eada41 atop main (ec957867db624237e79711bd73da301e64df6119):

  • C compile & outside-repo harness: gcc -O2 -std=gnu11 -shared -fPIC -Wall -Wextra -Werror helios/native/roce_proxy.c -libverbs -lpthread passed (0 warnings); an external scratch C harness (outside the repo, not committed) verified ABI 14, RING_WINDOW == 8, opcodes 5..9, all 10×10 credit_phases() transitions (5..6 -> 7..9 & cross-family 1,3,4 <-> 7,8,9), ring_dir_shard_bounds() across W = 3..16, multi-rail ring_ag_arrived(), negative bounds (incl. half_cap overflow at shard_cap = 256), CTRL_ERROR, and c->running == 0 aborts.
  • Rust & core boundary (git archive ac32e33e63): helios --features roce --lib execution::roce::tests 6 passed; --lib execution::roce 30 passed; helios --features runtime-core,server 1,813 passed, 83 ignored, 0 failed; flare 245 passed, 4 ignored, 0 failed; flare-cli 227 passed, 3 ignored, 0 failed; tests/preparation/test_core_boundary.py 4 passed, 0 failed.
  • Merge check: git merge-tree --write-tree origin/main ac32e33e632c 0 conflicts (c0d24f6e7a6c4adeb39cd781c5241a52950f4e0b).
  • Limitations: Live 4-node RDMA replay & flare run serving have not yet run on exact commit ac32e33e63; hardware qualification requires pairing with local-inference-lab/flashinfer#195. Exported cores using opcodes 7..9 fail 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 only helios/native/roce_proxy.c changed.

Stack and merge order

  1. This PR (NVIDIA/hyperflare-inference, lands 1st): Adds ABI-14 opcodes 7/8/9 in helios/native/roce_proxy.c so flare run supports them before preparation emits them.
  2. local-inference-lab/flashinfer#195 (lands 2nd): Adds lockstep _roce_proxy.c dispatch and b12x CuTe 1-hop reduce_scatter / gather_shards / all_reduce kernels.
  3. local-inference-lab/hyperflare-recipes#114 (lands 3rd): Advances uv.lock and enables closed-ring RoCE reserve_sms=4 Compute ∥ RoCE overlap.
Reproduction commands (plain local NVMe verified)
set -euo pipefail

# 1. Verify plain local NVMe backing
WORK=/var/tmp/flare-roce-ring-verify
mkdir -p "$WORK"
real=$(realpath "$WORK")
findmnt -T "$real" -o TARGET,SOURCE,FSTYPE,OPTIONS
df -Th "$real"

# 2. Extract exact candidate commit
FLARE_SHA="ac32e33e632cf232806c261bc7ad7ef911eada41"
git -C "$WORK/hyperflare-inference" archive "$FLARE_SHA" | tar -x -C "$WORK/archive"

# 3. Strict C compile with libibverbs
gcc -O2 -std=gnu11 -shared -fPIC -Wall -Wextra -Werror \
  "$WORK/archive/helios/native/roce_proxy.c" -libverbs -lpthread -o "$WORK/roce_proxy.so"

# 4. Rust release tests + core boundary check
python3 "$WORK/archive/tests/frontend/prepare_templates.py" --output "$WORK/templates" \
  --recipe gemma4 --recipe glm53 --recipe mimo_v2 --recipe minimax_m3 \
  --recipe nemotron_h --recipe qwen38 --recipe step5
export FLARE_TEST_TEMPLATE_DIR="$WORK/templates"
cargo test --locked --release --manifest-path "$WORK/archive/helios/Cargo.toml" \
  --features roce --lib execution::roce --target-dir "$WORK/target"
cargo test --locked --release --manifest-path "$WORK/archive/helios/Cargo.toml" \
  --features runtime-core,server --target-dir "$WORK/target"
cargo test --locked --release --manifest-path "$WORK/archive/flare/Cargo.toml" \
  --target-dir "$WORK/target"
cargo test --locked --release --manifest-path "$WORK/archive/flare-cli/Cargo.toml" \
  --target-dir "$WORK/target"
CUDA_VISIBLE_DEVICES="" pytest "$WORK/archive/tests/preparation/test_core_boundary.py" -v

Discord: Dooner

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant