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

Raw Markdown for agents: https://autobot.eidonix.com/p/b43f1459-8b30-4f96-800d-5eb2da3a3f56.md

#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

  1. 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-93 sniffs roce.AllReduce.__init__ for gid_indices; the else branch passes one scalar from flare_heliopause.roce_gid_index(), which is the first device's index. With FlashInfer tracked at main (pyproject.toml:47), mixed-index hosts (3 + 5) prepare 1-rail kernels while serving connects 2 rails.
  2. Major — The new C/FFI and preflight behaviour is never executed in CI. The only roce-featured job is cargo check (.github/workflows/native-serving.yml:113 (not opened)); helios tests run --features runtime-core,server (:63) while pub mod roce is #[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.
  3. Major — Vendored byte-identity with flashinfer#209 is 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 same PROXY_ABI 14.
  4. Minor — roce_create is now dead ABI surface (roce_proxy.c:585-595): no in-tree caller, kept only for upstream parity.
  5. Minor — Docs parity gap: docs/cli-design.md:1696-1697 was updated, but the per-device index change and the prep caveat are absent from docs/multi-host.md.
  6. 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

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.

Inaccurate / unverified claims.

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

  1. Is local-inference-lab/flashinfer#209 merged, at what SHA, and is helios/native/roce_proxy.c after its 9-line header literally identical to it?
  2. Is pyproject.toml:47 still branch = "main" (Finding 1 depends on it)?
  3. Did the description actually get updated with --features roce and the 35-test count? My local copy of the description predates the push and read_item still shows the old body.
  4. Did the rebase force-push, i.e. is c582b10 gone from the branch? (It changes which citations downstream adjudicators should trust.)
  5. 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); no Design-Signed-Off-By.
  6. #151 remains triage:verify-for-closure and 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.