Review — PR #643 "perf(helios): add 2-step RoCE ring proxy opcodes for 4-rank switchless rings"
Scope reviewed: helios/native/roce_proxy.c (single file, +311/−26, head 9c3ea69, base main @ 0a8c20f4), the whole modified file in context, plus its callers/contracts: helios/src/execution/roce.rs, docs/roce-ring.md, AGENTS.md, NOTICE, helios/build.rs / helios/Cargo.toml.
Key findings
- Blocker — the new compile-time WR budget is wrong.
_Static_assertbudgets relays atROCE_SEND_DEPTH/6(255 WRs) but relay forwarding on the same lane-0 QP is gated atROCE_SEND_DEPTH/4(384 WRs) with uncapped ring ACKs on top. Ring2 (222 WRs) + relays + ACKs exceeds the 512-deep queue;ibv_post_sendthen returnsENOMEM, the proxy setsfailed=1, and perdocs/roce-ring.md:347the whole serving group must be restarted. - Major — undeclared workload inversion on every 4-rank ring.
post_opnow posts relayed peers first (:1238-1252), so the 2/3 of every one-shot payload headed to the direct neighbours waits behind a blocking mailbox-credit spin (:1107-1116). This changes the existing one-shot path, not just ring2. - Major — undeclared scope carry-over from #576:
pin_high_capacity_cpus()+pthread_setname_np(…"flare-roce")(:1702-1767,:1771-1774), the identical hunk owned by open PR #576 (and closed duplicate #633). - Major — undeclared scope on all pre-existing traffic:
IBV_SEND_INLINEnewly added to relay mailbox/one-shot WRs andmax_inline_dataraised 16→256 for every QP (:497-515,:915,:924,:932,:1009,:1168,:1188). - Major — contracts: vendored-parity rule broken with no upstream proxy revision cited; new wire kind values with no ABI bump (stays 14), no
roce_blob_tcapability word, no preflight — mismatched peers and ring2-on-mesh/chain die at replay with no fallback. - Major — evidence: the only number is absolute (31.8–33.0 µs/call), no
mainbaseline or served-workload A/B (#210); the cited test invocations never compile this C; no ring2 test and nodocs/roce-ring.mdupdate exist.
1. Correctness, Safety & Platform Parity
F1 — BLOCKER: ring2 WR budget is arithmetically inconsistent with the actual relay gate; a full QP poisons the transport
helios/native/roce_proxy.c:175-187:
// Two-step ring direct writes signal 1 in RING2_SIGNAL_STRIDE ops per (HCA, peer)
// QP. Capping signaled outstanding ops at RING2_MAX_OUTSTANDING keeps at most
// RING2_MAX_OUTSTANDING * RING2_SIGNAL_STRIDE * 2 + (RING2_SIGNAL_STRIDE - 1) * 2
// = 222 WRs in flight on a 512-deep send queue, leaving room for up to 85
// subsequent three-WR relay ops (255 WRs) plus world=4 ring ACKs.
#define RING2_SIGNAL_STRIDE 16u
#define RING2_MAX_OUTSTANDING 6u
_Static_assert(RING2_MAX_OUTSTANDING * RING2_SIGNAL_STRIDE * 2 +
(RING2_SIGNAL_STRIDE - 1u) * 2 + (ROCE_SEND_DEPTH / 6) * 3 <=
ROCE_SEND_DEPTH,
"batched ring2 WRs must fit inside ROCE_SEND_DEPTH with queue slack");
The comment and the assert both assume relay forwarding is capped by reserve() = ROCE_SEND_DEPTH / 6. It is not. The forwarding path has its own, looser gate — helios/native/roce_proxy.c:984:
int next = ring_next(c, target);
int h = c->rail_hca[next][rail];
if (c->hca[h].outstanding[next][0] >= ROCE_SEND_DEPTH / 4) return 1;
ROCE_SEND_DEPTH is 512 (:140), so the relay cap is 128 ops × 3 WRs = 384 WRs, not 255. On top of that, ring_complete() posts an ACK on the same lane-0 QP with no cap at all (:880-885):
int rc = ibv_post_send(c->hca[h].qp[previous][0], &wr, &bad);
if (rc != 0) {
set_err(c, "ring ack", rc);
return -1;
}
c->hca[h].outstanding[previous][0]++;
Ring2 posts to exactly that QP (:1316 ibv_post_send(hca->qp[p][0], first_wr, &bad)), and at world==4 the ring2 neighbours are the relay next hops (ring_next / ring_next_from, :337-345), so ring2 and relay traffic share one 512-deep send queue. Second compounding fact: RING2_MAX_OUTSTANDING gates signaled ops, not WRs — outstanding is only incremented when signaled (:1321-1323), and only 1 post in 16 is signaled (:1277, :1324-1325), so 6 outstanding can mean up to 96 posts / 192 WRs, and the batching counter is advanced once per post even though a post can carry 2 WRs (:1296-1313).
Worst case: 222 (ring2) + 384 (relay) + unbounded ACKs > 512 → ibv_post_send returns ENOMEM → set_err → -1 → atomic_store(&c->failed, 1); return NULL; (:1864-1867). Impact: the transport is permanently poisoned for the process; docs/roce-ring.md:347 states "Recovery from a failed ring neighbor is unsupported; stop and restart all ranks together", i.e. one queue overflow takes down the whole serving group, triggered by load, not by a bug in the peer.
Fix: derive the ring2 window from the actual relay gate (ROCE_SEND_DEPTH / 4 * 3 = 384 WRs) plus explicit ring_complete ACK headroom in the assert; better, replace the two independent outstanding thresholds with one WR-count (not signaled-op count) occupancy counter per QP that both reserve_limit and the :984 relay gate consult, and count actual WRs per post in post_direct_striped_batched. The current _Static_assert is a compile-time claim about a runtime gate it does not model, and it passes only because it uses /6.
F2 — MAJOR: relayed-first two-pass post_op puts direct writes behind a blocking mailbox-credit wait
helios/native/roce_proxy.c:1223-1252:
// Post one-shot op seq to every peer: the whole payload, one stripe plus its flag
// write per rail, each on the HCA routed to that peer for the rail. Post relayed
// multi-hop peers first so the critical-path hop starts earliest on a ring.
static int post_op(roce_ctx_t* c, uint32_t seq, uint32_t nbytes) {
...
int passes = c->ring != NULL ? 2 : 1;
for (int pass = 0; pass < passes; pass++) {
int want_relayed = (c->ring != NULL && pass == 0);
for (int p = 0; p < c->world; p++) {
...
if (c->ring != NULL && (ring_relayed(c, p) != 0) != want_relayed) {
continue;
}
if (post_striped(c, p, send, remote_off, nbytes / 16, flag_off, seq, 0) != 0) {
post_striped dispatches relayed peers into ring_post (:1141), which spins until mailbox credit returns (:1107-1116):
while (__atomic_load_n(ring_ack(c, c->rank, rail, slot), __ATOMIC_ACQUIRE) != prior) {
if (drain_all(c) != 0) return -1;
uint32_t* ctrl = (uint32_t*)(c->region + c->ctrl_off);
if (!atomic_load_explicit(&c->running, memory_order_relaxed) ||
__atomic_load_n(&ctrl[CTRL_ERROR], __ATOMIC_ACQUIRE)) {
Before this PR direct peers were posted first. At world=4 each rank has 2 direct + 1 relayed peer, so in the pass-0 ordering the direct writes to the two cable neighbours — the only transfers with no mailbox hop — are now issued only after the relayed peer's mailbox window has been waited out. When the window is contended (which is exactly the case F9's busier idle loop is trying to help), the one-shot path on every ring deployment is slower at posting its fast writes. Impact: a latency regression on the path ignition/preparation/collectives.py:52-58 deliberately chose because oneshot "is fastest for decode rows" — the exact path this PR claims to improve, for the traffic it does not replace. Fix: keep the pre-PR order (direct first), or only pre-post relayed peers when credit is already available (a non-blocking ring_post probe that falls back to deferring the relayed peer to a second pass); and declare the change either way.
F3 — MINOR (metric/observability): post_ring2_step skips the per-op drain and shifts completion counters
helios/native/roce_proxy.c:1368-1369:
c->ops_posted += 1;
return 0;
}
versus the file-wide convention at :1253-1254 (c->ops_posted += 1; return drain_all(c);) and :1698-1699. Consequences: (a) ring2 ops no longer harvest completions at the end of the op, relying instead on the idle loop (:1805) and reserve_limit's drain — a correctness-adjacent convention break, not a data-integrity bug, since the peer's flag write implies the local NIC consumed the payload; (b) hca->writes_completed / c->writes_completed (:824-825) now advance once per RING2_SIGNAL_STRIDE writes for ring2 traffic while bytes_posted still advances per stripe (:1326), so completion-to-byte ratios change meaning for ring2 without any label. Honest scope check: roce_stat( / roce_hca_stat( are exported from the C only (:1907, :1930) and are not declared in helios/src/execution/roce.rs:35-76 or consumed anywhere in helios/src, so there is no current downstream threshold being mispriced — this is an instrumentation defect, not a pricing bug. Fix: return drain_all(c); like every sibling, and either document the batched-completion semantics of writes_completed or increment it per WR.
2. Unintended System-Level Consequences
F4 — MAJOR: idle loop now services relays on every spin on every ring transport
helios/native/roce_proxy.c:1794-1814:
if (seq == c->last_seq) {
idle++;
if (c->ring != NULL) {
int ring2_active =
(c->last_kind == KIND_RING2_STEP1 || c->last_kind == KIND_RING2_STEP2);
if (!ring2_active || (idle & 15u) == 0) {
if (ring_service(c) != 0) {
atomic_store(&c->failed, 1);
return NULL;
}
}
if ((idle & 15u) == 0 && drain_cqs(c) != 0) {
Previously rings did one drain_all per 64 spins (:1809 still does this for non-ring). Now every idle spin on a ring runs ring_service, which iterates world × n_rail mailbox slots doing acquire loads on lines written by remote NICs (:1039-1050). Combined with ROCE_IDLE_SPINS 20000000 (:194) and F3/F5's CPU pinning (:1773), an idle ring deployment busy-polls remote-written cache lines on a pinned high-capacity core for 20 M spins before the first nanosleep. That is a real system-level consequence for every ring user (mesh unaffected), and it overlaps the goal of open PR #577 ("drain relays eagerly"). Fix: gate the eager servicing on "relay work pending" (a dirty flag or ring_pending scan) rather than on every spin, and declare the polling change.
F5 — MAJOR (undeclared scope): the #576 CPU-pinning/thread-naming hunk is carried verbatim
helios/native/roce_proxy.c:1769-1774:
static void* proxy_main(void* arg) {
roce_ctx_t* c = (roce_ctx_t*)arg;
#ifdef __linux__
(void)pthread_setname_np(pthread_self(), "flare-roce");
pin_high_capacity_cpus();
#endif
with pin_high_capacity_cpus() at :1702-1766 (reads /sys/devices/system/cpu/cpu%d/cpu_capacity at :1723, sched_setaffinity at :1764). The PR description does not mention it; it is unrelated to ring2; it is the identical hunk in open PR #576 and closed duplicate #633. Impact: whichever lands second conflicts in the same file, and #643 carries only the C helper, not #576's Rust-side calls, so its effect would be to pin the proxy thread alone while the description implies no such behaviour change. Fix: drop the hunk and let #576 land it (or split this PR).
F6 — MAJOR (undeclared scope): IBV_SEND_INLINE and max_inline_data 16→256 now apply to all pre-existing traffic, including mesh
helios/native/roce_proxy.c:496-515:
for (int l = 0; l < c->n_lane; l++) {
attr.cap.max_inline_data = 256;
hca->qp[p][l] = ibv_create_qp(hca->pd, &attr);
if (hca->qp[p][l] == NULL) {
attr.cap.max_inline_data = 16;
hca->qp[p][l] = ibv_create_qp(hca->pd, &attr);
}
...
if (attr.cap.max_inline_data < 8) {
and inline flags on the existing WRs: relay payload :915, relay descriptor :924, relay mark :1009, relay bell :932, one-shot flag :1168, one-shot data :1188, ring ACK :876. Only :1289/:1309 belong to the new kinds. The description declares only "per-HCA max_inline tracking". Impact: the ordinary one-shot path on every transport — mesh included, where c->ring == NULL and ring2 will never be used — now takes inline WRs sized up to 256 bytes, changing provider copy semantics, per-WR cost and completion behaviour with zero evidence in the PR. Verified safe detail worth stating: the fallback is guarded correctly — hca->max_inline folds to the minimum granted across a HCA's QPs (:513-515), and the 72-byte relay descriptor is conditional (:923), so a QP stuck at 16 is never handed an oversized inline WR. Fix: split the inline change out as its own measured PR, or declare it and scope it to ring2 WRs.
F7 — blast radius: one bad doorbell kills the rank group, and there is no preflight
See F8 below for the mechanism; the system-level point is that all three new failure modes (unknown op kind, ring2 on a non-4-rank/chain topology, WR-queue overflow) converge on the same terminal path, helios/native/roce_proxy.c:1864-1867:
if (rc != 0) {
atomic_store(&c->failed, 1);
return NULL;
}
which docs/roce-ring.md:370-372 documents as poisoning the executor. Nothing in this file isolates a ring2 failure from the rest of replay.
3. Architecture, Contracts & Charter Compliance
F8 — MAJOR: new wire contract with no ABI bump, no capability word, no negotiation, no preflight, no fallback
New kind values in the shared ctrl slot (helios/native/roce_proxy.c:173-174):
#define KIND_RING2_STEP1 5u
#define KIND_RING2_STEP2 6u
ROCE_ABI_VERSION remains 14 (:141) and roce_blob_t is unchanged, so helios/src/execution/roce.rs:131 still accepts it:
if !matches!(spec.proxy_abi, 9 | 10 | 11 | 14) || abi != PROXY_ABI {
A peer proxy built before this PR receives kind 5 and fails at :1860-1862:
} else {
snprintf(c->err, sizeof(c->err), "unknown op kind %u at seq %u", kind, s);
rc = -1;
}
Likewise a core whose kernels post kinds 5/6 but is served on a mesh or chain hard-fails rather than degrading (:1336-1341):
if (c->world != 4 || c->ring == NULL || c->ring_open) {
snprintf(c->err, sizeof(c->err),
"RoCE two-step ring op requires a 4-rank closed ring (world=%d, ring=%d, open=%d)",
c->world, c->ring != NULL, c->ring_open);
return -1;
}
Impact: the failure lands at the first collective of replay, after CUDA graphs are already restored and the executor believes the transport healthy — whereas everything else in this file is preflighted in roce_create/roce_connect and docs/roce-ring.md:368-369 promises "Before replay, the native transport checks the core's proxy ABI, collective region layout, and routing table." The description's "existing exported cores … load and serve unchanged" is true but is silent on the reverse direction (new core, old proxy) and on new core on a non-ring topology. Fix: add a capability word to roce_blob_t (as open PR #577 does for its window field) checked at connect, and a matching refusal in roce.rs::open before replay; keep post_ring2_step's topology check as a second line of defence but reach it at startup, not at op 1.
F9 — MAJOR: vendored-parity contract (the file's own stated rule) is broken with no upstream proxy revision named
helios/native/roce_proxy.c:6-8 and docs/roce-ring.md:360-364:
Flare vendors the serving proxy in `helios/native/roce_proxy.c`; preparation uses the pinned
FlashInfer dependency. When changing the protocol, keep the vendored source
identical to the dependency after its provenance header and verify their ABI
and collective-region layouts together.
New opcode values added in-tree only, with the PR citing local-inference-lab/flashinfer#192 as a kernel PR and no upstream proxy PR/revision. This is the same ground on which siblings #576/#577 were sent back, and the same author established the rule in merged #589 (ba3afb13). Fix: cite the FlashInfer proxy revision that defines kinds 5/6, or re-vendor from it.
F10 — Charters/process: the op-contract approval is not recorded
AGENTS.md:376-381:
- Introducing a captured-graph operation family requires prior explicit approval
from project owner Luke Alonso <lalonso@gmail.com>. Shape and capacity variants
of an existing family do not constitute a new type when its operation contract
stays unchanged. A new operation contract requires approval even if it reuses
an existing graph kind or enum value. A design acknowledgment does not grant
that approval.
Kinds 5/6 are a new operation contract (a new kind value with its own topology/size preconditions and completion semantics), not a shape variant. Stated honestly: the author is the named owner, so approval is plausibly self-granted — but the description does not record it, and downstream reviewers cannot distinguish "approved" from "assumed." Severity: Minor (process). Fix: one sentence in the description recording the approval, or the Design-Signed-Off-By digest check.
F11 — MAJOR: wrong-layer question on the b12x selection assumption
The change is correctly placed (transport proxy, no per-model branches), but it commits the runtime to world == 4 && ring && !ring_open as a hard precondition for a kernel family whose selection lives outside this repo (a hyperflare-recipes PR cited without a number, plus flashinfer#192). There is no in-repo issue asking for kinds 5/6 and no roadmap item covering it (dossier Open questions 1 and 3). Combined with F8's missing preflight, the runtime has no way to know whether the peer/proxy pair supports the contract before serving begins. Fix: at minimum make the precondition machine-checkable at startup (F8), so the coupling is explicit rather than discovered at op 1.
4. Tests & Claim Accuracy
F12 — MAJOR: the evidence standard is not met and the cited tests do not compile the changed code
Description: "RoceRing2AllReduceLaunch averages 31.8–33.0 µs/call across 88 calls/round" from node-level nsys. That is an absolute figure; there is no main/oneshot baseline, no delta, and no served-workload throughput. The charter requires: "Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)."
And the cited verification is not reproducible for this file:
- Rust crate tests (`cargo test --locked --release`): Passed on `helios` (`--features runtime-core,server`), `flare`, and `flare-cli`.
helios/native/roce_proxy.c compiles only under the roce feature (helios/Cargo.toml:27, helios/build.rs:67-77), so --features runtime-core,server does not build it. docs/roce-ring.md:381-384 gives the command that does:
cargo test --manifest-path helios/Cargo.toml --features roce \
--lib execution::roce::tests
No ring2 test was added anywhere (the only occurrences of ring2 in the repo are in roce_proxy.c), and the crate's ABI/preflight tests would not exercise kinds 5/6.
Impact: "CI passed" and "cargo test passed" both mean the C was not compiled; the only support for correctness is an external trace on hardware the reviewer cannot inspect. Fix: run and report --features roce --lib execution::roce::tests; add a host-side preflight/conformance test for the new reject conditions (world != 4, chain, non-multiple-of-32, mixed capability); report the same op with an A/B against main's oneshot path on the same four Sparks, plus tok/s on the served workload.
F13 — MAJOR: operator-facing documentation not updated
docs/roce-ring.md:161-167 enumerates exactly what a proxy ABI 14 does and is the only place an operator learns what behaviour to expect:
Preparation and serving use proxy ABI 14. Its proxy holds eight packets in flight per sender and
rail in ring mailboxes that the runtime allocates at startup, serves the pipelined reduce-scatter
and shard-gather operations, connects four queue-pair lanes per rail, and exchanges start-of-op
credits between proxies.
Nothing in the document mentions kinds 5/6, the 2-step ring, the 32-byte alignment requirement, or the new WR budget; :349-353's qualification matrix (GLM-5.3 Flash TP4, four DGX Sparks) is also unchanged even though ring2 changes what a 4-rank ring does. Fix: one paragraph in "Protocol model and runtime checks" naming the two opcodes, their preconditions (world==4, closed ring, multiple of 32 bytes), and the selection path in the core.
F14 — MINOR: ring2 requires 32-byte payloads where the existing path accepts 16
helios/native/roce_proxy.c:1342:
if (nbytes == 0 || (nbytes % 32) != 0 || nbytes > c->slot_bytes) {
versus :1227:
if (nbytes == 0 || nbytes % 16 != 0 || nbytes > c->slot_bytes) {
Message sizes that are legal for oneshot today (multiple of 16, not 32, e.g. 16B or 48B packs) cannot use ring2 and fail the transport (F8) rather than falling back. Fix: state the constraint in docs (F13) and, for a size that fails it, either reject at startup per-geometry or fall back to oneshot.
Verified sound (no finding)
ring_relays_origin[]is computed aftern_rail,ring,ring_openare all fixed and matchesring_next_fromfor both the cycle and the chain case (an endpoint origin correctly relays nothing) —roce_proxy.c:734-751vs:337-350; honoured at:1041-1042.- Flag ordering within one step is safe: the lo and hi halves go to two different peers (
:1353-1354), so no QP receives two distinct flag writes to one address in a step, and the per-rail payload→flag chain (data_wr.next = &flag_wr,:1304) is preserved.:1004-1016keeps the same ordering for relayed forwards. - Bounds on the split are sound:
half_bytes/half_packscome fromnbytes/2andnbytes/32(:1355-1356), and the hi half targetsremote_off + half_bytesinside the neighbour's slot becausenbytes <= c->slot_bytesis checked first (:1342,:1358-1359,:1361-1367). - Existing kinds 0..4 and
roce_blob_tare untouched, andROCE_ABI_VERSIONstays 14, so previously exported cores still load (the failure mode is the new core / old proxy direction, F8). max_inlinefolding and the 8-byte fatal minimum (:507-515) correctly prevent an inline WR larger than a QP's grant, including the 72-byte relay descriptor guard at:923.
Open questions / could not verify
- Which upstream FlashInfer revision or PR defines
KIND_RING2_STEP1/2,post_direct_striped_batched,RING2_SIGNAL_STRIDE, the inline changes andpin_high_capacity_cpus()?local-inference-lab/flashinferis not searchable from here; without it F9 cannot be closed. - The baseline: what does the same collective cost on
main's oneshot path on the same 4× DGX Spark? The PR gives only 31.8–33.0 µs/call (F12). - Whether the branch commit carries a current
Design-Signed-Off-Bydesign-review digest (not visible from the PR page), and whether the owner's approval for the new op contract (F10) is recorded anywhere. - Whether flashinfer#192 and the unnumbered recipes transmission-selection PR are merged; both determine whether kinds 5/6 are ever posted.
- Whether
IBV_SEND_INLINEat 256 bytes is a win or a loss on the CX7/GB10 provider — the PR does not measure it, and it now applies to mesh deployments that will never use ring2 (F6).
Suggested review outcome and fix ordering
Request changes. Order: F1 (can poison a live ring under load) and F2 (regresses the existing one-shot path) block; F5/F6 are trivially separable and shrink the PR to its declared content (drop the pinning hunk for #576, split the inline change); F8/F9 need the upstream proxy reference plus a blob capability word and a roce.rs preflight; F12/F13 need a --features roce test run, a main baseline and a docs paragraph. F4, F3, F14, F10 are declaration/measurement/documentation fixes.