Architecture report · NVIDIA/hyperflare-inference #576

Raw Markdown for agents: https://autobot.eidonix.com/p/ee4ab5df-f033-4dd6-83db-8d06b5fecc34.md

Architecture and scope review — PR #576 "Pin Helios execution and RoCE proxy threads to high-capacity CPUs on asymmetric Linux topologies"

Key findings

  1. Blocking — an unconfigurable, default-on host-scheduling policy with a magic threshold is installed in the shared eos crate and the vendored proxy. prefer_high_capacity_cpus restricts every Linux serving build's critical threads to capacity*10 >= max*9 with no configuration home, no way to disable it, and an undocumented midpoint fallback. This is exactly what the charter's "Be explicit and pin everything. No magic defaults", AGENTS.md's three-homes rule for settings, and AGENTS.md's "reject unsupported abstractions and churn" rule prohibit. The policy is also implemented twice (Rust and C) and must be kept in sync by hand.
  2. Blocking — there is no measurement of this branch against main. Every claimed number compares CPU placements within the change (X925-placed vs A725-placed launches of the same tree), not pinned-vs-unpinned or main-vs-head with flare run on the same exported core, which is what the charter and design-review principle 12 require.
  3. Should fix — silent error suppression in both implementations (return on the first unreadable sysfs file, ignored sched_setaffinity results), which makes the claimed no-op semantics unverifiable and violates "Do not ... suppress errors".
  4. Should fix — a persistent, undocumented side effect on the public serve_rank entry point used by the peer-rank serving path.
  5. Should fix — no test covers the function that actually touches the system (prefer_high_capacity_cpus) or the entire C helper; only the pure selector is tested.
  6. Nits — placement in eos/ rather than a Helios module, doc-comment/behaviour mismatches in the fallback logic, one sysfs open per allowed CPU on the startup path (also paid by ranks that are rejected immediately), and an unrelated thread-name change bundled into the same hunk.

Nothing in my lens is a correctness or compatibility problem: the change adds no environment variable, no Protobuf field, no core-contract or ABI change, and its new mask is a subset of the thread's existing affinity, so operator cpusets are preserved.


Blocking

B1. Blanket, unconfigurable affinity default with a magic 90% constant in the serving path

Files: eos/src/unix.rs:172-245 (select_high_capacity_cpus, prefer_high_capacity_cpus), eos/src/windows.rs:220, helios/native/roce_proxy.c:1505-1570 (pin_high_capacity_cpus), call sites helios/src/execution/parallel.rs:539, helios/src/execution/worker.rs:71, helios/src/replay.rs:174, helios/src/server/runtime.rs:568, helios/native/roce_proxy.c:1576.

What is wrong. The PR installs one hard-coded host scheduling policy into the default serving path of every Linux build: model, peer-rank, execution, replay, and RoCE proxy threads are narrowed to the set selected by the rule cap * 10 >= max_cap * 9 (eos/src/unix.rs:192, mirrored at roce_proxy.c:1550), with a second, different rule (cap * 2 > min + max, eos/src/unix.rs:198-203, roce_proxy.c:1558-1564) when the first selects fewer than two CPUs. Nothing in the recipe declaration, configuration file, or CLI selects this behaviour, and nothing can select it off. The Rust function has no parameters, no return value, and no error path; it is simply invoked at thread start.

Why it matters (rules cited).

Secondary defect of the same change: the same ~60-line heuristic now exists twice, in Rust (eos/src/unix.rs:172-210) and in C (roce_proxy.c:1510-1569), with two threshold expressions, two CPU_SETSIZE loops, and two copies of the fallback. They must be kept in sync by hand across two build systems; any future fix to one is a latent divergence in the other.

Fix. Either (a) make it an explicit setting with one of the three sanctioned homes — a CLI flag on flare run/Helios carried into the runtime, or a typed config field — stating the CPU set the operator wants (an explicit set is also easier to reason about than a capacity heuristic, and removes the magic constant and the midpoint fallback), or (b) drop the code change and document the taskset/systemd-cpuset recommendation in the multi-host or runtime-core design doc. If a heuristic is to survive at all, the threshold and the fallback must be justified by named hardware and stated in the docs, not embedded as literals. A default-on heuristic cannot be justified by "no environment variables are introduced".

B2. Performance claims have no main-vs-head baseline

Files/claims: PR description, "Claimed Benefit" and "Supporting Evidence" sections.

What is wrong. No measurement of this branch against main is reported. Every number compares CPU placements within the change on the same tree:

Why it matters (rules cited).

The measurements are substantial and appear honestly reported for what they are (placement effect on one host family, with x86_64 explicitly declared a no-op path), and that honesty is worth acknowledging. But under this project's standard, "placement A is faster than placement B on my branch" does not establish that merging the change improves main, and it does not show what the change costs. A default-on affinity mask also has a cost the description never measures: threads that were previously free to migrate across 20 CPUs are now confined to 10, and while the proxy is idle it still naps on a restricted CPU set alongside the model thread (roce_proxy.c:1578-1585).

Fix. Report a paired comparison of main and this head on the same host with the same exported core via flare run, with launch counts and dispersion, and state the recipe/core identity and configuration. If the intent is only to demonstrate the placement effect, then the change should not be a default — see B1.


Should fix

S1. Silent failure paths make the documented no-op semantics unverifiable and suppress errors

Files: eos/src/unix.rs:218-222, 228-233, 244; helios/native/roce_proxy.c:1513-1515, 1528-1536, 1567.

prefer_high_capacity_cpus bails out of the whole computation on the first CPU whose cpu_capacity cannot be read or parsed (unix.rs:228-233: let Ok(text) = … else { return; }, same for the parse), and the C helper does the same (roce_proxy.c:1528-1530, 1534-1536). Both ignore the final sched_setaffinity result (unix.rs:244 let _ =; roce_proxy.c:1567 (void)). The doc comment and the PR description claim a no-op "when cpu_capacity is absent, unreadable, zero, homogeneous" — but the whole file is skipped silently, including the readable CPUs, and a failed sched_setaffinity (for example under a seccomp or container restriction on sched_setaffinity) leaves the thread on the full mask with no diagnostic whatsoever. There is no way to tell from a serving log whether the policy applied, which also makes B2's placement claims untestable in the field.

AGENTS.md:182-186 explicitly rejects weakened guarantees: "Do not remove validation, suppress errors, silently substitute execution paths…". The charter adds: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)."

Fix. Either treat the "no policy" case as a deliberate decision and emit one startup diagnostic line (the pattern the repository already uses for WFET parking, see #280), or return a Result/status so callers and tests can observe whether the mask was applied. Do not merge with let _ =.

S2. A public API's contract now includes a persistent thread-affinity side effect

Files: helios/src/execution/parallel.rs:527-539 (serve_rank, exported at helios/src/execution.rs:25 (not opened)), callers flare-cli/src/main.rs:560 and heliopause/src/python.rs:548.

serve_rank is public API, documented only in terms of resource lifetime (parallel.rs:527-532), and reached from flare-cli's serve_peer and from the Python qualification path via heliopause (py.detach(|| … serve_rank(…)), heliopause/src/python.rs:548). After this PR the first statement of the function permanently narrows the calling thread's CPU affinity (parallel.rs:539), before the persistent-worker rejection (540-547) and before manifest.validate() (548). Two consequences worth stating in the contract: (a) an embedding caller that reuses that thread for other work (notably the Python path, where the calling thread returns to general use after py.detach) inherits a narrowed mask it never asked for; (b) ranks that are rejected immediately still pay the probe. AGENTS.md:194-199 requires the problem and resulting behaviour to be described, and the charter's "solve the right problem in the right place" applies: if placement is a serving decision, it belongs where serving is started, with the decision visible, not buried in a library entry point documented only for resource lifetime.

Fix. Document the affinity side effect in serve_rank's doc comment, and move the call after validation (or into the caller) so it is a deliberate action of the process that owns the serving thread. If B1 is resolved by an explicit setting, this becomes moot because the call takes an argument.

S3. The only code that touches the system is untested, and the untested arm is the latency-critical one

Files: eos/src/unix.rs:254-314 (tests), helios/native/roce_proxy.c:1510-1569 (no test), eos/src/windows.rs:220 (never compiled, per the description).

The four new unit tests exercise only select_high_capacity_cpus, the pure selector: the GB10 two-tier split, homogeneous/single-tier/zero-capacity no-ops, and the three-tier fallback. prefer_high_capacity_cpus itself — sysfs enumeration, sched_getaffinity, sched_setaffinity — has no test at any layer, and the entire pin_high_capacity_cpus C helper has no test and is only claimed to have been exercised implicitly on GB10 by 6 launches and a soak. That is the function the PR blames for its headline effect (the flare-roce proxy thread). AGENTS.md:194-199: "Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness… Identify missing hardware, inputs, and unrun checks explicitly." The description does disclose the Windows gap, which is to its credit, but not the C gap as a gap.

A test is feasible without a GB10: factor the sysfs root into a parameter (or read capacities through a small injectable function) and assert the mask applied to the calling thread with sched_getaffinity, plus a negative case with a synthetic three-tier root. The C helper could at minimum be exercised by a host-side test that sets its own affinity and reads it back.

Fix. Add a test for prefer_high_capacity_cpus that verifies the applied mask and the no-op path, and either add a host-side test for the C helper or state plainly in the PR that the C path is unverified by any automated check.


Nits

  1. Placement of the policy. AGENTS.md:20-21 defines eos/ as "the host operating-system operations that Helios and Selene use", exported wholesale (eos/src/lib.rs:10-16, pub use unix::*). A serving-affinity policy is not a generic host OS operation and is now inherited by Selene and anything else linking eos. A Helios module would express the same behaviour, keep the scope visible, and remove the windows.rs stub (eos/src/windows.rs:220) entirely.

  2. Doc comment does not match the code, and one test passes for the wrong reason. eos/src/unix.rs:195-197 says the midpoint fallback exists to "Avoid collapsing multiple busy threads onto a single prime core", but if the high tier contains exactly one CPU the fallback can still select just that one CPU and then return None at line 205. Likewise the "already restricted to one tier is a no-op" claim is enforced by selected.len() < allowed_with_capacity.len() at line 205, not by the min_cap == max_cap check at line 185 — which is why the performance_only case at unix.rs:287-292 passes, despite being a set with two distinct capacities (997…1024). The comment and the tests should name the actual mechanism.

  3. Cost paid before validation. prefer_high_capacity_cpus opens one sysfs file per allowed CPU (20 opens on GB10) in the first statement of each thread's closure (worker.rs:71, replay.rs:174, runtime.rs:568, parallel.rs:539), before any manifest validation or rejection check; runtime.rs:568 precedes the host-prefix-store check at 569-581, and parallel.rs:539 precedes the persistent-worker rejection at 540. Cheap in absolute terms, but it is work done on the startup path for ranks that are about to fail.

  4. Unrelated change in the same hunk. roce_proxy.c:1575 adds pthread_setname_np(…, "flare-roce"), which is a debugging improvement with no relation to the pinning policy; it is described in the PR body but is bundled into the same #ifdef __linux__ block. AGENTS.md:194-199 asks for one coherent outcome per PR. (The name itself is fine and matches the flare-* convention of the Rust threads.)

  5. C helper's stack footprint. roce_proxy.c:1516-1517 allocates int cpus[CPU_SETSIZE] and uint32_t caps[CPU_SETSIZE] (8 KiB with CPU_SETSIZE 1024) on the proxy thread's stack; harmless here but worth noting if the policy is kept and CPU_SETSIZE grows.


Verified as fine (no finding)


Open questions and what could not be found

  1. Is there a maintainer request behind this? I could not find an issue or maintainer statement authorizing CPU-affinity policy in Helios or in the vendored proxy; the related items in the local index (#577, #575, #574 — same author; #280 WFET parking; #556 DispatchRing) do not cover it. AGENTS.md:165-169 and :201-206 require an explicit maintainer request for a change of this kind; if one exists it should be linked, since it would also likely settle B1's shape (flag vs documented recommendation).
  2. Was the served dependency branch-identical? Only the cold-prefill experiment states "same core, no re-export". Whether the CV and tok/s figures compare the same exported core across arms cannot be determined from the description; a paired flare run on main and this head (per B2) would settle it.
  3. Does the policy help or hurt on a homogeneous 20-core host or a many-core Xeon/EPYC server when someone exposes cpu_capacity (for example a manually built kernel or a container image with a mounted sysfs)? The description calls x86_64 a guaranteed no-op, but that rests on the kernel not exposing the file, not on a guard in the code. eos/src/unix.rs:237 would happily narrow a 128-core EPYC to whatever CPUs sit within 90% of its maximum. This is a consequence of B1's lack of configuration, and only a test on such a host (or the explicit-setting fix) would settle it.
  4. No review comments or CI results exist on the head commit (0 reviews, no checks), so there is no repository-side discussion to weigh against this analysis.

Recommendation

Request changes. The mechanism is small, well-contained, and demonstrably effective at the placement effect it targets, and the author has been candid about host coverage. But as submitted it makes a magic-numbered host-scheduling decision for every Linux deployment with no configuration home (AGENTS.md:453-457, charter "No magic defaults"), duplicates the policy in Rust and C, suppresses the errors that would let anyone verify it (AGENTS.md:182-186), and backs it with measurements that never compare against main (charter "Bring real evidence", docs/design-review.md:106-114). The cleanest resolution is an explicit, operator-supplied affinity setting (or documentation of the cpuset recommendation), with a paired main-vs-head measurement and one test that covers the sysfs/sched_setaffinity path.