Skip to content

helios: rotate RoCE proxy peer send order by rank to avoid synchronized incast - #725

Merged
lukealonso merged 2 commits into
mainfrom
perf/roce-rotate-peer-order
Dec 4, 2026
Merged

lukealonso merged 2 commits into
mainfrom
perf/roce-rotate-peer-order

Conversation

@original-el8

@original-el8 original-el8 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

In helios/native/roce_proxy.c, all four peer-posting loops (post_op, post_pipe_chunk, post_credits, and run_varlen_op) iterate destinations in fixed 0 .. world - 1 order on every rank. On switched mesh fabrics (world >= 4), all world - 1 ranks post to rank 0 simultaneously, then rank 1, then rank 2, creating lockstep (world - 1):1 incast onto each receiver's switch egress port on every collective and chunk.

Change

Rotate destination order by rank in all four posting loops (three payload loops — post_op, post_pipe_chunk, run_varlen_op — plus control-plane post_credits for uniformity):

for (int step = 1; step < c->world; step++) {
  int p = (c->rank + step) % c->world;
  • Every peer p != rank is visited exactly once per pass.
  • At each step, rank -> (rank + step) % world is a 1:1 bijection (0->1, 1->2, 2->3, 3->0, then 0->2, 1->3, ...), eliminating lockstep (world - 1):1 incast at zero runtime or ABI cost (ROCE_ABI_VERSION remains 14; existing runtime packages load unmodified).
  • Two-pass relayed-first (c->ring) and all-gather relay (c->relay_via) filters are preserved unchanged; intra-pass peer order within those filters also rotates by rank.
  • pyproject.toml pins the merged FlashInfer parity commit 3c5c7b14886a7b8904e2963f7d678dbf3a4a755e (from local-inference-lab/flashinfer#221), and helios/native/roce_proxy.c matches flashinfer/experimental/b12x/comm/roce/_roce_proxy.c byte-for-byte after the 9-line vendored header (required by tests/preparation/test_roce_proxy_parity.py). Because 3c5c7b14886a7b8904e2963f7d678dbf3a4a755e sits on top of local-inference-lab/flashinfer#220, helios/native/roce_proxy.c also includes the roce_set_hairpin_peers pacing path, which is inactive unless called by a hairpin topology.

Cross-Rank Happens-Before Analysis

  • Source-keyed slots and symmetric barriers: Every collective sequence seq writes source-keyed slots (recv[src][slot], flag[src][slot][rail], pipe_recv[src][phase], pipe_flag[phase][src][chunk][rail], varlen_flag[slot][src][chunk][rail], and ctrl[CTRL_CREDIT + src]). No destination slot is shared between distinct senders, and each receiver's completion check (credits_arrived, pipe_chunk_arrived, and device flag waits) is a symmetric barrier over all src != rank independent of destination posting order.
  • Per-QP ordering: For any fixed (src, dst, rail, lane) reliable RC QP, the relative order of payload data WRs, inline 4-byte readiness seq flags, and consecutive chunk/op sequences is unchanged.
  • Ring mailbox ordering: ring_post allocates strictly monotonic per-rail c->ring_serial[rail] at post time; rotating destination order within pass 0 of post_op or post_credits preserves strictly ascending serials on each neighbor hop and identical receiver reassembly.

Validation

Unit & Parity Checks

  • cargo test --locked --release --manifest-path helios/Cargo.toml --features roce --lib execution::roce: 35 passed, 0 failed.
  • helios/native/roce_proxy.c (lines 10..EOF) is byte-for-byte identical (98,150 bytes) to flashinfer/experimental/b12x/comm/roce/_roce_proxy.c at pinned revision 3c5c7b14886a7b8904e2963f7d678dbf3a4a755e (-Wall -Wextra clean, test_roce_proxy.py: 24 passed).

Served-Workload A/B Benchmark (4-Node Switched Mesh)

  • Conditions: 4-node NVIDIA GB10 (SM121) cluster on a switched dual-rail 200GbE ConnectX-7 RoCEv2 mesh (Shape::Mesh), serving an unmodified ABI 14 TP4 DeepSeek-V4.1-Flash runtime package (--alpha 1.0 --embedding-cache-size 22GiB --checkpoint-extra-work-fraction 0.05, --max-concurrency 32, --mtp-draft-tokens 7, --mtp-adaptive-verification, --mtp-max-verification-token-budget 256). One clean cold boot per arm, identical prompts and concurrency schedule, comparing release flare binaries built from main (f705086b) against the isolated peer-rotation commit (8b06cdac; the switched-mesh execution path at da7abad2 is identical because roce_set_hairpin_peers is not called on Shape::Mesh).
  • Correctness: 0 failed requests on both arms across all prefill and decode passes.
Workload main (f705086b) Peer rotation (8b06cdac) Delta Per-pass throughput (main vs branch)
Cold prefill 10,618 tok (3 passes) 9,929.7 tok/s (1,069.4 ms TTFT) 9,992.1 tok/s (1,062.9 ms TTFT) +0.63% 9866.0 / 9869.4 / 10053.6 vs 9916.1 / 9833.8 / 10226.2
Cold prefill 42,430 tok (2 passes) 11,605.5 tok/s (3,656.1 ms TTFT) 11,726.8 tok/s (3,618.2 ms TTFT) +1.05% 11639.9 / 11571.0 vs 11742.0 / 11711.7
Concurrent prefill 4×10,618 tok (2 passes) 10,077.7 agg tok/s (4,214.4 ms wall) 10,228.4 agg tok/s (4,152.4 ms wall) +1.50% 10084.1 / 10071.4 vs 10198.7 / 10258.2
Decode C=1, 256 tok (2 passes) 74.5 e2e / 78.8 dec tok/s 76.9 e2e / 81.4 dec tok/s +3.23% e2e 73.5 / 75.5 vs 72.6 / 81.2
Decode C=4, 4×256 tok (2 passes) 137.8 e2e / 158.7 dec tok/s 137.3 e2e / 157.0 dec tok/s -0.38% e2e 130.1 / 145.6 vs 126.6 / 148.1
Decode C=16, 16×256 tok (2 passes) 235.7 e2e / 286.5 dec tok/s 234.9 e2e / 285.6 dec tok/s -0.35% e2e 221.3 / 250.1 vs 224.0 / 245.7
  • Conclusion: Multi-MB collective prefill paths (post_pipe_chunk / run_varlen_op) gain +1.05% on 42K single-request prefill and +1.50% on 4×10.6K concurrent prefill (strictly higher on every pass), with neutral decode throughput across C=1/4/16 (all deltas within pass-to-pass variance) and zero collective or request errors.

Discord: el8

…ed incast

In `helios/native/roce_proxy.c`, `post_op`, `post_pipe_chunk`,
`post_credits`, and `run_varlen_op` iterated peers in fixed `0..world-1`
order on every rank. On switched mesh fabrics (`world >= 4`), every rank
posted to rank 0 first, then rank 1, then rank 2, synchronizing
`(world - 1):1` incast onto each receiver's switch egress port.

Replace those four peer-posting loops with a rank-rotated permutation
schedule (`for (int step = 1; step < c->world; step++) { int p =
(c->rank + step) % c->world; ... }`) under existing ABI 14 (no wire,
blob, or region layout changes), matching companion
local-inference-lab/flashinfer#221 byte-for-byte after the provenance
header. Each step maps senders to destinations 1:1 across the fabric
while visiting every peer `p != rank` exactly once and preserving
existing `c->ring` and `c->relay` filters.

Validated with `cargo test --locked --release --manifest-path
helios/Cargo.toml --features roce --lib execution::roce` (35 passed),
`-Wall -Wextra` C compilation, and byte-for-byte parity verification
against local-inference-lab/flashinfer#221 (`test_roce_proxy.py`: 24
passed). Live multi-node switched-mesh benchmarking and pinning the
merged FlashInfer commit in `pyproject.toml` remain pending.

Discord: el8
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 725.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:rocenante RoCEnante cross-host GPU collectives and RoCE transport. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:validation Proposed implementation needs acceptance evidence; no claim that a reported defect is fixed. labels Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The C change itself (helios/native/roce_proxy.c, +11 / -14) is clean and free of verified code defects — all four rotated peer loops visit every p != rank bijectively, with ROCE_ABI_VERSION = 14, relayed-first / relay_via filters, and ring mailbox serial ordering preserved. Two verified hard gates block merge: the vendored proxy now diverges from the pinned FlashInfer revision (pyproject.toml:47), failing mandatory parity CI, and the PR lacks the required served-workload benchmark plus live multi-GPU collective and cross-rank happens-before evidence.

  • Blockers: 2 · Should fix: 0 · Subtract/Simplify: 1 · Nits: 1
Walkthrough
  • helios/native/roce_proxy.c:1296-1306 (post_op): replaces for (int p = 0; p < c->world; p++) + p == c->rank skip with a rank-rotated step = 1 .. world - 1 loop (p = (c->rank + step) % c->world), preserving the two-pass want_relayed filter (:1293-1302).
  • helios/native/roce_proxy.c:1437-1441 (post_pipe_chunk): same rank-rotated loop, removing the redundant p == c->rank || branch while keeping the phase == 1 && c->relay && c->relay_via[p] >= 0 guard verbatim.
  • helios/native/roce_proxy.c:1556-1563 (post_credits): same rank-rotated loop for 4-byte inline credit writes, preserving the ring_relayed(c, p) relay branch.
  • helios/native/roce_proxy.c:1939-1951 (run_varlen_op): same rank-rotated loop inside the per-chunk varlen all-gather posting loop, keeping posted % c->n_lane lane selection and source-keyed flags unchanged.
  • Verified invariants: world bounded to 2..=16 (roce_layout:389), ring_post:1159 allocates monotonic c->ring_serial[rail] at post time so per-relay arrival order stays strictly ascending for any peer permutation, and ROCE_ABI_VERSION remains 14 (:160, matching helios/src/execution/roce.rs:23) with zero wire or core-format changes.
Merge Risk: Medium · up to 8b06cda
  • Guaranteed CI failure on head: tests/preparation/test_roce_proxy_parity.py:35-65 runs under .github/workflows/python-cpu.yml:29-33 and fails until local-inference-lab/flashinfer#221 lands and pyproject.toml:47 is repinned.
  • Unvalidated runtime behavior on live RDMA hardware: The cited 35 Rust unit tests (execution::roce) do not open IB verbs or execute any of the four rotated loops, and no multi-node switched-mesh or ring benchmark has been run.
  • Direct merge overlap with open #712: The same author's #712 modifies the same four functions in helios/native/roce_proxy.c (+222 / -38) with its own companion FlashInfer PR (flashinfer#220); whichever lands second needs a rebase and coordinated FlashInfer pin.
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: Pure local loop-order change in C proxy; no new network surface, credentials, flags, or prompt-injection content.
  • ⚠️ Charter & value fit: Right layer and minimal footprint (no new flags or per-model branches, ABI 14 preserved), but misses the Charter's mandatory performance-PR benchmark gate (#210) and dependency-pinning parity rule (#215).
  • ⚠️ Related / duplicate / conflict check: Genuinely additive (not duplicated on main), but directly overlaps open #712 (same author, same four functions in helios/native/roce_proxy.c, companion flashinfer#220 vs #221).
  • ⚠️ Tests & verification evidence: execution::roce unit tests (35 passed) do not exercise the four rotated loops; tests/preparation/test_roce_proxy_parity.py fails against the current pyproject.toml:47 pin; live multi-GPU collective execution and served A/B benchmarks are unrun.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

… roce_proxy.c

Pin `[tool.uv.sources].flashinfer-python.rev` to merged
`local-inference-lab/flashinfer#221` (`3c5c7b14886a7b8904e2963f7d678dbf3a4a755e`)
and sync `helios/native/roce_proxy.c` byte-for-byte with that revision
(which includes merged `flashinfer#220` plus the rank-rotated peer send
order from `#221`) so `tests/preparation/test_roce_proxy_parity.py`
passes against the pinned FlashInfer dependency.

Validated exact byte-for-byte parity (97,954 bytes).

Discord: el8
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@original-el8

Copy link
Copy Markdown
Collaborator Author

Both blockers are resolved at da7abad2:

  1. FlashInfer parity pin (pyproject.toml + helios/native/roce_proxy.c): local-inference-lab/flashinfer#221 merged at 3c5c7b14886a7b8904e2963f7d678dbf3a4a755e. pyproject.toml pins that revision and helios/native/roce_proxy.c matches flashinfer/experimental/b12x/comm/roce/_roce_proxy.c byte-for-byte after the 9-line vendored header (also carrying the roce_set_hairpin_peers pacing path from local-inference-lab/flashinfer#220, which is inactive on switched mesh).
  2. Served-workload 4-node switched-mesh A/B & cross-rank happens-before: Added the cross-rank happens-before analysis and matched 4-node GB10 switched dual-rail 200GbE mesh (Shape::Mesh) DeepSeek-V4.1-Flash TP4 A/B results (main f705086b vs isolated peer-rotation 8b06cdac, unmodified ABI 14 package, 0 failed requests on both arms) to the PR description:
    • Cold prefill 42,430 tok (2 passes): 11,605.5 → 11,726.8 tok/s (+1.05%, higher on every pass)
    • Concurrent prefill 4×10,618 tok (2 passes): 10,077.7 → 10,228.4 agg tok/s (+1.50%, higher on every pass)
    • Cold prefill 10,618 tok (3 passes): 9,929.7 → 9,992.1 tok/s (+0.63%)
    • Decode C=1 / C=4 / C=16 (256 tok, 2 passes): +3.23% / -0.38% / -0.35% e2e (neutral within pass-to-pass variance)

@flare-autobot please re-review.

@flare-autobot flare-autobot added triage:review Proposed change needs code review; this does not imply merge readiness. and removed triage:validation Proposed implementation needs acceptance evidence; no claim that a reported defect is fixed. labels Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

Both Round-1 blockers are resolved at da7abad: the pyproject.toml:47 pin now tracks merged local-inference-lab/flashinfer#221 with a compliant provenance header, and the PR description carries a cross-rank happens-before analysis plus a matched 4-node GB10 switched-mesh served-workload A/B (zero failed requests). Direct inspection of all four rotated peer-posting loops and the parity-imported roce_set_hairpin_peers / post_striped_paced path found zero code correctness bugs, zero hot-path regressions, and zero ABI/wire changes.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 1 · Nits: 1
Walkthrough
  • pyproject.toml:47: updates flashinfer-python git rev from 1441ce862ffbc9d8550fdda7ad90e97ca04f4b8e (set by #707) to merged local-inference-lab/flashinfer#221 commit 3c5c7b14886a7b8904e2963f7d678dbf3a4a755e; helios/native/roce_proxy.c:1-9 preserves the 9-line provenance header asserted by tests/preparation/test_roce_proxy_parity.py:17,40-46.
  • helios/native/roce_proxy.c:1460-1464 (post_op), :1602-1606 (post_pipe_chunk), :1729-1736 (post_credits), :2115-2119 (run_varlen_op): replaces ascending for (int p = 0; p < c->world; p++) loops with for (int step = 1; step < c->world; step++) { int p = (c->rank + step) % c->world; ... }, preserving two-pass relayed-first (c->ring), relay_via, and ring_relayed filters while visiting every p != rank bijectively (world ∈ [2, 16] enforced by roce_layout:401).
  • helios/native/roce_proxy.c:206-213, 354-357, 870-893, 1299-1422, 1599-1637, 2112-2135: syncs HAIRPIN_SEG_BYTES (64 KiB), HAIRPIN_MAX_INFLIGHT_SEGS (2, statically asserted < ROCE_RESERVE_OPS), roce_set_hairpin_peers, peer_outstanding, post_striped_paced, and the two-pass want_paced dispatch from upstream flashinfer#220 to maintain byte-for-byte parity with 3c5c7b148.
  • Verified protocol & ABI invariants: ROCE_ABI_VERSION remains 14 (:160, matching helios/src/execution/roce.rs:23), roce_layout and roce_blob_t (1176 bytes since #707) are untouched, all receive/flag/credit destinations are source-keyed, and ring_post:1196 allocates strictly monotonic c->ring_serial[rail] at post time so ring_service:1154-1172 and ring_service_slot:1059-1060 preserve ascending per-hop serial ordering.
Merge Risk: Low · up to da7abad
  • Dead vendored hairpin pacing path until #712 wires it: Because merged flashinfer#221 (3c5c7b148) sits on top of flashinfer#220, helios/native/roce_proxy.c carries ~150 lines of roce_set_hairpin_peers / post_striped_paced (:206-213, :354-357, :870-893, :1299-1422, :1599-1609, :2112-2135) with no caller in this repository (hairpin_pacing remains 0 from calloc at :588, so passes == 1 and post_striped_paced never executes). Once #712 lands and enables roce_set_hairpin_peers, the combined rotation × hairpin-pacing path on Shape::HairpinRing/HairpinChain should be validated on hardware there.
  • Unverified external byte parity & pin contention: Exact byte identity against external flashinfer@3c5c7b148 cannot be executed in this offline review environment (validated by .github/workflows/python-cpu.yml via tests/preparation/test_roce_proxy_parity.py:35-65). Open #731 also bumps pyproject.toml:47 (to 6aff33c4), and open #712 touches helios/native/roce_proxy.c and pyproject.toml:47; merging #725 first lets #712 drop its own proxy/pin diff cleanly and requires #731 (or whichever lands second) to rebase its pin.
  • Benchmark sample size & instrumentation: The 4-node switched-mesh A/B uses n = 2–3 sequential passes per cell with non-overlapping wins on 42K cold prefill (+1.05%) and 4×10.6K concurrent prefill (+1.50%), overlapping per-pass ranges on 10.6K cold prefill (+0.63%), neutral decode, and no NIC/switch pause counters; however, ROCE_RESERVE_OPS = 48 and RING_WINDOW = 16 were already on main via #707, confirming the measured 8b06cdac mesh path is identical to da7abad.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: Pure local loop-order rotation, inert vendored upstream pacing path, and exact 40-char git SHA pin on the existing local-inference-lab/flashinfer repo; no new network surface, flags, or prompt-injection content.
  • ✅ Charter & value fit: Right layer, zero ABI/core-format/flag overhead, exact dependency pin (#215), and a matched main-vs-branch served-workload A/B benchmark (#210) with cross-rank happens-before analysis (docs/design-review.md:252-259).
  • ⚠️ Related / duplicate / conflict check: Genuinely additive over merged #707; note merge-order coordination on pyproject.toml:47 with open #731 and on helios/native/roce_proxy.c with open #712 (landing #725 first is the cleaner sequence).
  • ✅ Tests & verification evidence: Offline Rust execution::roce suite (35 passed), upstream test_roce_proxy.py (24 passed), parity header/pin alignment verified, and 4-node GB10 switched-mesh DeepSeek-V4.1-Flash TP4 flare-served A/B completed with 0 failed requests.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Test Results

Full Test Report

Tested

Ran the full CPU-side gate set for PR #725 (vendored-proxy parity against the pinned FlashInfer 3c5c7b148, the full prep pytest suite, the 35 native RoCE conformance tests, the aarch64 roce,rdma compile-parity check plus a release build, and flare doctor). Attempted the planned live-verbs exercise at world=4 over both real CX-7 and Soft-RoCE, and when that was denied, substituted a CPU-only posting-order enumeration of the four rotated loops.

Hardware used

Single arm64 node: 1× GB10 GPU (driver 580.178.04, CUDA 13.0) and 2× dual-port ConnectX-7 adapters presenting 4 RoCE ports, all ACTIVE, LinkUp, 200 Gb/s (2X NDR), link_layer=Ethernet; 20 CPUs, 121 GiB, ephemeral container with no RDMA device nodes and no network-admin capabilities. No GPU-hours used.

Results

  • Phase 0 PASS: parity is byte-identical to upstream 3c5c7b148 (2 passed); full suite 4 failed, 2612 passed, 481 skipped with the 4 failures unrelated (argparse wrapping, a torch-2.14 weakref, and an RLIMIT_NOFILE capability test); cargo test ... execution::roce 35 passed; 0 failed; cargo check --features roce,rdma and a release build of flare both exit 0. The changed proxy is genuinely compiled into the arm64 artifact (build.rs:81-91 (not opened) → roce_proxy_dlopen.c:236 (not opened)).
  • Parity initially failed only because the prefetched venv held flashinfer 598c8547 (76 commits behind pyproject.toml:47); cmp against the pinned tree is identical.
  • Phase 1 BLOCKED / not run: no /dev/infiniband in the container, mknod and rdma link add rxe0 both EPERM (CapEff 0xeb), ibv_devices empty. The four rotated loops were never executed under real verbs, and the phase-2 traffic-spread counters were not taken. No substitute result is offered as hardware evidence.
  • Rotation is a no-op at world=2 (verified: rotated order equals pre-PR order for both ranks) and a permutation at world=3..6 (every peer posted exactly once, so no stall-by-omission); peak fan-in on one receiver drops 3→1 at world=4, 4→1 at world=5, 7→1 at world=8. Ranks 0 and world-1 keep the old order. Arithmetic, not measurement.
  • Hairpin pacing is dead in Flare (roce_set_hairpin_peers has no caller outside the C file), so the author's "mesh path identical to the measured 8b06cdac" equivalence holds for Shape::Mesh; the rotation × pacing combination stays untested (helios,flare-cli: default --roce-ring and --roce-chain to ConnectX-7 hardware hairpin (--roce-proxy for CPU relay) #712).
  • Thermal: GPU 39 °C/4 W at start, 41 °C/4.80 W/0 % util at the end; no GPU work submitted, so no thermal risk taken.

Conclusion

Pass—every gate runnable in this environment is green, and nothing here indicates a defect. The performance claim is a separate matter: it is Inconclusive, unverified by this pass, and still needs a 4-node GB10 CX-7 bench with n ≥ 5 interleaved passes, per-pass ranges, incast/PFC counters, and a --ring-open relay run, so this pass should not be treated as satisfying the merge gate.

@lukealonso
lukealonso merged commit 3222a51 into main Dec 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:rocenante RoCEnante cross-host GPU collectives and RoCE transport. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants