Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #672

Raw Markdown for agents: https://autobot.eidonix.com/p/36982182-7412-49d1-b52d-74859c50a6b0.md

#1 [high] Core mechanism is correct: per-HCA SGID threads local-only

Correctness of the plumbing itself is sound (do not invent bugs here):

#2 [high] MAJOR: fix is one-sided — preparation keeps one global GID index, serving becomes per-HCA; rail count can now mismatch in the opposite direction

SEVERITY: Major (arguably Blocker). The PR's own root-cause narrative ("prep planned 2 HCAs while discovery dropped the second") is only half fixed; the other half is untouched, and the fix can invert the mismatch.

  1. Rails are derived from the merged kept-device set, unchanged by this PR but now larger on mixed hosts: 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. RoceTransport::open only checks the bound, !(1..=super::roce_fabric::MAX_RAILS).contains(&topology.rails) (helios/src/execution/roce.rs:154), it does not compare against what preparation compiled.

  2. n_rail is load-bearing in the captured kernel's flag addressing, e.g. helios/native/roce_proxy.c:1259 uint64_t flag_off = c->flag_off + ((uint64_t)c->rank * ROCE_SLOTS + slot) * (uint64_t)c->n_rail * ROCE_FLAG_STRIDE; and the same stride at roce_proxy.c:1382, 1425, 1439, 1466, 1693. The GPU kernels spin on flag[peer][slot][rail] using the rail count baked in at preparation, so serving must plan exactly that many rails.

  3. Preparation still opens every active device at a single host-wide index: ignition/preparation/collectives.py:83 gid_index=flare_heliopause.roce_gid_index(), which is Fabric::gid_index (heliopause/src/python.rs:695-701). So prep's HCA set/rail count is still decided by one index while serving's is now per-HCA — the two rules can disagree in either direction. On the PR's own 2×GB10 mixed host (IPv4 at 3 / 5), prep gets gid_index=3 (roce_fabric.rs:430) and opens the second HCA at index 3 (its link-local IPv6 GID) or rejects it, while serving now plans 2 rails at 3 and 5.

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 removes one direction of the mismatch without closing the class.

FIX: make preparation consume the per-HCA indices too (expose e.g. roce_gid_indices() / name->index map from heliopause and pass it to b12x), or fail fast: have RoceTransport::open/connect reject a rail count that differs from the core's recorded geometry. Either way the PR description must state which half remains open.

#3 [high] MAJOR: Fabric::gid_index semantic change unannounced + stale contract docs/consumer

SEVERITY: Major. Fabric::gid_index silently changes meaning and its only outside consumer keeps the old documented rule.

Old field was "the host's chosen index" (main roce_fabric.rs:405-415: 3 if every active device has one there, else the lowest index any device has one). New value is just the first kept device's index: helios/src/execution/roce_fabric.rs:430 let gid_index = devices[0].1;

The doc comment on the field 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, pub traffic_class: u32, pub endpoints: Vec, }

The stale-rule consumer: heliopause/src/python.rs:692-704 /// 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 { ... crate::execution::roce_fabric::discover() .map(|fabric| fabric.gid_index) Both the doc string and the invariant are now false: on the PR's own 2×GB10 example the returned value is 3 (renamed-to-"devices[0]") and it no longer describes any host-wide rule prep can rely on. Doc drift + a semantic change to a public API that prep calls (ignition/preparation/collectives.py:83) — and the PR description says nothing about having changed it.

Also stale after this PR:

FIX: rename/redocument Fabric::gid_index (e.g. first_gid_index or drop it), update python.rs:692-693 and the doctor fallback text, and update the three docs pages, or make the doctor warn path use gid_index_for/indices list.

#4 [high] MAJOR: vendored-parity invariant broken without upstream revision or ABI bump

SEVERITY: Major (contract/charter), not a code bug.

helios/native/roce_proxy.c:1-8 // Vendored from FlashInfer's pinned preparation dependency // (flashinfer/experimental/b12x/comm/roce/_roce_proxy.c, proxy ABI 14). // Keep the source below identical so preparation and serving share the transport ABI.

helios/native/roce_proxy_dlopen.c:7-9 // Loads libibverbs.so.1 lazily ... while // keeping the vendored roce_proxy.c byte-for-byte identical to FlashInfer.

docs/roce-ring.md:360-364 FlashInfer owns these models 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 (adds int gid_index, roce_proxy.c:259), open_hca (:461), roce_create (:587), adds roce_create_with_gids (:531) and changes connect_qp (:680). No upstream FlashInfer revision is cited anywhere in the diff or description, NOTICE still claims "implementation is unchanged", and PROXY_ABI stays 14 (helios/src/execution/roce.rs:23) even though the exported surface grew. #643 (merged one day earlier, 2026-11-30, ec957867) existed specifically to restore byte parity, and #649 is blocked on the same invariant (per dossier).

This also matters functionally: preparation keeps using the pinned FlashInfer b12x proxy while serving uses this fork, so any divergence in SGID selection between the two is exactly the class of bug being fixed. Charter #215 "Be explicit and pin everything" / #404.

FIX: land the same change upstream in FlashInfer and re-vendor at a named revision (updating NOTICE and the header comment), or increment the proxy ABI / describe the divergence explicitly and get owner sign-off. At minimum cite the upstream commit or patch URL in the PR description.

#5 [high] MAJOR: the roce.rs per-HCA branch and its fallback are never executed by CI or any test; description unverifiable

SEVERITY: Major (test/claim accuracy). The one changed file CI never executes carries the riskiest code.

docs/roce-ring.md:381-384 documents the required command: cargo test --manifest-path helios/Cargo.toml --features roce
--lib execution::roce::tests

CI only compiles the roce feature: .github/workflows/native-serving.yml:113 cargo check --locked --manifest-path flare-cli/Cargo.toml --tests --features roce,rdma There is no cargo test --features roce anywhere in .github/workflows (grep for roce returns only that one line). And execution::roce is gated: helios/src/execution.rs:16-17 #[cfg(feature = "roce")] pub mod roce; So helios/src/execution/roce.rs — where roce_create_with_gids / gid_indices are wired (roce.rs:46-61, 199-221) — is compile-checked only. The new roce_fabric test and the new doctor test do run.

MC/DC-relevant untested paths:

CLAIM ACCURACY: the description's two cargo test … lines render with the identifiers blanked, so the commands cannot be reproduced from the PR at all; no --features roce run is claimed; the hardware paragraph gives no command, counts, baseline, or logs. AGENTS.md:103-112 requires each claim tied to command/configuration/result, and docs/design-review.md:252-259 makes live multi-GPU execution mandatory for helios/src/execution/roce* transport changes — claimed narratively, not demonstrated.

FIX: add a cargo test --features roce --lib execution::roce::tests leg to native-serving.yml (the libibverbs dev package is already installed in the rdma job, :105-108), add a unit test for the per-HCA branch in roce.rs, and state the exact commands + counts in the description.

#7 [high] Research summary

Review complete for PR #672 (per-HCA RoCEv2 IPv4 GID selection). I inspected all four changed files in full context plus their direct callers and contracts: helios/src/execution/roce_fabric.rs, helios/src/execution/roce.rs, helios/native/roce_proxy.c, flare-cli/src/doctor/spark.rs, and callers/consumers flare-cli/src/cluster.rs, flare-cli/src/fabric.rs, heliopause/src/python.rs, ignition/preparation/collectives.py, docs/{cli-design,multi-host,roce-ring}.md, NOTICE, helios/build.rs, and .github/workflows/native-serving.yml (not opened).

The mechanism itself is sound and I say so plainly: gid_indices is always exactly one entry per endpoint, the per-HCA index is assigned before open_hca queries it, only the local SGID index changes while the remote DGID still comes from the peer's blob, roce_blob_t and PROXY_ABI are untouched, and there is no concurrency, allocation, lock-contention, hot-path, or cross-platform regression — the new vectors are one-shot at transport open and the proxy's posting/ring logic is unmodified.

The substantive findings are four Majors. (1) The fix is one-sided: serving's kept-device set now yields more rails on exactly the mixed-index hosts targeted, while preparation still opens every HCA at a single host-wide index (ignition/preparation/collectives.py:83 → heliopause/src/python.rs:695-701), so the prep/serving rail-count mismatch the PR blames for the sequence-1 timeout is not closed and can now invert — made concrete by the fact that n_rail is baked into the captured kernels' flag addressing (roce_proxy.c:1259,1382,1425,1439,1466,1693) and RoceTransport::open only bounds-checks it. (2) Fabric::gid_index silently changes meaning to "first device's index" (roce_fabric.rs:430) without updating its own doc, the roce_gid_index() doc contract in heliopause/src/python.rs:692-693, the doctor's terminal Warn path (flare-cli/src/doctor/spark.rs:250-256), or any of the three doc pages AGENTS.md:234 requires. (3) The native edit forks the vendored roce_proxy.c one day after #643 restored byte parity, cites no upstream FlashInfer revision, leaves NOTICE claiming "implementation is unchanged", and does not bump PROXY_ABI from 14 — preparation still uses the pinned upstream proxy, which is exactly where an SGID-selection divergence would hide. (4) The riskiest code has no executable coverage: CI only cargo check --features roce,rdma (native-serving.yml:113), execution::roce is feature-gated, and nothing tests the new per-HCA branch or its silent length-mismatch fallback (roce.rs:199-203), while the PR's verification lines are unreproducible and the "backward-compatible wrapper" roce_create has no in-tree caller.

Minors are limited to latent silent-fallback hazards and two coverage gaps. Full detail, with verbatim quotes and exact file:line citations for every finding, is in my scratchpad notes 1–6.

#8 [high] Review scope and verified before/after claim (positive)

REVIEW SCOPE (for stating coverage in the final report). Changed files inspected in full context:

VERIFIED POSITIVE (before/after claim in the PR description is accurate): main, roce_fabric.rs:405-418 → let gid_index = if !names.is_empty() && names.iter().all(|name| roce_v2_ipv4(name, PREFERRED_GID_INDEX)) { PREFERRED_GID_INDEX } } else { (0..GID_TABLE).find(...) ... }; let devices: Vec<(&String, Option)> = names.iter() .filter(|name| roce_v2_ipv4(name, gid_index)) .take(MAX_DEVICES) ... So main did drop any active HCA lacking an IPv4 RoCEv2 GID at the single chosen index. Head (roce_fabric.rs:407-431) instead picks per device. The PR's "Previously … dropped any active HCA whose IPv4 RoCEv2 GID lived at a different index" is truthful, and every item in its "What Changed" list is present in the diff. The problem is the Verification section, not the change description.

ALSO VERIFIED: docs/roce-ring.md:381-384 documents the exact required test command (cargo test --manifest-path helios/Cargo.toml --features roce --lib execution::roce::tests); CI never runs it.

#9 [high] Verdict and disposition for the final report

VERDICT: request changes. The change addresses a real defect at the right layer (discovery + transport FFI + proxy; no new flag/env/config — charter #404 satisfied) and is internally correct, but it does not close the failure class it cites, changes a public contract silently, breaks a repo-invariant restored one day earlier, and ships its riskiest hunk with zero executable coverage.

Severity ranking (all with citations in notes 1-6):

  1. MAJOR — one-sided fix; prep still single-index (collectives.py:83 → python.rs:695-701) while serving is per-HCA; rails derived from merged kept-set (roce_fabric.rs:1025) and n_rail is baked into kernel flag addressing (roce_proxy.c:1259/1382/1425/1439/1466/1693); open() only bound-checks rails (roce.rs:154). [note 2]
  2. MAJOR — Fabric::gid_index = devices[0].1 (roce_fabric.rs:430), field doc (roce_fabric.rs:221-228), python.rs:692-693 contract, doctor Warn path (spark.rs:250-256) and docs/cli-design.md:1695-1698/1712-1714, docs/roce-ring.md:333-342, docs/multi-host.md:42-43/102-130 all stale; AGENTS.md:234 requires the doc updates. [note 3]
  3. MAJOR — vendored-parity broken: roce_proxy.c:6-8 and roce_proxy_dlopen.c:7-9 and docs/roce-ring.md:360-364 and NOTICE:16-19 still assert identity/unchanged; no upstream revision cited; PROXY_ABI still 14 (roce.rs:23); prep uses upstream proxy while serving uses this fork. [note 4]
  4. MAJOR — tests/claims: CI only cargo check --features roce,rdma (native-serving.yml:113); execution::roce feature-gated (execution.rs:16-17); new per-HCA branch and its silent fallback (roce.rs:199-203) untested (only fixture uses gid_indices: Vec::new(), roce.rs:397); roce_create wrapper (roce_proxy.c:587-601) has no caller; description's commands render blank and the hardware evidence carries no command/counts/logs (AGENTS.md:103-112, design-review.md:252-259). [note 5]
  5. MINOR — silent unwrap_or(self.gid_index) degradation (roce_fabric.rs:1009-1011, 1027-1031), coverage gaps in the two new tests, and the negative findings: no concurrency/memory/latency/failure-propagation/cross-platform regression. [note 6]
  6. NO ISSUE — the per-HCA plumbing is correct and symmetric; state plainly. [note 1]

NOT CLAIMED: the PR links no issue. #151 is the closest symptom match but per the dossier its rails both sat at GID index 3, so per-HCA divergence does not explain it and #672 neither cites nor posts to it — the hardware paragraph reads like the retest original-el8 asked for but is not linked. Present as "no issue linkage / closure unproven", not as a verified mechanism claim. No Design-Signed-Off-By trailer could be confirmed from the repository.

CONCRETE FIXES to state: make preparation consume per-HCA indices (expose a name→index map from heliopause and pass it to b12x) or fail fast on rail-count mismatch with the core's recorded geometry; rename/redocument gid_index and update python.rs, the doctor Warn text and the three doc pages; land the proxy change upstream and re-vendor at a named revision (updating NOTICE) or bump PROXY_ABI with owner sign-off; add cargo test --features roce --lib execution::roce::tests to the rdma CI job (libibverbs-dev already installed there, native-serving.yml:105-108) plus a per-HCA-branch unit test, and quote exact commands/counts in the description.

#6 [medium] Minor: silent fallback hazards, coverage gaps, and the negative findings (no hot-path/system-level regression)

SEVERITY: Minor each, verified against the diff.

  1. take(MAX_DEVICES) moved from before the map to after filter_map (roce_fabric.rs:414-426). Behaviour is equivalent (filter_map is lazy, take still caps the collected vec) but note the scan cost: pick_gid_index now loops 0..GID_TABLE (16 indices, each 2 sysfs reads) per active device instead of (0..GID_TABLE).find(any device) once — up to 4 devices × 16 × 2 reads per discovery. Discovery runs once per rank start and once per flare doctor, so this is not a hot path; mentioning only so it is not mistaken for a perf regression. No action needed.

  2. gid_index_for silently degrades on a short/empty vector: helios/src/execution/roce_fabric.rs:1009-1011 pub fn gid_index_for(&self, index: usize) -> u32 { self.gid_indices.get(index).copied().unwrap_or(self.gid_index) } unwrap_or(self.gid_index) means a truncated vec silently uses devices[0]'s index for the missing HCAs — precisely the old bug — rather than erroring. Same .len() == fallback in Fabric::topology (roce_fabric.rs:1027-1031) and roce.rs:199-203. In-tree this is unreachable today (discover_in always populates both vecs in lockstep), so it is a latent hazard, not a live bug. If the fallback is only for test fixtures, a debug assertion or expect would be safer than silent degradation.

  3. New doctor test fixture uses a real interface name that does not collide, but note it writes gid_attrs/ndevs/{gid} at only one index per device (flare-cli/src/doctor/spark.rs:553-563), so it does not cover the case where a low index also holds a RoCEv2 IPv4 GID on the same HCA (i.e. the preference for index 3 when both 3 and 5 are valid on one HCA). The roce_fabric test likewise only covers "index 3 invalid on the second HCA". Neither covers "index 3 valid but on a different IPv4 subnet than index 5" — a case where the per-HCA preference could pick two rails on the same subnet. Low likelihood, cheap to add.

  4. Doctor ready_gids[0] indexing at flare-cli/src/doctor/spark.rs:187-188 is guarded by if !ready.is_empty() (:181), and ready_gids is pushed in lockstep with ready (:172-179), so no panic. Correct as written.

  5. Cross-platform parity: unaffected. Fabric/Topology are Linux-gated in use (helios/src/execution/roce_fabric.rs:515-523, flare-cli/src/cluster.rs:41-45), and roce_gid_index returns an error off-Linux (heliopause/src/python.rs:702-703). New Vec<u32>/Vec<c_int> allocations are one-shot at transport open, not per collective — no memory amplification, no lock/contention change, no failure-propagation change on any hot path. The proxy's posting thread and ring/mailbox logic are untouched. Say this plainly: there is no system-level regression in this PR.