#672 — Correctness, Contracts & System-Level Consequences review
Important tooling caveat first (affects every citation below). pr_files/pr_diff still return the stale c582b10 diff (4 files, +187/−40) and read_file without an explicit ref served me an older revision (helios/src/execution/roce.rs 531 lines, Fabric still carrying a scalar gid_index). Calling read_file with ref: pr/672 returns the real head (roce.rs 601 lines, roce_fabric.rs 2217 lines). Every citation below is from ref: pr/672 or from a search_code run at that ref. The real change spans ≥7 files, not the 4 the tool reports.
Key findings
- Major — Preparation still branches on the installed FlashInfer build, and the fallback preserves the very prep/serving divergence this PR fixes.
ignition/preparation/collectives.py:81-93sniffsroce.AllReduce.__init__forgid_indices; theelsebranch passes one scalar fromflare_heliopause.roce_gid_index(), which is the first device's index. With FlashInfer tracked atmain(pyproject.toml:47), mixed-index hosts (3 + 5) prepare 1-rail kernels while serving connects 2 rails. - Major — The new C/FFI and preflight behaviour is never executed in CI. The only
roce-featured job iscargo check(.github/workflows/native-serving.yml:113(not opened)); helios tests run--features runtime-core,server(:63) whilepub mod roceis#[cfg(feature = "roce")](helios/src/execution.rs:16-17).roce_create_with_gids_rejects_null_and_out_of_range_gid_indices(roce.rs:537) is human-run-only proof. - Major — Vendored byte-identity with
flashinfer#209is asserted, not verifiable in-repo, and this PR now adds an exported symbol to that file. If upstream_roce_proxy.c(not opened) differs, prep and serving compile different proxies under the samePROXY_ABI14. - Minor —
roce_createis now dead ABI surface (roce_proxy.c:585-595): no in-tree caller, kept only for upstream parity. - Minor — Docs parity gap:
docs/cli-design.md:1696-1697was updated, but the per-device index change and the prep caveat are absent fromdocs/multi-host.md. - Sound (stated plainly): alignment of HCA ↔ GID index across every layer; index locality (no wire/ABI change); C guard ordering before allocation; doctor Pass and Warn paths; no concurrency, hot-path, memory-amplification or failure-blast-radius regression; no metric/rate/admission span change.
1. Correctness, Safety & Platform Parity — sound
1.1 Index alignment is consistent end to end (verified). Discovery builds the device list and the index vector in one pass, name-sorted, so entry i always pairs with device i:
helios/src/execution/roce_fabric.rs:407-425 (pr/672):
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))
}
};
with roce_fabric.rs:429 let gid_indices: Vec<u32> = devices.iter().map(|(_, gid, _)| *gid).collect(); — same devices iterator that produces endpoints, so the two vectors cannot desynchronise.
The old silent-fallback hazard is gone. Topology no longer carries a scalar, and open hard-rejects before touching the region — helios/src/execution/roce.rs:181-187 (pr/672):
if topology.gid_indices.len() != topology.hcas.len() {
return Err(failure(format!(
"RoCE topology has {} GID indices for {} HCAs",
topology.gid_indices.len(),
topology.hcas.len()
)));
}
and the conversion has no else arm — roce.rs:206:
let gid_indices: Vec<c_int> = topology.gid_indices.iter().map(|&g| g as c_int).collect();
Fabric likewise has a single source of truth — roce_fabric.rs:224-228 (pr/672):
pub struct Fabric {
pub gid_indices: Vec<u32>,
pub traffic_class: u32,
pub endpoints: Vec<Endpoint>,
}
This closes the earlier High finding that a scalar was silently repeated across HCAs. Sound.
1.2 Index locality is correct, so no wire/ABI change is needed (verified). The SGID index never crosses the wire: only the peer's GID value travels (roce_proxy.c:239, :644), and sgid_index is applied locally on the local QP (roce_proxy.c:674). Because the index is a local table address, ranks genuinely need not agree on it — the premise of this PR. PROXY_ABI remains 14 (roce.rs:23; roce_proxy.c:141), and helios/proto/runtime_core.proto:734-736 explicitly reserves 11..15 as "Formerly the preparing hosts' devices, GID index…". No proto change, no owner sign-off required. Correct.
1.3 C guard ordering is right (verified via notes on roce_proxy.c:537-549). The NULL and 0..=255 checks precede calloc, region access and every libibverbs call:
gid_indices == NULL || traffic_class < 0 || traffic_class > 255 || n_lane < 1 ||
...
if (gid_indices[h] < 0 || gid_indices[h] > 255) {
snprintf(err, err_len, "invalid roce gid index %d for HCA %d", gid_indices[h], h);
and the per-HCA index is threaded to open_hca(c, h, hca_names[h], gid_indices[h]) (roce_proxy.c:576), ibv_query_gid (:461) and connect_qp (:674). The former write-only roce_ctx_t.gid_index is gone. Sound; no error-handling or panic gap.
1.4 Platform parity. All of this is Linux sysfs + libibverbs; Windows/non-RoCE paths are untouched and roce.rs keeps the dlopen-only libibverbs.so.1 requirement with its install hint test (roce.rs:518-529). No cross-platform regression.
1.5 Metrics/observability span check. The only observable string change is the doctor detail, from "at RoCEv2 GID index {n}" to a format_gid_indices label (flare-cli/src/doctor/spark.rs:190, :246, :259). No rate, latency, or admission metric changed its sampled span or scope anywhere in this PR — nothing in inbound_rate/estimated_seconds-class fields is touched. No finding.
2. Unintended system-level consequences — no regression found
- Hot path untouched. Discovery runs once at startup;
pick_gid_indexreads at most two extra sysfs leaf files per HCA when index 3 is not the answer (roce_fabric.rs:407-412), bounded byMAX_DEVICES = 4andGID_TABLE = 16. The posting thread, queue-pair geometry, region layout and the ring/mesh service loops are unchanged. - No new locking, coalescing or buffering. The added validation is O(n_hca ≤ 4) on a cold path. No memory amplification: the only new allocation is a
Vec<c_int>of ≤4 elements. - Failure blast radius unchanged.
RoceTransport::openstill writes the region to zero only after all preflight checks (roce.rs:198,:203-205), and the new length check sits with the other preflight rejects, so a malformed topology still fails before any DMA registration. Theroce_createfailure path still destroys the context on ring-setup error (roce.rs:231-237). - Invariant check. Nothing here reverses a recently merged feature; it aligns serving with the per-rail topology that #369/#506/#666 already assume. No system-level finding.
3. Architecture, Contracts & Charter Compliance
Finding 1 — Major: preparation sniffs the installed b12x API, and FlashInfer is not pinned
ignition/preparation/collectives.py:81-93:
# aligned `hca_names` and `gid_indices` when the pinned b12x RoCE runtime supports them
import inspect
gid_kwargs: dict[str, object]
if "gid_indices" in inspect.signature(roce.AllReduce.__init__).parameters:
devices = flare_heliopause.roce_devices()
gid_kwargs = {
"hca_names": [name for name, _ in devices],
"gid_indices": [gid for _, gid in devices],
}
else:
gid_kwargs = {"gid_index": flare_heliopause.roce_gid_index()}
pyproject.toml:47 tracks FlashInfer branch = "main", not a revision.
Impact. Two live preparation code paths are selected by whatever library happens to be installed, with no test in this repo reaching create_roce_runtime. On the scalar path roce_gid_index() returns only the first device's index (heliopause/src/python.rs:693-706, delegating to the first entry of fabric.gid_indices), so on the exact dual-CX7 host this PR targets (indices 3 and 5) preparation opens both HCAs at index 3 while RoceTransport::open now genuinely uses 3 and 5. The n_rail flag-offset mismatch the earlier review described is therefore only closed once flashinfer#209 is pinned — the PR's own summary claim ("Pass aligned hca_names and gid_indices into roce.AllReduce during preparation") is conditional and the description does not say so. This is also a direct "no magic defaults / pin everything" violation (charter #215).
Fix. Pin the flashinfer revision that carries gid_indices and delete the inspect.signature branch; or, if the fallback must stay for one release, state in the PR body and docs/multi-host.md that prep/serving divergence persists on mixed-index hosts until the pin lands, and add the caveat next to the comment that currently reads "when the pinned b12x RoCE runtime supports them" (it is not pinned).
Finding 2 — Major (evidence): CI never executes the new C/FFI or preflight paths
The only roce invocation in .github/workflows/native-serving.yml (not opened) is cargo check … --features roce,rdma at :113; helios tests run with --features runtime-core,server at :63. pub mod roce is #[cfg(feature = "roce")] (helios/src/execution.rs:16-17), so CI compiles the module but never links or runs it.
Impact. roce_create_with_gids_rejects_null_and_out_of_range_gid_indices (roce.rs:537), the length-mismatch preflight (roce.rs:181-187, exercised as a case of rejects_incompatible_core_and_routes_before_modifying_region) and native_proxy_abi_matches_core_contract are green only when a human types --features roce. The description's helios command as recorded omits --features roce, so that exact quoted command cannot produce the quoted 35 passed.
Fix. Add a Linux step cargo test --manifest-path helios/Cargo.toml --features roce --lib execution::roce — libibverbs-dev is already installed earlier in the same job (:108).
Finding 3 — Major (contract): vendored parity is asserted, not verifiable, and this PR adds a symbol to the vendored file
helios/native/roce_proxy.c:6-8 claims byte-identity with FlashInfer's _roce_proxy.c (not opened) after the 9-line header; docs/roce-ring.md:362-363 states the rule ("keep the vendored source identical to the dependency after its provenance header"). There is no submodule, checksum or copied third_party source in the tree.
Impact. roce_create_with_gids is a new exported symbol in the vendored file (roce_proxy.c:531-593). If flashinfer#209 has not landed, or lands with any divergence, preparation (collectives.py per-HCA path) and serving compile different proxies under the same PROXY_ABI 14 — exactly the mixed-build hazard this repo's vendoring rule exists to prevent. Also relevant to open #577, which concurrently edits the same vendored file (disjoint hunks; the second lander must rebase and re-vendor).
Fix. Cite the flashinfer#209 merge SHA in the PR and record a checksum of the vendored body, or land #209 first and re-vendor from the merged commit.
Finding 4 — Minor: roce_create is now dead ABI surface
roce_proxy.c:585-595 reduces roce_create to a shim that fills gids[ROCE_MAX_HCAS] with the scalar and delegates; the Rust side declares only roce_create_with_gids (roce.rs:46-61) and no in-tree caller exists. Impact: an exported entry point kept solely for upstream parity, undocumented as such, so a future "cleanup" PR could delete it and silently break byte-identity. Fix: add a one-line comment that it exists only to match the vendored upstream.
Finding 5 — Minor: docs are partially updated
docs/cli-design.md:1696-1697 now says "serving's per-device RoCEv2 GID indices", matching spark.rs:161-190. But docs/multi-host.md mentions IPv4 RoCEv2 GIDs only generically (:42, :565) and says nothing about per-device indices or the preparation caveat in Finding 1. Fix: one paragraph in docs/multi-host.md.
4. Tests & Claim Accuracy
Accurate claims.
- The 35-test count checks out: the
execution::rocefilter is a prefix match, so it also selectsroce_fabric::tests— 7 tests inroce.rs(:409, :414, :438, :462, :494, :517, :537) plus 28 inroce_fabric.rs= 35. - The doctor test exists and is meaningful:
cx7_readiness_handles_distinct_per_hca_gid_indices(spark.rs:550) adds a decoy index-3 IPv6 entry onroce1and asserts the decoy is not used, plus aWarn-path assertion — closing the earlier "Warn prints one scalar" gap (format_gid_indicesis used at bothspark.rs:190and:246). - The discovery test
mixed_per_hca_gid_indices_discover_both_ipv4_rails(roce_fabric.rs:1189-1219) and the per-HCA preference test (:1221-1253, index 3 beating a lower index 1) directly cover the regression, andtopology.gid_indices == vec![3, 5]is asserted at:1217. - The doctor detail string in the description matches the code.
Inaccurate / unverified claims.
- The quoted helios command cannot execute the FFI test without
--features roce(Finding 2), so the stated evidence is not reproducible as written. - "Pass aligned
hca_namesandgid_indicesintoroce.AllReduceduring preparation" is conditional on an unpinned dependency (Finding 1). - Hardware verification ("2 of 2 active CX7 devices … [3, 5]") is not reproducible from the record and no log is linked.
What is sound, plainly
The core of this change is correct and at the right layer: per-HCA GID selection localised to discovery, a single gid_indices source of truth, a hard preflight reject instead of a silent fallback, per-HCA sgid_index application in the C proxy, and doctor output that reports mixed indices on both the pass and warn paths. I found no concurrency, ordering, contention, memory-amplification, failure-propagation, deadlock or metric-span defect in anything this PR touches.
Open questions / not verifiable from here
- Is
local-inference-lab/flashinfer#209merged, at what SHA, and ishelios/native/roce_proxy.cafter its 9-line header literally identical to it? - Is
pyproject.toml:47stillbranch = "main"(Finding 1 depends on it)? - Did the description actually get updated with
--features roceand the 35-test count? My local copy of the description predates the push andread_itemstill shows the old body. - Did the rebase force-push, i.e. is
c582b10gone from the branch? (It changes which citations downstream adjudicators should trust.) - Has the 90-minute auto re-review fired on the new head, with what verdict? Still zero human reviews; labels unchanged (
area:rocenante, bug, priority:P2, triage:review); noDesign-Signed-Off-By. - #151 remains
triage:verify-for-closureand unlinked — worth linking here if #672 subsumes it.
Recommendation
Changes Requested, on three checkable conditions: (a) pin the FlashInfer revision carrying gid_indices and drop (or explicitly caveat) the inspect.signature fallback in collectives.py:81-93; (b) make CI run cargo test --features roce --lib execution::roce, or at minimum correct the description's command; (c) cite flashinfer#209's merge SHA and record a checksum for the vendored roce_proxy.c. Findings 4–5 are non-blocking polish.