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
- No blocking correctness defect in the affinity logic. The mask is only ever narrowed from the thread's live
sched_getaffinity, every failure path is a silent no-op, and no-op is the documented x86_64/Windows path. - One should-fix:
helios/native/roce_proxy.cis a vendored file whose own header (lines 6–8) anddocs/roce-ring.md:355–364require it to stay identical to the pinned FlashInfer source after its provenance header. This PR adds 71 Flare-only lines to it and leaves the pin, header, NOTICE and doc rule untouched; the description says the paired upstream PR (local-inference-lab/flashinfer#156) may merge in any order, so the divergence can outlive the pin. - Nits: the same selection policy now exists twice (Rust and C) with duplicated thresholds and no shared test or cross-reference; the C helper synchronously stats/reads up to
CPU_SETSIZEsysfs files on the proxy thread before it starts polling; there is no operator opt-out of the narrowing other than a single-tier cpuset.
Verified-correct behaviour (files and lines)
- Policy parity between the two implementations. Rust:
eos/src/unix.rs:172–210(select_high_capacity_cpus) andeos/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_capacityfor 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 homogeneousmin_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 fallbackcap*2 > min+max(unix.rs:198–203,roce_proxy.c:1558–1564). Both compute in 64-bit intermediates, so no overflow on exoticcpu_capacityvalues. Both only apply when2 <= selected < allowed(unix.rs:205–209,roce_proxy.c:1566–1568), so busy threads are never collapsed onto one core. - Operator cpusets are strictly preserved.
nextis populated only from CPUs taken out of the current mask (unix.rs:224–243,roce_proxy.c:1518–1564), sosched_setaffinitycan only narrow; a cgroup cpuset can never be widened by this code, and a cpuset already restricted to one tier no-ops (tested ateos/src/unix.rs:281–292). - 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 ateos/src/windows.rs:219–220(the crate is compiled per-platform fromlib.rs, sounix::*vswindows::*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 ateos/src/unix.rs:247–248. - 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 ofserve_rank, before manifest validation and executor construction (cross-hostRankPeers::Processespath).helios/src/execution/worker.rs:71— inside the"flare-execution"thread closure, beforeRankExecutor::new.helios/src/replay.rs:174— inside the"flare-cuda"thread closure, beforerun(...)and before the readiness signal.helios/src/server/runtime.rs:568— inside the"flare-model"thread closure, before the host-prefix-store check andRankExecutor::new.helios/native/roce_proxy.c:1574–1577— first statements ofproxy_main, ahead of the doorbell poll loop; the thread is created inroce_startand joined inroce_stop, so a thread id is never reused with stale affinity. Same-hostRankPeers::Threadspeer ranks run on threads spawned insideThreadedExecutor(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.
- Error handling adds no new failure surface. Every failure path returns early and the
sched_setaffinityresult 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. - Tests match the claimed coverage.
eos/src/unix.rs:254–314covers 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. - 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):
- land or bump the upstream pin so
_roce_proxy.c(not opened) in the pinned FlashInfer revision contains the same helper, and update the header comment atroce_proxy.c:6–8(andNOTICE/THIRD_PARTY_NOTICES.md:49(not opened)) to the new revision; or - document the deliberate, ABI-neutral divergence in
docs/roce-ring.md:355–364— stating that the vendored copy carries an additional Linux-only thread-affinity helper and thread name that upstream may lack, and that a re-vendor must re-apply them.
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
- Whether the paired upstream PR ever lands.
helios/native/roce_proxy.cprovenance can only be reconciled by checkinglocal-inference-lab/flashinfer#156and the pinned revision; only the PR/commit state can settle it, not this repository. - Whether
cpu_capacityreflects real tiering on every supported ARM host. The code trusts the ACPI CPPC values as exposed; on hosts where the kernel exposes partial or stale capacity data the 90 % band could select a mixed set. The homogeneous/zero/absent guards make the failure mode benign (best-effort narrowing or no-op), but nothing in the tree can verify the sysfs values per host — only hardware validation can. eos/src/windows.rs:219–220was not compiled on Windows (stated in the description). The stub is trivially correct by inspection and the crate's per-platform re-export makes it the only definition, but only a Windows build confirms it.- Actual benefit is a hardware measurement on 4× DGX Spark per the description; I could not re-derive it from the repository, and review of the measurement itself is outside this lens.
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.