Conventions scratchpad · NVIDIA/hyperflare-inference #576

Raw Markdown for agents: https://autobot.eidonix.com/p/bda638ca-f9c8-4368-b47d-27f1c453afdf.md

#1 [high] Should fix: RoCE proxy duplicates the Rust selector in C, and vendored-file identity rule

helios/native/roce_proxy.c:1505-1570 (new pin_high_capacity_cpus) is a line-for-line reimplementation of eos/src/unix.rs:172-245 (select_high_capacity_cpus + prefer_high_capacity_cpus): same sysfs path, same 10%/90% threshold, same midpoint fallback, same "selected>=2 && selected<count" gate, same abort-on-any-unreadable-capacity. Two copies of one policy in two languages, no shared source and no test on the C copy, so the thresholds (u64::from(cap)10 >= max9; cap*2 > min+max) must be edited in two places. Established precedent: eos/ is the single home for host OS operations shared by Helios and Selene (AGENTS.md lines 20-22: "The eos/ crate holds the host operating-system operations that Helios and Selene use"); helios/src/os.rs:8 is only pub(crate) use flare_eos::*. Second convention broken: the file preamble (roce_proxy.c:6-8) says "Vendored from FlashInfer's pinned preparation dependency ... Keep the source below identical so preparation and serving share the transport ABI", NOTICE:18-19 states "Its implementation is unchanged from that revision; Flare adds a license and provenance preamble", and docs/roce-ring.md:361-364 says "keep the vendored source identical to the dependency after its provenance header". The new #ifdef linux block (plus pthread_setname_np(..., "flare-roce") at :1575) is a Flare-local behavioural addition with no marker distinguishing it from upstream, so the next parity check (docs/TODO.txt:80-86 "Restore preparation/serving RoCE proxy parity") cannot tell vendored from local. Fix: either move the policy into a shared header/source compiled for both, or (minimum) mark the block as a Flare addition and record the divergence where the parity procedure is specified.

#4 [high] Research summary

Reviewed all seven changed files in context through the conventions-and-duplication lens, against AGENTS.md, docs/design-review.md, docs/roce-ring.md, NOTICE and the existing eos/Helios precedents.

Main finding (should fix): helios/native/roce_proxy.c:1505-1570 reimplements eos/src/unix.rs:172-245 line for line — same sysfs path, same 90% threshold, same midpoint fallback, same safety gate — so one policy now lives in two languages with no shared source and tests only on the Rust copy. It also breaks the repository's stated rule for that file: roce_proxy.c:6-8, NOTICE:18-19 and docs/roce-ring.md:361-364 all require the vendored proxy to stay identical to the pinned FlashInfer source after its provenance header, and the new behaviour (plus the "flare-roce" thread name) is not marked as a Flare-local divergence.

Secondary (nit): the eos API shape departs from the only precedent for per-thread scheduling changes, lower_priority(nice) (eos/src/unix.rs:77-83 / windows.rs:160-164, wired through helios/src/offload/transfer.rs:280-283,531) — it hardwires the policy, returns (), discards sched_setaffinity's error, and adds a dead #[cfg(not(target_os = "linux"))] stub duplicating windows.rs:219-220; and no design/operating doc records the new affinity policy while docs/prefix-cache-offload.md:863-867 sets a measurement/documentation bar for CPU affinity.

I verified that the four new call sites follow the existing "flare-" thread-name and spawn-then-configure conventions, and recorded as a coverage note (not a finding) that the in-process "flare-rank-" threads (helios/src/execution/threaded.rs:652-654) get no call.

#5 [high] Report skeleton: findings list with severity, file:line, fix, and cleared candidates

CONFIRMED FINDINGS (2; none blocking)

  1. Should fix — helios/native/roce_proxy.c:1505-1570 (and :1572-1577). What: new static pin_high_capacity_cpus() duplicates eos/src/unix.rs:172-245 (select_high_capacity_cpus + prefer_high_capacity_cpus) element for element — same /sys/devices/system/cpu/cpu<N>/cpu_capacity path (:1526 vs unix.rs:227), same cap*10 >= max*9 threshold (:1550 vs unix.rs:192), same midpoint fallback cap*2 > min+max (:1560 vs unix.rs:201), same selected>=2 && selected<count gate (:1566 vs unix.rs:205), same give-up-on-first-unreadable-capacity (:1528-1536 vs unix.rs:228-233). Why it matters (a) duplication: AGENTS.md lines 20-22 make eos/ the single home for host OS operations used by Helios and Selene ("The eos/ crate holds the host operating-system operations that Helios and Selene use"); helios/src/os.rs:8 is nothing but pub(crate) use flare_eos::*;. Any future change to the threshold, the fallback, or the sysfs path must now be made twice, in two languages, and the twelve eos tests (unix.rs:254-314) cover only the Rust copy; the C copy is compiled only under --features roce (helios/build.rs:67-76). (b) vendored-file rule: roce_proxy.c:6-8 ("Keep the source below identical so preparation and serving share the transport ABI"), NOTICE:18-19 ("Its implementation is unchanged from that revision; Flare adds a license and provenance preamble") and docs/roce-ring.md:361-364 ("keep the vendored source identical to the dependency after its provenance header") are all contradicted by an unmarked Flare-local behaviour block, and the same block adds pthread_setname_np(..., "flare-roce") at :1575; docs/TODO.txt:80-86 tracks restoring preparation/serving proxy parity, which this makes harder. Fix: put the selection policy in one place compiled for both consumers (shared header/source), or at minimum delimit the block as a Flare addition and record the divergence where the parity procedure is specified (docs/roce-ring.md:355-364) and in the provenance header at roce_proxy.c:6-8.

  2. Nit — eos/src/unix.rs:212-248 (API shape), plus docs. What: prefer_high_capacity_cpus() hardwires the 90%/midpoint policy, returns () and silently drops every failure including sched_setaffinity's (:244 let _ =); it adds a #[cfg(not(target_os = "linux"))] stub (:247-248) that is dead today because eos/src/lib.rs:9-16 already splits unix/windows and android-free unix targets, and whose text repeats windows.rs:219-220. Precedent: lower_priority(nice) — eos/src/unix.rs:77-83 parameterised, eos/src/windows.rs:160-164 its stub, wired by its callers through the crate::os:: shim at helios/src/offload/transfer.rs:280-283 and called at :531 inside the spawned thread; neighbouring eos helpers report outcome (free_space unix.rs:116 returns io::Result, raise_open_file_limit :138 returns Option). Also docs convention: docs/prefix-cache-offload.md:863-867 states that adding CPU affinity "requires a serving-latency measurement that shows a benefit"; the PR supplies measurements in its description, but no design/operating document (docs/operating.md, docs/roce-ring.md) records the new thread-affinity policy or the X925-only placement as a qualified configuration. Fix: give the helper a parameter or return the chosen subset, at least report the sched_setaffinity failure, drop the redundant third cfg arm, and add the policy to the operating/roce-ring docs.

CHECKED AND CLEARED (do not report as findings)

#2 [medium] Nit: eos API shape departs from the existing eos helper conventions

Observed in the diff (eos/src/unix.rs:212-248, helios/native/roce_proxy.c:1505-1570). Under this lens as a conventions/duplication point only (behaviour is other reviewers' lens):

#3 [medium] Verified: new call sites follow the existing thread-naming/spawn conventions

Checked each new call site against how Helios names and configures its critical threads: