Simplicity scratchpad · NVIDIA/hyperflare-inference #576

Raw Markdown for agents: https://autobot.eidonix.com/p/8ce55515-0b76-44c7-9cff-10a35c9d432a.md

#1 [high] should fix: tier-selection policy duplicated in Rust and C

Finding (lens D, simplicity). Severity: should fix.

The tier-selection policy is implemented twice:

Both encode identical, non-obvious policy: read sched_getaffinity; per-CPU /sys/devices/system/cpu/cpu<N>/cpu_capacity; any read/parse failure or zero capacity aborts (C also aborts on >UINT32_MAX, :1534); min==max no-op; keep caps >= 90% of max; if that yields <2, fall back to caps above (min+max)/2; apply only if 2 <= selected < count. Two copies of an unwritten numeric threshold (0.9) must now be kept in sync by hand, and only the Rust copy has tests.

Why the C copy exists (so the fix is not trivial deletion): the proxy thread is created by pthread_create(&c->thread, NULL, proxy_main, c) roce_proxy.c:1674 inside roce_start, called from RoceTransport::connect helios/src/execution/roce.rs:295, which flare-cli calls from cluster::peer (flare-cli/src/main.rs:549) and cluster::rank_zero (main.rs:613) — before serve()/serve_peer() reach the narrowed threads (serve_rank parallel.rs:539, flare-model server/runtime.rs:568). The child therefore inherits the un-narrowed main-thread mask, which is why the C side narrows itself.

Smaller version: keep one implementation. Because the thread name and the affinity both belong to that one proxy thread, the cheapest consolidation is to narrow the creating thread's mask just before roce_start (e.g. call flare_eos::prefer_high_capacity_cpus() in RoceTransport::connect, or narrow a short-lived transport-opener thread that creates the proxy), letting pthread_create inherit; then delete roce_proxy.c:1505-1570 (66 lines) entirely. If instead the C copy must stay (vendored file — see comment roce_proxy.c:6-8 "Keep the source below identical so preparation and serving share the transport ABI"), then the duplication is deliberate and should be stated, and the Rust copy should be the only tested one — currently true.

#2 [high] should fix: two of the four Rust call sites narrow only qualification/preparation threads

Finding (lens D). Severity: should fix.

The four Rust call sites are not the same population:

Missing site, which makes the set look arbitrary: same-process TP rank threads format!("flare-rank-{}", index + 1) helios/src/execution/threaded.rs:652 are execution threads of exactly the kind the PR describes (they own GraphExecutor / launch CUDA graphs) and get no call, although serve_rank (process TP) and worker.rs (threaded TP via ExecutionWorker::new_threaded) do.

Fix: narrow serving threads only — keep runtime.rs:568 and parallel.rs:539, delete worker.rs:71 and replay.rs:174 — unless the same-process TP rank threads at threaded.rs:652 also get the call, in which case the PR must say which threads are "critical" and validate them. Either way the PR should state the rule (which threads) rather than listing files.

#3 [high] Research summary

Reviewed PR #576 through the simplicity lens (what can be deleted). Read the charter, AGENTS.md contribution/review rules, docs/design-review.md and the repo-prose skill, then read every changed function in context and followed the call sites.

Two findings, both "should fix", both recorded in the scratchpad:

  1. The tier-selection policy is implemented twice. select_high_capacity_cpus (eos/src/unix.rs:172-210, with the mask/sysfs plumbing at :215-245) and pin_high_capacity_cpus (helios/native/roce_proxy.c:1505-1570) encode the same unwritten policy: read sched_getaffinity, read each /sys/devices/system/cpu/cpu<N>/cpu_capacity, abort on any read/parse failure or zero, no-op when min == max, keep capacities ≥ 90% of max, fall back to above (min+max)/2 when fewer than two survive, apply only when 2 <= selected < count. Two copies of a magic 0.9 threshold now need hand-syncing, and only the Rust copy has tests. The C copy exists because the proxy thread is created by pthread_create (roce_proxy.c:1674) in roce_start, reached from RoceTransport::connect (helios/src/execution/roce.rs:295) before any narrowed thread exists, so it inherits the un-narrowed main mask. Smaller version: narrow the creating thread just before roce_start (or narrow a short-lived transport-opener thread) so the proxy inherits the mask, and delete roce_proxy.c:1505-1570 (66 lines). If the vendored-file comment at roce_proxy.c:6-8 forbids that, the duplication should be stated as deliberate.

  2. Two of the four Rust call sites only touch preparation/qualification threads, and a serving site is missing. worker.rs:71 (flare-execution) and replay.rs:174 (flare-cuda) reachable only from heliopause/src/python.rs:410-411 and :86 and from test tools — i.e. ignition preparation/qualification, where the PR reports no measurement and where AGENTS.md says debug-serve timings are diagnostic only. Meanwhile the same-process TP rank threads flare-rank-{n} (helios/src/execution/threaded.rs:652), which own GraphExecutor and launch CUDA graphs exactly like the threads the PR targets, get no call. Fix: keep runtime.rs:568 and parallel.rs:539, drop worker.rs:71 and replay.rs:174, unless threaded.rs:652 is also narrowed — and state the rule (which threads count as critical) instead of listing files.

I did not finish checking a third candidate (whether prefer_high_capacity_cpus should silently no-op versus report the chosen tier in the startup line, given the repo's "be explicit" rule), so I make no claim about it.

#4 [high] Review scope and rules cited (simplicity lens, PR #576)

Review lens: D, simplicity. PR #576, 7 files, +226/-1; head 4b41ddc; state open; no reviews yet.

Rules cited:

Files read in full/context: eos/src/unix.rs (1-336), eos/src/lib.rs, eos/src/windows.rs (stub at :219-220), helios/native/roce_proxy.c (1-120, 1440-1700, sentroce_start :1661-1687), helios/src/execution/worker.rs (1-223), helios/src/replay.rs (100-260), helios/src/server/runtime.rs (520-640), helios/src/execution/parallel.rs (470-640), helios/src/execution/ranks.rs, helios/src/execution/threaded.rs (600-680), helios/src/execution/roce.rs (1-80, 150-330), flare-cli/src/main.rs (470-620), flare-cli/src/cluster.rs (40-110), heliopause/src/python.rs (370-425), ignition/preparation/graphs.py (95-140), .github/workflows/native-serving.yml.

Coverage statement for the report: every changed hunk was read in context; two findings, both should fix, no blockers. No comment/bloat nit survived verification as worth reporting on its own — the doc comments on the new functions are short and state invariants, and the eos windows.rs stub comment (windows.rs:219) is one line and matched by the file's existing style.

#5 [medium] Unverified candidate — do not report as a finding

Candidate that was NOT settled and must not be stated as a finding:

prefer_high_capacity_cpus returns () and swallows every failure (let _ = unsafe { libc::sched_setaffinity(...) } eos/src/unix.rs:244; C counterpart (void)sched_setaffinity roce_proxy.c:1567). The operator therefore cannot tell from logs whether the narrowing happened, while the PR's claimed benefit is entirely "48/48 threads on X925". Under the charter's "Be explicit and pin everything" this could argue for one startup log line naming the selected CPU set. What would settle it: whether Helios already prints thread placement/affinity anywhere at startup (I did not finish grepping the flare-model startup line in server/runtime.rs), and whether the maintainers consider an affinity decision a diagnosable event. Also unresolved: the PR's corrected-claim shape — the Rust unit tests only cover select_high_capacity_cpus on synthetic capacities, not prefer_high_capacity_cpus against a real mask, so the sysfs-read/parse path (unix.rs:225-236) is untested by any check in the PR; only the manual 4-Spark run exercised it. A test on GB10 that calls the real entry point against a real cpuset would settle that, and only a hardware test can.

Neither item should appear in the final report as a finding with a severity; mention only as an unverified observation if at all.