Correctness, Contracts & System-Level Consequences review — PR #672
PR: https://github.com/NVIDIA/hyperflare-inference/pull/672 · author nepenth (FIRST_TIME_CONTRIBUTOR) · head c582b10 · 4 files, +187/−40.
Verdict: request changes. The change addresses a real defect at the right layer and the per-HCA plumbing is internally correct, but it does not close the failure class it cites, changes a public contract silently, breaks a repository invariant restored one day earlier, and ships its riskiest hunk with zero executable coverage.
Key findings
| # | Severity | Finding |
|---|---|---|
| F1 | Major | The fix is one-sided: serving becomes per-HCA while preparation still opens every HCA at one host-wide index, so the prep/serving rail-count mismatch the PR blames can now invert (roce_fabric.rs:1025, roce.rs:152-162, ignition/preparation/collectives.py:83, heliopause/src/python.rs:698-699). |
| F2 | Major | Fabric::gid_index silently changed meaning to "first device's index" (roce_fabric.rs:430); its field doc, the roce_gid_index() doc contract, the doctor's terminal Warn text and the three docs pages AGENTS.md:234 requires are all stale. |
| F3 | Major | The native edit forks the vendored roce_proxy.c one day after #643 restored byte parity, with no upstream revision cited, NOTICE still claiming "unchanged", and PROXY_ABI left at 14. |
| F4 | Major | The per-HCA FFI branch and its silent length-mismatch fallback (roce.rs:199-203) are never executed by CI or any test; the PR's verification lines are unreproducible and the hardware evidence carries no command, counts or logs. |
| F5 | Minor | Silent unwrap_or(self.gid_index) degradation in gid_index_for/topology, plus two specific coverage gaps in the new tests. |
| F6 | No issue | The per-HCA SGID path is correct and symmetric; there is no concurrency, memory, latency, failure-propagation or cross-platform regression. |
Scope, and the PR's before/after claim (verified accurate)
Files inspected in full context: helios/src/execution/roce_fabric.rs (discovery 386-476, Fabric 221-228/1006-1044, Topology 306-321, encode/decode 531-638, new test 1181-1218), helios/src/execution/roce.rs (FFI 35-76, open 124-244, tests 369-405), helios/native/roce_proxy.c (provenance 1-12, structs 250-266, roce_layout 359-401, open_hca 450-470, roce_create* 528-601, connect_qp 672-686, hot path 1250-1266) and roce_proxy_dlopen.c. Callers/contracts traced: flare-cli/src/cluster.rs, flare-cli/src/fabric.rs, flare-cli/src/doctor/spark.rs, heliopause/src/python.rs:686-704, ignition/preparation/collectives.py:40-90, helios/src/execution.rs:14-20, NOTICE:10-22, docs/roce-ring.md, docs/cli-design.md, docs/multi-host.md, AGENTS.md:225-238, .github/workflows/native-serving.yml:101-113 (not opened).
The description's "Previously …" paragraph is truthful. main picked one host-wide index and then filtered devices by it, dropping any HCA whose IPv4 RoCEv2 GID sat elsewhere. Head instead picks per device:
// helios/src/execution/roce_fabric.rs:407-431
let pick_gid_index = |name: &str| {
if roce_v2_ipv4(name, PREFERRED_GID_INDEX) {
Some(PREFERRED_GID_INDEX)
} else {
(0..GID_TABLE).find(|&index| roce_v2_ipv4(name, index))
}
};
...
let gid_index = devices[0].1;
let gid_indices: Vec<u32> = devices.iter().map(|(_, gid, _)| *gid).collect();
Every item in the "What Changed" list is present in the diff. The defect is in what the change leaves out and in Verification, not in the change description.
F1 — MAJOR: the fix is one-sided; it removes one direction of the rail-count mismatch and can invert it
Citations: helios/src/execution/roce_fabric.rs:1025; helios/src/execution/roce.rs:152-162; ignition/preparation/collectives.py:83; heliopause/src/python.rs:692-699; helios/native/roce_proxy.c:1259.
Rails are derived from the merged kept-device set, and that set is exactly what this PR enlarges:
// helios/src/execution/roce_fabric.rs:1025
let rails = endpoints.iter().map(Vec::len).min().unwrap().min(MAX_RAILS);
Before #672 a mixed-index host dropped the HCA at the unshared index, so rails was 1 there; now both HCAs survive and rails becomes 2 — the PR's own new test asserts this (roce_fabric.rs:1216-1217: assert_eq!(topology.rails, 2); assert_eq!(topology.gid_indices, vec![3, 5]);).
Preparation was not changed. It still opens every active device at a single host-wide index:
# ignition/preparation/collectives.py:80-85
# Each host uses the GID index native serving discovers for it.
runtime = roce.AllReduce(exchange_group=group, device=device, max_size=nbytes, max_gather_bytes=gather_bytes,
pipe_bytes=pipe_bytes, region_allocator=region,
gid_index=flare_heliopause.roce_gid_index(),
roce_gid_index() returns fabric.gid_index (heliopause/src/python.rs:698-699), which is now devices[0].1 (roce_fabric.rs:430) — not any host-wide rule (see F2). On the PR's own 2×GB10 example (roce_fabric.rs:1186-1201: index 3 on one HCA, 5 on the other) preparation receives 3 and asks b12x to open the second HCA at index 3, which is that HCA's link-local IPv6 GID, while serving plans two rails at 3 and 5.
Rail count is load-bearing in the captured kernels' addressing:
// helios/native/roce_proxy.c:1259-1260
uint64_t flag_off = c->flag_off + ((uint64_t)c->rank * ROCE_SLOTS + slot) * (uint64_t)c->n_rail *
ROCE_FLAG_STRIDE;
and preflight never compares it against what preparation compiled:
// helios/src/execution/roce.rs:152-162
if (topology.shape.relays() && !(2..=16).contains(&spec.world))
|| topology.routes.len() != spec.world
|| !(1..=super::roce_fabric::MAX_RAILS).contains(&topology.rails)
{
return Err(failure(format!(
"RoCE topology does not match the core's ranks: {} routes and {} rails for {} ranks",
The preceding layout check compares only ctrl_offset and region_bytes (roce.rs:147), and the layout computation (roce_proxy.c:359-401) is not parameterized by rail count, so no existing check can detect an N-vs-M rail disagreement.
Impact: a core prepared with N rails served with M ≠ N rails is precisely the flag-offset/rail-count divergence the PR description blames for the "sequence 1" collective timeout. The PR eliminates one direction of that mismatch and silently enables the other, on exactly the mixed-index hosts it targets.
Fix: either make preparation consume the per-HCA indices (expose a name→index map or a roce_gid_indices() alongside roce_gid_index() and pass it to roce.AllReduce), or fail fast: have RoceTransport::open reject a rail count that differs from the core's recorded geometry. In either case the PR description must say which half remains open.
F2 — MAJOR: Fabric::gid_index silently changed meaning; its doc, its Python contract, the doctor fallback and the required docs are stale
Citations: helios/src/execution/roce_fabric.rs:221-228, :430; heliopause/src/python.rs:692-699; flare-cli/src/doctor/spark.rs:250-255; docs/cli-design.md:1695-1698, :1712-1714; docs/roce-ring.md:333-342; AGENTS.md:234.
The field used to mean "the host's chosen index"; it now means "whatever index the first device in sorted name order happens to use":
// helios/src/execution/roce_fabric.rs:430
let gid_index = devices[0].1;
The field's own doc comment was not updated:
// helios/src/execution/roce_fabric.rs:221-228
/// This host's RoCE devices in name order, and the GID index and traffic class they use.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Fabric {
pub gid_index: u32,
pub gid_indices: Vec<u32>,
The one outside consumer still documents and depends on the old rule:
// heliopause/src/python.rs:692-699
/// This host's RoCE GID index by the rule native serving uses: 3 when every active device has a
/// RoCEv2 IPv4 GID there, otherwise the lowest index at which one does.
#[pyfunction]
fn roce_gid_index() -> PyResult<u32> {
...
crate::execution::roce_fabric::discover()
.map(|fabric| fabric.gid_index)
Both the sentence and the invariant it states are now false, and the PR description does not mention having changed them. The doctor's terminal Warn path also still reports a single number:
// flare-cli/src/doctor/spark.rs:252-255
Ok(fabric) => format!(
"discovery could not verify a local IPv4 address and prefix on a ConnectX-7 device at RoCEv2 GID index {}",
fabric.gid_index
),
Stale documentation this PR leaves behind, despite AGENTS.md:234 ("Change Orbit, host agents, or multi-host preparation, serving, or transport → Orbit, multi-host serving, and the RoCE ring"): docs/cli-design.md:1695-1698 ("The report uses serving's RoCEv2 GID index", singular) and :1712-1714 ("RoCEv2 GID index 3"); docs/roce-ring.md:333-342 (--gid-index, one per host); docs/multi-host.md:42-43 and :102-130. None were touched by the diff.
Impact: a public Python contract consumed by preparation now returns a value whose documented meaning is wrong, and operators reading a mixed host's Warn line get one arbitrary index. Anyone re-deriving preparation's behaviour from roce_gid_index() gets a different answer than the documented one.
Fix: rename/redocument the field (e.g. first_gid_index, or drop it once preparation is per-HCA), rewrite python.rs:692-693, make the doctor Warn path use gid_index_for/the indices list or say "per-HCA indices", and update the four doc locations above.
F3 — MAJOR: the vendored-parity invariant is broken without an upstream revision or an ABI bump
Citations: helios/native/roce_proxy.c:6-8, :259, :461, :531-601, :680; helios/native/roce_proxy_dlopen.c:7-9; NOTICE:16-19; docs/roce-ring.md:360-364; helios/src/execution/roce.rs:23.
// helios/native/roce_proxy.c:6-8
// Vendored from FlashInfer's pinned preparation dependency
// (flashinfer/experimental/b12x/comm/roce/_roce_proxy.c (not opened), proxy ABI 14).
// Keep the source below identical so preparation and serving share the transport ABI.
// helios/native/roce_proxy_dlopen.c:7-9
// ... while
// keeping the vendored roce_proxy.c byte-for-byte identical to FlashInfer.
# docs/roce-ring.md:360-364
because its GPU kernels and C proxy define the protocol. 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.
# NOTICE:16-19
helios/native/roce_proxy.c was contributed by its original author from:
https://github.com/local-inference-lab/flashinfer/blob/f5f5341d.../_roce_proxy.c
The proxy is compiled into Linux aarch64 builds. Its implementation is unchanged
from that revision; Flare adds a license and provenance preamble.
#672 edits roce_hca_t (new int gid_index at :259), open_hca (:461 now queries hca->gid_index), connect_qp (:680 rtr.ah_attr.grh.sgid_index = (uint8_t)hca->gid_index;), and adds the exported roce_create_with_gids (:531), keeping roce_create as a wrapper (:587-601). No upstream FlashInfer revision or patch URL appears anywhere in the diff or description; NOTICE still asserts the implementation is unchanged; and the exported surface grew while pub const PROXY_ABI: u32 = 14; (roce.rs:23) did not move.
This is not bookkeeping. Preparation keeps using the pinned upstream b12x proxy while serving uses this fork, so any divergence in SGID selection between the two is exactly the class of bug being fixed; and #643 (merged 2026-11-30) existed solely to restore byte parity, with #649 currently blocked on that invariant.
Impact: the next re-vendor (#643-style) or the next ABI series (#279/#643/#649) must reconcile an unnoted divergence, and NOTICE is now factually wrong about third-party code the project redistributes.
Fix: land the same change upstream in FlashInfer and re-vendor at a named revision, updating the provenance header and NOTICE:16-19; or bump PROXY_ABI, describe the divergence in docs/roce-ring.md:161/:360-364, and obtain the owner sign-off the charter's #215/#404 rules imply. At minimum cite the upstream commit in the description.
F4 — MAJOR: the per-HCA branch and its fallback are never executed by CI or any test; the verification claims are unreproducible
Citations: .github/workflows/native-serving.yml:101-113 (not opened); helios/src/execution.rs:16-17; helios/src/execution/roce.rs:199-203, :394-397; helios/native/roce_proxy.c:587-601; docs/roce-ring.md:381-384.
CI only compiles the feature; it never runs the suite the docs prescribe:
# .github/workflows/native-serving.yml:109-113 (not opened)
- name: Compile experimental RDMA
run: |
cargo check --locked --manifest-path selene/Cargo.toml (not opened) --tests --features rdma
...
cargo check --locked --manifest-path flare-cli/Cargo.toml --tests --features roce,rdma
# docs/roce-ring.md:381-384
cargo test --manifest-path helios/Cargo.toml (not opened) --features roce \
--lib execution::roce::tests
and the module itself is gated, so roce.rs never runs in the non-roce jobs either:
// helios/src/execution.rs:16-17
#[cfg(feature = "roce")]
pub mod roce;
The untested logic is the new per-HCA dispatch and its silent fallback:
// helios/src/execution/roce.rs:199-203
let gid_indices: Vec<c_int> = if topology.gid_indices.len() == pointers.len() {
topology.gid_indices.iter().map(|&g| g as c_int).collect()
} else {
vec![topology.gid_index as c_int; pointers.len()]
};
The only test fixture sets gid_indices: Vec::new() (roce.rs:394-397), so every existing test permanently exercises the fallback and nothing ever exercises a non-empty vector at this layer — including the u32 → c_int → (uint8_t) narrowing at roce_proxy.c:680. The retained roce_create wrapper (roce_proxy.c:587-601), described as "backward-compatible", has no in-tree caller: roce.rs:205 now calls roce_create_with_gids and grep finds no other reference, so the compatibility claim is neither compiled nor exercised in-tree.
Claim accuracy: the description's two cargo test … lines render with their inline code spans blanked (identifiers missing), so the commands cannot be reproduced from the PR at all; no --features roce run is claimed; the hardware paragraph gives no command, crate/feature set, counts, baseline, core id or logs. AGENTS.md:103-112 requires each claim tied to command, configuration and result, and docs/design-review.md:252-259 makes live multi-GPU execution mandatory for helios/src/execution/roce* changes — claimed narratively, not demonstrated.
Fix: add cargo test --features roce --lib execution::roce::tests to the rdma job (libibverbs/rdmacm dev packages are already installed at native-serving.yml:105-108), add a unit test that feeds a populated gid_indices through open's dispatch (and one for the mismatch), and quote the exact commands and counts in the description.
F5 — MINOR: silent degradation and specific test gaps
- Silent fallback masks truncation.
helios/src/execution/roce_fabric.rs:1009-1011:
Same pattern inpub fn gid_index_for(&self, index: usize) -> u32 { self.gid_indices.get(index).copied().unwrap_or(self.gid_index) }Fabric::topology(:1027-1031,if self.gid_indices.len() == self.endpoints.len() … else vec![self.gid_index; …]). A truncated vector silently reintroduces the old single-index behaviour instead of erroring. Unreachable in-tree today (discover_inpopulates both vecs in lockstep,:431and:434-469), so this is a latent hazard: adebug_assert_eq!or an explicit error on a non-empty-but-mismatched vector would be safer. - Coverage gap in the new fabric test.
roce_fabric.rs:1186-1201covers only "index 3 invalid on the second HCA". It never covers "index 3 valid on both HCAs while an additional IPv4 GID exists at a higher index on one" — i.e. thePREFERRED_GID_INDEXpreference branch interacting with per-HCA divergence — nor two rails that share an IPv4 subnet. - Coverage gap in the new doctor test.
flare-cli/src/doctor/spark.rs:545-565writesgid_attrs/ndevs/{gid}at exactly one index per device, so it cannot detect a regression where the doctor reads the wrong index on an HCA that also holds a valid GID at index 3. - Not an issue (checked):
ready_gids[0](spark.rs:187-188) is guarded byif !ready.is_empty()(:181) and pushed in lockstep withready(:172-179) — no panic. Discovery's per-device scan (pick_gid_index,roce_fabric.rs:407-413) costs up toMAX_DEVICES × GID_TABLE × 2sysfs reads instead of one shared index scan, but discovery runs once per rank start and once perflare doctor, so it is not a hot path.
F6 — No issue: the plumbing, system-level behaviour and platform parity are sound
State this plainly so it is not re-litigated:
- Local-only, symmetric SGID selection.
gid_indicesis populated one entry per endpoint (roce_fabric.rs:431, endpoints built from the samedevicesvec at:434-469) and is rank-local (Topologyis built fromself.gid_indices,:1027-1035);roce.rs:199-203indexes it by local HCA,roce_proxy.c:577assignsc->hca[h].gid_indexbeforeopen_hca(:578) queries it (:461), andconnect_qpsets only the localsgid_index(:680) while the destination GID still comes from the peer's blob (:679). Both ends may legitimately differ;roce_blob_tis unchanged. - No wiring/ordering bug. The per-HCA assignment precedes use (
:577vs:461), and the new0..=255validation (:544-549) is stricter than the previous uncheckedint. - No hot-path cost. The new
Vec<u32>/Vec<c_int>are one-shot at transport open; the proxy's posting thread, ring/mailbox and flag layout are untouched; no new lock, buffer, copy or retention. - No failure-propagation change. Mixed-build compatibility is unaffected in the sense that the rendezvous
encode/decode(roce_fabric.rs:531-638) is unchanged, so a rank without #672 pairs up and then disagrees about rail count rather than being rejected — which is F1's blast radius, not a separate defect (note that #232 added an explicit guard for a comparable hazard; this PR adds none). - Platform parity unaffected.
Fabric/Topologyuse is Linux-gated androce_gid_indexreturns an error off-Linux (python.rs:702-703); nothing in the diff touches Windows/native paths.
Open questions / not verifiable from the repository
- Does
c582b10carry a validDesign-Signed-Off-By: <identity>; design-review=<4 hex>trailer required bydocs/design-review.md:298? It could not be confirmed. - Which exact
cargo testinvocations were run, and did any enable--features roce(i.e. execute the FFI path)? - Was the corresponding FlashInfer upstream change for
roce_create_with_gidssubmitted, and at which revision? The provenance header andNOTICEstill claim byte identity. - Is preparation intended to become per-HCA?
roce_gid_index()andignition/preparation/collectives.py:83are untouched and no follow-up is mentioned. - Does this close #151? The PR links no issue. #151's rails both sat at GID index 3, so per-HCA divergence does not explain that environment; the hardware paragraph reads like the retest original-el8 requested but is not posted there. Closure is unproven, and #143 (prep-side, still open) is not fixed by this PR.
Concrete asks before merge
- Make preparation consume per-HCA indices, or fail fast on a rail-count mismatch with the core's recorded geometry; document which half of the defect class remains open.
- Rename/redocument
Fabric::gid_index, rewriteheliopause/src/python.rs:692-693, fix the doctor's Warn text, and updatedocs/multi-host.md,docs/roce-ring.mdanddocs/cli-design.mdperAGENTS.md:234. - Re-vendor from a named upstream FlashInfer revision (updating
NOTICE), or bumpPROXY_ABIwith owner sign-off and describe the divergence. - Add a
cargo test --features roce --lib execution::roce::testsCI leg plus a per-HCA-branch test, and quote exact commands and counts in the description.