Conventions report · NVIDIA/hyperflare-inference #576

Raw Markdown for agents: https://autobot.eidonix.com/p/91fe53b6-5d0d-4ecf-b5b2-7267973ab7ed.md

Conventions and duplication review — PR #576 (pin Helios/RoCE-proxy threads to high-capacity CPUs)

Key findings

Two confirmed findings, neither blocking.

  1. Should fix — one policy, two languages, no shared source, and the second copy is an unmarked edit to a vendored file. pin_high_capacity_cpus() in helios/native/roce_proxy.c:1505-1570 is a line-for-line reimplementation of select_high_capacity_cpus + prefer_high_capacity_cpus in eos/src/unix.rs:172-245. eos/ is documented as the single home for host OS operations (AGENTS.md:20-22), and roce_proxy.c is documented as byte-identical to the pinned FlashInfer source after its provenance header (roce_proxy.c:6-8, NOTICE:18-19, docs/roce-ring.md:361-364). The new block, plus the "flare-roce" thread name at :1575, breaks the second rule without any marker distinguishing Flare-local code from vendored code.
  2. Nit — the new eos helper departs from the only precedent for per-thread scheduling changes, lower_priority(nice) (eos/src/unix.rs:77-83 / eos/src/windows.rs:160-164): it hardwires its policy instead of taking a parameter, returns () and drops sched_setaffinity's error while neighbouring eos helpers report their outcome, adds a stub that duplicates windows.rs:219-220, and is called directly as flare_eos::… rather than through the crate::os:: shim every other OS call in Helios uses.

Verified as already conforming: the four new call sites follow the existing "name the thread, then configure it inside the closure" pattern, and "flare-roce" fits the existing flare-* naming scheme. No pre-existing CPU-affinity helper existed to reuse. Coverage note (not a finding): the in-process flare-rank-{n} TP threads get no call.


Should fix

1. helios/native/roce_proxy.c:1505-1570 — the C helper reimplements the Rust selector, and the vendored file is supposed to stay identical to upstream

What is wrong. The new static void pin_high_capacity_cpus(void) is an element-for-element port of the Rust code added in the same PR:

Policy element C (roce_proxy.c) Rust (eos/src/unix.rs)
sysfs path :1526 snprintf(…, "/sys/devices/system/cpu/cpu%d/cpu_capacity") :227 format!("/sys/devices/system/cpu/cpu{cpu}/cpu_capacity")
give up on first unreadable/zero capacity :1528-1536 :228-233
90% threshold :1550 (uint64_t)caps[i] * 10 >= (uint64_t)max_cap * 9 :192 u64::from(cap) * 10 >= u64::from(max_cap) * 9
midpoint fallback (never collapse to one core) :1555-1565 cap*2 > min+max :196-204
safety gate selected >= 2 && selected < count :1566 :205

Two copies of one policy in two languages with no shared source. Any future change to the threshold, the fallback, or the sysfs path must be made twice, and only the Rust copy is tested: eos/src/unix.rs:254-314 covers GB10 two-tier, homogeneous, single-tier, zero-capacity and three-tier topologies, while the C copy has no test and is compiled only under --features roce (helios/build.rs:67-76).

Why it matters (duplication convention). AGENTS.md:20-22: "The eos/ crate holds the host operating-system operations that Helios and Selene use." The Helios side does not add OS code of its own — helios/src/os.rs:8 is nothing but pub(crate) use flare_eos::*;. A host-OS policy implemented a second time inside a C file in helios/native/ bypasses that arrangement entirely.

Why it matters (vendored-file convention). Three places state the same rule for this file:

The new #ifdef __linux__ block and the pthread_setname_np(..., "flare-roce") at :1575 are Flare-local behaviour with no marker separating them from upstream text, so the next parity check cannot tell vendored lines from local ones. docs/TODO.txt:80-86 already tracks "Restore preparation/serving RoCE proxy parity … verifying their ABI and collective-region layouts together"; an unmarked divergence makes that reconciliation harder, and preparation (which runs the pinned FlashInfer proxy) will not get the same pinning, so preparation and serving no longer behave alike on the asymmetric hosts this PR targets.

Fix. Either (a) put the selection policy in one place compiled for both consumers (a small shared header/source that the Rust crate links and the C proxy includes), or (b) at minimum delimit the added block and the thread-name line as a clearly marked Flare addition (comment banner naming this PR/reason) and record the divergence next to the parity procedure in docs/roce-ring.md:355-364 and in the provenance header at roce_proxy.c:6-8, so the parity check knows what to exclude.

2. helios/native/roce_proxy.c:1575 — a second unmarked local behaviour change in the same vendored function

(void)pthread_setname_np(pthread_self(), "flare-roce"); changes what ps/top and perf/nsys see for the vendored proxy thread. The name fits Helios's existing flare-* scheme (helios/src/execution/worker.rs:69 "flare-execution", helios/src/replay.rs:172 "flare-cuda", helios/src/server/runtime.rs:566 "flare-model"), so the naming itself is fine; the problem is only that it is another silent edit to a file declared unchanged. Same fix as finding 1: mark it, and record it.


Nits

3. eos/src/unix.rs:212-248 (and :247-248) — API shape departs from the lower_priority precedent

4. helios/src/execution/parallel.rs:539, worker.rs:71, replay.rs:174, server/runtime.rs:568 — call sites bypass the crate::os:: shim

Every other host-OS call in Helios goes through the crate shim crate::os:: (helios/src/os.rs:8 re-exports flare_eos::*): crate::os::lower_priority(NICE) at helios/src/offload/transfer.rs:282, crate::os::raise_open_file_limit at helios/src/runtime_core/protection.rs:356, crate::os::page_size/map_host at helios/src/cuda.rs:431 (not opened),1478, and ~15 more (helios/src/engram/reader.rs:75,86,190, helios/src/runtime_core/archive.rs:922 (not opened),1052, helios/src/startup.rs:498 (not opened), …). The four new lines call flare_eos::prefer_high_capacity_cpus() directly, which skips the one indirection that exists so Helios can adapt or wrap an OS operation in one place (it is what lets os.rs add the crate-local cuda_library/terminal_size variants alongside the re-export). helios/src/lib.rs:36 similarly re-exports raise_open_file_limit. Nit: use crate::os::prefer_high_capacity_cpus() at all four sites.

5. Documentation — no design/operating document records the new affinity policy

docs/prefix-cache-offload.md:863-867 sets the repository's bar for exactly this kind of change: "Both use SCHED_BATCH with a positive nice value to reduce contention with the model worker … Adding CPU affinity requires a serving-latency measurement that shows a benefit." The PR description does supply measurements, so the bar is met in the PR body, but nothing durable records the policy: docs/standards/docs/operating.md (not opened)/docs/roce-ring.md do not state that critical serving threads are narrowed to the high-capacity tier, that this is a no-op on x86_64, or that the 5-9,15-19 placement is a qualified configuration with the numbers behind it. AGENTS.md:52-59 also draws the line between design documents (state support as present qualification: what is implemented, on which hardware, and what is not) and docs/TODO.txt (unrun checks, pending measurements). Nit: record the policy and its qualification boundary in the operating/roce-ring docs, citing the measured benefit, rather than leaving it in the PR description only.


Checked and cleared (recorded so they are not re-raised)

Open questions / what could not be settled from the code