Code correctness report · NVIDIA/hyperflare-inference #707

Raw Markdown for agents: https://autobot.eidonix.com/p/a2b473e8-9f16-4ea9-ac71-1a8a717add34.md

Deep Code Correctness, Invariants & Hot-Path Audit — PR #707 @ 81ef561

Partitioned into 3 disjoint slices (C proxy / helios Rust / CLI+heliopause+ignition+parity) and audited with the full 4-part protocol (callee/enum resolution, same-loop state ordering, adversarial boundary inputs, hot-path big-O) on each. I independently re-read and verified the C findings below.


FINDING 1 — Major: credit_phases() holds only ONE phase on a pipe↔1-hop transition, leaving the other phase of a two-phase op unguarded (silent peer-row/flag corruption)

Diff site: helios/native/roce_proxy.c:1530-1547, buggy branch at 1536-1538 (new in this PR).

static uint32_t credit_phases(uint32_t prev, uint32_t kind) {
  uint32_t prev_p = kind_phases(prev);
  uint32_t cur_p = kind_phases(kind);
  if (prev_p == 0 || cur_p == 0) {
    return 0;
  }
  if (kind_1hop(prev) != kind_1hop(kind)) {
    return (cur_p & PIPE_PHASE_RS) != 0 ? CREDIT_RS : CREDIT_AG;   // <-- drops the other phase
  }

Callee / enum resolution (verified by me):

Concrete counterexample (prev = KIND_GATHER_SHARDS, cur = KIND_RING_RSAG, world W=4, rank R=0, 2 rails, chunks=4, chunk_packs=8, nbytes=1024 → total=64 packs, half_max=32, widest=8, half_cap large): prev_p = 2, cur_p = 3, kind_1hop(4)=0 != kind_1hop(9)=1 → returns CREDIT_RS only. The AG half (do_ag) is therefore never gated: at :1823 and :1867 credit & CREDIT_AG == 0 from the first loop iteration, so with dir=0, s=1, c_idx=0 we take src_slot = 2*(4-1)+0*(4-1)+(1-1) = 6, dst_slot = 7 → bytes [3·sc, 3.5·sc) written into peer 3's pipe_recv row 3 = (source 1, phase 1) region while peer 3 may still be reading that row for its predecessor op, and the AG flag write lands on row W+0 = 4 = peer 3's pipe (source 0, phase 1) flag row. Result per :76-78: "Either write could replace a flag before the peer saw it (a wait timeout) or the rows it is reading (silent corruption)." The same under-hold exists in the reverse direction (prev = KIND_RING_RSAG(9), cur = KIND_TWOSHOT(1) → CREDIT_RS only, while :1676 posts pipe phase 1 unguarded).

Fix — hold every phase the new op performs:

  if (kind_1hop(prev) != kind_1hop(kind)) {
    uint32_t need = 0;
    if (cur_p & PIPE_PHASE_RS) need |= CREDIT_RS;
    if (cur_p & PIPE_PHASE_AG) need |= CREDIT_AG;
    return need;
  }

Safe because credits_arrived clears the whole mask once every peer's credit lands. Escalates to Blocker once the companion recipes PR (#114) enables KIND_RING_RSAG: it is an unfixable-after-the-fact silent data-corruption race, and no in-tree test covers it (roce.rs:695-746 only exercises roce_set_relay rejection).


FINDING 2 — Minor: the mixed-GID legacy guard is keyed on a parameter name, so a legacy AllReduce that declares gid_indices=None/**kwargs is misclassified as per-HCA-capable, silently preparing fewer rails than serving connects

Diff sites: ignition/preparation/collectives.py:85-97; test tests/preparation/test_roce_proxy_parity.py:77-81, 110-119.

    if "gid_indices" in inspect.signature(roce.AllReduce.__init__).parameters:
        gid_kwargs = {
            "hca_names": [name for name, _ in devices],
            "gid_indices": [gid for _, gid in devices],
        }

The test models "legacy" as def __init__(self, *, gid_index=None, **kwargs), so it exercises only the **kwargs-free case. Counterexample: a legacy __init__(self, *, gid_index=None, gid_indices=None, **kwargs) (or a **kwargs-only signature) plus roce_devices() == [("roce0",3),("roce1",5)] selects the gid_indices branch, never raises the RuntimeError("… distinct GID indices") the code claims guarantees "fail loudly rather than dropping rails", and the hca_names/gid_indices kwargs are swallowed. Fix: require both names to be explicit parameters and reject a VAR_KEYWORD-only signature (per_hca = {"hca_names","gid_indices"} <= params), and add a third test class whose signature accepts but ignores gid_indices, asserting the mixed-GID host raises. Minor because the pinned environment (pyproject.toml:47) does honour gid_indices.


Verified sound (no defect found)

Unverifiable here: byte-for-byte parity against FlashInfer 524799c4 (upstream tree not present in-repo), multi-node wire behaviour, and the claimed 25% switch-traffic / 1.20x–1.46x speedups (single host, as the PR itself states).