Correctness report · NVIDIA/hyperflare-inference #576

Raw Markdown for agents: https://autobot.eidonix.com/p/44b69dd6-cd32-41e9-beb5-3b734822cd2b.md

Correctness review — PR #576: Pin Helios execution and RoCE proxy threads to high-capacity CPUs

Head reviewed: 4b41ddc (7 files, +226/−1). Every changed hunk was read in context, and every caller of flare_eos::prefer_high_capacity_cpus and of the new C pin_high_capacity_cpus was followed through its thread topology (serve_rank, flare-execution, flare-cuda, flare-model, proxy_main), plus the project's own rules (read_charter, docs/roce-ring.md, docs/prefix-cache-offload.md) and the vendored-file provenance header.

Key findings

Verified-correct behaviour (files and lines)

  1. Policy parity between the two implementations. Rust: eos/src/unix.rs:172–210 (select_high_capacity_cpus) and eos/src/unix.rs:215–245 (prefer_high_capacity_cpus). C: helios/native/roce_proxy.c:1505–1569 (pin_high_capacity_cpus). Both read the calling thread's current mask (sched_getaffinity(0, …)), read /sys/devices/system/cpu/cpu<N>/cpu_capacity for each allowed CPU, and return without action when: the mask read fails, any capacity file is absent/unreadable/unparsable (unix.rs:228–233, roce_proxy.c:1527–1536), any capacity is zero (unix.rs:179–181, roce_proxy.c:1534), fewer than two CPUs are allowed (unix.rs:173–175, roce_proxy.c:1543), the set is homogeneous min_cap == max_cap (unix.rs:185–187, roce_proxy.c:1543), or the selection would be empty/all/single. Thresholds match exactly: cap*10 >= max*9 (unix.rs:192, roce_proxy.c:1550) and, when fewer than two CPUs clear the 90 % band, the midpoint fallback cap*2 > min+max (unix.rs:198–203, roce_proxy.c:1558–1564). Both compute in 64-bit intermediates, so no overflow on exotic cpu_capacity values. Both only apply when 2 <= selected < allowed (unix.rs:205–209, roce_proxy.c:1566–1568), so busy threads are never collapsed onto one core.
  2. Operator cpusets are strictly preserved. next is populated only from CPUs taken out of the current mask (unix.rs:224–243, roce_proxy.c:1518–1564), so sched_setaffinity can only narrow; a cgroup cpuset can never be widened by this code, and a cpuset already restricted to one tier no-ops (tested at eos/src/unix.rs:281–292).
  3. No-op coverage for the documented targets. x86_64 Linux does not expose cpu_capacity, so the read fails and the function returns before touching affinity (unix.rs:228–230, roce_proxy.c:1528–1530); the Windows path is the stub at eos/src/windows.rs:219–220 (the crate is compiled per-platform from lib.rs, so unix::* vs windows::* never both define it); the C helper is #ifdef __linux__ (roce_proxy.c:1505, 1574). Other unix targets (macOS/BSD) take the #[cfg(not(target_os = "linux"))] stub at eos/src/unix.rs:247–248.
  4. Every call site is on a freshly spawned thread, before any other work, so the per-thread affinity change races with nothing and cannot leak to a parent or sibling thread:
    • helios/src/execution/parallel.rs:539 — first statement of serve_rank, before manifest validation and executor construction (cross-host RankPeers::Processes path).
    • helios/src/execution/worker.rs:71 — inside the "flare-execution" thread closure, before RankExecutor::new.
    • helios/src/replay.rs:174 — inside the "flare-cuda" thread closure, before run(...) and before the readiness signal.
    • helios/src/server/runtime.rs:568 — inside the "flare-model" thread closure, before the host-prefix-store check and RankExecutor::new.
    • helios/native/roce_proxy.c:1574–1577 — first statements of proxy_main, ahead of the doorbell poll loop; the thread is created in roce_start and joined in roce_stop, so a thread id is never reused with stale affinity. Same-host RankPeers::Threads peer ranks run on threads spawned inside ThreadedExecutor (helios/src/execution/threaded.rs:652–654) after the "flare-model"/"flare-execution" thread has already narrowed its mask, so the peer threads inherit the narrowed mask and the helper no-ops there (both tiers are gone) — no interference with the multi-thread collector structure.
  5. Error handling adds no new failure surface. Every failure path returns early and the sched_setaffinity result is discarded (unix.rs:244, roce_proxy.c:1567), so startup, shutdown, drain and error-reporting paths behave exactly as before; a kernel that refuses the narrowed mask leaves the thread on its original mask, which is the pre-PR behaviour.
  6. Tests match the claimed coverage. eos/src/unix.rs:254–314 covers GB10 two-tier capacities (718/731 vs 997/1017/1024), homogeneous CPUs, efficiency-only and performance-only cpusets, a single CPU, zero capacity, and a three-tier prime/big/little topology that avoids single-core collapse. They exercise the pure selector, not the sysfs/affinity syscalls — see nit 2.
  7. ABI/compatibility unchanged. Proxy ABI stays 14 (roce_proxy.c:134); no Protobuf, core-format or transport-layout change appears in the diff, so existing exported cores load and serve as before. This matches the description's "no wire/ABI change" claim and the charter's requirement not to break served artifacts.

Findings

Should fix — helios/native/roce_proxy.c:1505–1577: the vendored proxy is no longer identical to the pinned FlashInfer source, and nothing records the divergence

helios/native/roce_proxy.c:6–8 states: "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." docs/roce-ring.md:355–364 repeats the rule as a review standard: "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–17 and THIRD_PARTY_NOTICES.md:49 (not opened) pin the upstream file at FlashInfer commit f5f5341d711f8210ce91af5731a0841570f70e53.

This PR adds a Flare-only block — pin_high_capacity_cpus (roce_proxy.c:1505–1570) plus the pthread_setname_np(…, "flare-roce") and pin_high_capacity_cpus() calls at 1574–1577 — and updates neither the pinned dependency, the provenance header, NOTICE/THIRD_PARTY_NOTICES.md (not opened), nor docs/roce-ring.md. The description says the paired upstream PR (local-inference-lab/flashinfer#156) is independent and "either PR can merge in any order", which is precisely the case the identity rule is meant to protect against: if this lands first, the vendored file is silently ahead of the pin, and the next re-vendor from f5f5341d will drop the pin, the call and the thread name without any test failing (nothing in the tree compares the vendored file to the dependency).

Why it matters beyond bookkeeping: preparation and serving must agree on the proxy's behaviour and progress-barrier semantics; a divergence that exists only on the serving side is exactly the failure mode the rule was written for after earlier ABI-drift incidents (#271, #251, #215, #279).

Fix (either is sufficient):

Not blocking: the ABI stays 14, the wire format and collective-region layout are untouched, and preparation's behaviour is unchanged, so no deployed core or peer interaction breaks.

Nit 1 — eos/src/unix.rs:167–245 and helios/native/roce_proxy.c:1505–1569: two unlinked copies of one policy

The selection policy now exists twice, in two languages, with the 90 % band, the midpoint fallback and the "at least two CPUs" floor duplicated and no shared test or cross-reference. The comment at roce_proxy.c:1506–1509 and the Rust doc comments at unix.rs:167–171/212–214 describe the policy but do not name each other. Any future tuning of one copy (e.g. a different band, or a preference for avoiding SMT siblings) will silently leave the RoCE thread on a different policy than the execution thread, which is precisely the pairing this PR's evidence relies on. Fix: add a comment in each file naming the other as the must-match implementation, and ideally a test fixture with the same capacity vectors in both (a small table-driven C self-test, or a comment pointing at eos/src/unix.rs:254–314).

Nit 2 — eos/src/unix.rs:215–245 (and roce_proxy.c:1510–1542): the syscall/sysfs half is untested and unmeasured

The unit tests cover select_high_capacity_cpus only; prefer_high_capacity_cpus itself (mask read, per-CPU file reads, sched_setaffinity) has no test, and on any given CI host it necessarily no-ops. The PR's own evidence shows multi-millisecond host-side effects on one-shot collectives, so the cost of reading up to CPU_SETSIZE (1024 in C roce_proxy.c:1516–1517; 1024-bit mask in Rust unix.rs:223–236) cpu_capacity files synchronously on the proxy thread before it enters the doorbell poll loop is worth one measurement; on GB10 it is 20 cached reads, but the first fopen after roce_start is a cold page-cache miss on the thread the GPU kernels will immediately wait on. Fix: a test that installs a fake sysfs root (or an injectable reader closure) and exercises the mask-intersection path, plus a note in the PR that the one-time cost at proxy start was measured.

Nit 3 — no operator opt-out is documented

The narrowing is unconditional for these four threads on asymmetric Linux hosts; the only way to avoid it is a cpuset confined to one tier (eos/src/unix.rs:281–292 shows that no-ops). That is defensible and the description says cpusets are preserved, but operators who deliberately want the critical threads on efficiency cores for power or thermal reasons have no documented escape hatch. Not a code defect; a sentence in the docs for these threads (there is precedent for recording such decisions in docs/prefix-cache-offload.md:863–867, which requires a serving-latency measurement before adding affinity to the offload transfer/disk threads — this PR leaves those threads alone, correctly, and its evidence would be the model to cite) would close it.

Open questions / what could not be settled from the code

Nothing else in the changed files produced a correctness finding: the call ordering, thread lifetimes, cpuset intersection, no-op conditions, error paths, test coverage of the selector, and ABI/format compatibility all hold up under inspection.