#1 [high] Should fix: roce_proxy.c's pin_high_capacity_cpus duplicates eos::prefer_high_capacity_cpus; call the Rust helper before roce_start instead (~66 lines)
helios/native/roce_proxy.c:1505-1570 (#ifdef __linux__ … #endif, pin_high_capacity_cpus) is a line-for-line C transcription of eos/src/unix.rs:172-248: same sched_getaffinity, same per-CPU /sys/devices/system/cpu/cpuN/cpu_capacity read, same 90% filter (cap*10 >= max*9), same <2 fallbacks, same setaffinity. Nothing in it is C-specific.
It is also unnecessary: helmos/native/roce_proxy.c:1661 roce_start() builds the proxy thread with pthread_create (line 1674) from RoceTransport::connect() (helios/src/execution/roce.rs:264-300, roce_start called at roce.rs:295). A new pthread inherits its creator's affinity mask and CPU set, so pinning the creating thread immediately before roce_start gives the proxy thread exactly the same mask the C helper would install for itself.
Smaller version — delete roce_proxy.c:1505-1570 entirely and keep only the one-line rename; then in helios/src/execution/roce.rs, before line 295:
flare_eos::prefer_high_capacity_cpus();
if unsafe { roce_start(self.context) } != 0 { … }
Saves ~66 added lines of C and leaves no duplicated policy (single threshold, single fallback rule). Also required by docs/roce-ring.md:360-364 and the file's own provenance header (roce_proxy.c:6-8: "Keep the source below identical so preparation and serving share the transport ABI"), which the added Flare-specific block violates. Keep pthread_setname_np(…, "flare-roce") (2 lines) — the PR's evidence uses the name.
Verified: roce_start is the only pthread_create of proxy_main (roce_proxy.c:1674) and has one caller (roce.rs:295); RoceTransport::connect is called at flare-cli/src/cluster.rs:203 and :250, both before serving starts.
#2 [high] Should fix: drop the three-tier "avoid single-core collapse" fallback and its test; the existing <2 guard already makes it a no-op (~44 lines)
eos/src/unix.rs:195-204 (the if selected.len() < 2 { … midpoint fallback … } block), the comment at 196-197, and the test eos/src/unix.rs:298-314 (select_high_capacity_cpus_avoids_single_core_collapse_on_three_tier_soc).
Why nothing is lost: the final guard at unix.rs:205 (selected.len() >= 2 && selected.len() < allowed.len()) already turns a sub-2 selection into None, i.e. "leave affinity alone", which is the safe behaviour the fallback claims to protect. The fallback only changes which set is chosen on a topology where exactly one CPU is within 90% of the maximum — a prime-core SoC. The charter scopes Flare to SM120/SM121 workstations and DGX Spark and says the project is "not interested in … broad hardware support" (charter Goals/How We Work). On the stated target (GB10, 10 X925 at 997-1024 + 10 A725 at 718-731) the 90% pass always selects 10 CPUs; the PR's own test data shows the fallback branch unreachable there.
Once the fallback goes, min_cap has no reader, so the whole min/max loop at unix.rs:176-184 collapses too, and the min_cap == max_cap early return at 185-187 is provably redundant: when every capacity is equal every CPU passes the 90% filter, so selected.len() == allowed.len() and line 205 already returns None.
Smaller version (~14 lines replacing 39 at unix.rs:167-210):
/// Select the high-capacity CPU subset of `allowed` when its capacities span
/// more than one tier. `None` means "leave this thread's affinity alone".
fn select_high_capacity_cpus(allowed: &[(usize, u32)]) -> Option<Vec<usize>> {
let max_cap = allowed.iter().map(|&(_, cap)| cap).max()?;
if allowed.len() < 2 || allowed.iter().any(|&(_, cap)| cap == 0) {
return None;
}
let selected: Vec<usize> = allowed
.iter()
.filter(|&&(_, cap)| u64::from(cap) * 10 >= u64::from(max_cap) * 9)
.map(|&(cpu, _)| cpu)
.collect();
(selected.len() >= 2 && selected.len() < allowed.len()).then_some(selected)
}
Surviving tests still pass unchanged: homogeneous (all selected → None), efficiency-only and performance-only single-tier cpusets (all selected → None), [(19,1024)] (len < 2 → None), [(0,0),(1,1024)] (zero capacity → None), and the GB10 split.
Saves ~10 (fallback) + 6 (min_cap loop) + 3 (min==max) + 17 (test) ≈ 36 lines; with the C copy removed per the other finding, the same 11-line fallback disappears from C too.
#7 [high] Summary: change is +226/−1; ≈107 lines removable (47%); the minimal form keeps parallel.rs + runtime.rs pins
Change size (from the diff): 7 files, +226/−1.
- eos/src/unix.rs +148 (functions 167-248 = 82 lines; tests 254-314 = 61 lines; blank/doc overhead)
- eos/src/windows.rs +3
- helios/native/roce_proxy.c +71
- helios/src/{server/runtime.rs,execution/parallel.rs,execution/worker.rs,replay.rs} +7/−1 (replay.rs accounts for the −1 and 3 of the +)
Confirmed subtractions, ranked by lines saved:
- ~66 lines — delete roce_proxy.c:1505-1570 (C duplicate of the Rust helper) and pin before
roce_startin helios/src/execution/roce.rs:295. Keep the pthread_setname_np line. - ~36 lines — delete the three-tier midpoint fallback (unix.rs:195-204) and its test (unix.rs:298-314); min/max loop and
min_cap == max_capguard fall out with it (unix.rs:176-187). 14-line replacement given. - ~4 lines — drop the pin from helios/src/replay.rs:171-176 (test/heliopause replay worker only).
- ~1 line — drop the pin from helios/src/execution/worker.rs:71 (bootstrap/qualification surface only).
Total ≈ 107 lines of the +226 (≈47%), with no behaviour the PR's own measurements depend on lost: the remaining pin on the flare-model thread (runtime.rs:568) plus the same mask inherited by the RoCE proxy thread reproduces the two placement results the PR reports. The peer-rank pin (parallel.rs:539) stays.
Files examined and found minimal: eos/src/windows.rs (stub is required), helios/src/execution/parallel.rs:539 (multi-host rank serving path, needed), helios/src/server/runtime.rs:568 (the flare-model serving thread, needed).
Potential pre-existing duplication not caused by this PR: helios/src/execution/threaded.rs:652-654 spawns the actual in-process per-rank executor threads (flare-rank-N) with no pin, so on a single-host TP core the WFET-serving threads still follow the unsigned scheduler. Mentioning as a gap, not a subtraction (I do not propose adding the call).
#8 [high] Research summary
Reviewed PR #576 (7 files, +226/−1) through the subtraction lens, against the charter (SM120/SM121 + DGX Spark scope, "smallest footprint in shared code", "not interested in broad hardware support") and docs/roce-ring.md's rule that the vendored proxy stay identical to the pinned dependency.
Four confirmed subtractions, ≈107 of the +226 lines (≈47%), recorded in the scratchpad with exact lines and replacement code:
-
~66 lines — the C helper is a copy of the Rust one and does not need to exist.
pin_high_capacity_cpus(roce_proxy.c:1505-1570) is a line-for-line transcription ofeos/src/unix.rs:172-248— same getaffinity, same sysfs reads, same 90% filter, same fallbacks. It is also redundant: the proxy thread is apthread_create(roce_proxy.c:1674) fromroce_start, whose only caller isRoceTransport::connect(helios/src/execution/roce.rs:295), so a pin on the creating thread gives the proxy the same mask — one call in roce.rs, and the C block goes. It additionally breaks the file's own provenance header (roce_proxy.c:6-8) and docs/roce-ring.md:360-364. Keep only thepthread_setname_npline, which the PR's evidence uses. -
~36 lines — the three-tier "avoid single-core collapse" fallback protects a branch that is already safe (unix.rs:195-204 + its test at 298-314). The final
selected.len() >= 2guard (line 205) already turns a sub-2 selection into a no-op, so the fallback only changes which set is picked on a prime-core SoC outside the project's targets; on GB10 it never fires. Removing it also emptiesmin_cap, collapsing the min/max loop and the provably redundantmin_cap == max_capearly return. I gave a 14-line replacement whose behaviour still satisfies every surviving test. -
~4 lines — replay.rs:171-176 wraps
run(...)in a closure only to add a pin on theflare-cudareplay worker, which the native server never spawns (it is heliopause'sGraphReplayWorkerand the CUDA integration tests). -
~1 line — worker.rs:71 pins
ExecutionWorker, which its own doc comment calls the bootstrap/qualification control surface; its only users are tp4_collective and heliopause. Meanwhile the real in-process per-rank threads (threaded.rs:652) get no pin — noted as a gap, not something I propose adding.
Checked and deliberately not proposed: the eos/src/windows.rs stub is load-bearing (lib.rs re-exports windows::* on Windows, and gating four call sites instead would be longer); the 90% multiply, the cpu_set_t scan, and the per-thread allocations have no shorter correct equivalent. The one open question is the charter-level "solve it in the right place": a deployment-only affinity fix is plausible, but the code cannot show that a static cpuset reaches the placement the PR measures.
Net: the change should not merge at 226 lines; the same reported placement follows from the flare-model pin plus the proxy inheriting that mask, at roughly half the size.
#9 [high] Charter quotes to cite in the report (smallest footprint, no broad hardware support, provenance, judged on merits)
Quotes the report should attach to the findings:
- "Look for the smallest footprint in shared code, or a way to solve it without new code at all. Good ideas in the wrong place will be declined" — charter, How We Work, "Solve the right problem in the right place" (bullet 1). Grounds findings 1 and 2 (the C duplicate is new code in the wrong layer; the fallback is code for a topology outside scope). It also grounds the open question about a deployment-only fix.
- "Stay focused. We want changes that help more people run Flare locally (#6). We're not interested in piling on extra model aliases, random switches, or broad hardware support." — charter, How We Work, bullet 2. Grounds finding 2 (three-tier / prime-core SoCs are outside the SM120/SM121 + DGX Spark scope stated in Goals, and the PR's own caveats say the path is untested).
- "PR descriptions: Expect four parts: why the change is needed, what changed, the claimed result, and the evidence backing it." — charter, Code Review Standards, last bullet. The PR meets this; noted only so the report does not fault the description.
- "Every PR is judged on its merits" / "Respect contributors" — charter, How We Work and Respect for the Community. Relevant because the PR is substantial and well evidenced: the report should say the measurement work is sound and the cuts are structural, not that the idea is unwelcome.
Code rule (not the charter, but the repo's own documented standard):
- docs/roce-ring.md:360-364 — "Flare vendors the serving proxy in
helios/native/roce_proxy.c… 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." Combined with the file's own header, roce_proxy.c:6-8 ("Vendored from FlashInfer's pinned preparation dependency … Keep the source below identical so preparation and serving share the transport ABI"), this makes a Flare-specific affinity block in that file a maintenance liability as well as a duplication. Note the PR is careful about ABI (no change, remains 14) — the objection is to editing the vendored body, which a rename alone already does.
#10 [high] Reduced-change shape and verification evidence (what I checked by search, so the report can state it plainly)
Minimal form of the change after the four subtractions:
- eos/src/unix.rs —
select_high_capacity_cpus(14 lines) +prefer_high_capacity_cpus(34 lines, unchanged) + 2 tests (GB10 split; homogeneous/single-tier) ≈ +60. - eos/src/windows.rs — +3 stub (unchanged).
- helios/src/execution/parallel.rs:539 — keep (multi-host peer serving loop).
- helios/src/server/runtime.rs:568 — keep (the
flare-modelthread that runs the WFER/WFET serving loop). - helios/src/execution/roce.rs — +1 line (
prefer_high_capacity_cpus()beforeroce_start). - helios/native/roce_proxy.c — +2 lines (the
#ifdef __linux__pthread_setname_np). - helios/src/execution/worker.rs and helios/src/replay.rs — untouched.
So 7 files / +226 becomes 6 files / ≈+66, and the two placement results the PR reports (execution thread and
flare-roceon X925 CPUs 5-9,15-19) still hold: the proxy thread inherits the mask its creator installed.
Verification performed (all by reading code / search at the PR head):
search_code prefer_high_capacity_cpus→ definition eos/src/unix.rs:216, stub eos/src/windows.rs:220, and exactly four call sites: parallel.rs:539, worker.rs:71, replay.rs:174, server/runtime.rs:568. No other callers, so the function's only consumers are these four (relevant to finding 1's replacement: adding a fifth call in roce.rs means removing the C copy, net unchanged API).search_code roce_start→ declared roce.rs:71, called roce.rs:295;pthread_create(&c->thread, NULL, proxy_main, c)at roce_proxy.c:1674 is the only creation of the proxy thread.search_code serve_rank→ flare-cli/src/main.rs:560 (serve_peer) and heliopause/src/python.rs:548, plus parallel/tests.rs:698; confirms parallel.rs:539 is on a real serving path.search_code ReplayWorkerin helios/src → no hit in server/ or execution/; hits only in replay.rs, lib.rs, tests, heliopause. Confirms finding 3.- worker.rs:36-40 doc comment read in full: "Synchronous control surface for bootstrap/qualification callers on other threads. The native scheduler owns its rank executor directly without this channel boundary." Confirms finding 4.
search_code affinities/taskset/CPUAffinity→ nothing in the repo sets process affinity today (only selene-manager's seccomp allowlist lists sched_getaffinity/sched_setaffinity, selene-manager/deploy/seccomp-io-uring.json:309,317). This matters: a new syscall use is not a regression, but the seccomp profile already permits it, so no accompanying policy change is needed — worth one sentence in the report so a reader does not go looking.- eos/src/lib.rs:9-16 read:
#[cfg(unix)] pub use unix::*;/#[cfg(windows)] pub use windows::*;— the Windows stub is load-bearing (entry 5). - No existing helper to reuse: eos has
lower_priority(unix.rs:77) for nice/SCHED_BATCH only; helios/src/os.rs just re-exports flare_eos. So findings are about duplication within this PR, not against pre-existing code.
#3 [medium] Nit: worker.rs:71 pins a bootstrap/qualification thread that never serves, while the real per-rank threads (threaded.rs:652) stay unpinned (1 line)
helios/src/execution/worker.rs:71 (flare_eos::prefer_high_capacity_cpus(); inside ExecutionWorker::start).
ExecutionWorker (worker.rs:36-40, doc comment: "Synchronous control surface for bootstrap/qualification callers on other threads. The native scheduler owns its rank executor directly without this channel boundary") is not the serving thread. The serving paths are:
- single-host: helios/src/server/runtime.rs:565-568,
flare-modelthread, which callsRankExecutor::newdirectly (runtime.rs:585); and - multi-host rank zero / in-process TP: helios/src/execution/threaded.rs:652-654,
flare-rank-Nthreads — which the PR does not pin at all.
Its only users are test/qualification tools: helios/tests/tools/tp4_collective.rs:122,134,156 and heliopause/src/python.rs:410-411 (ExecutionWorker::new / new_parallel). So the call pins a thread that never serves a request, and the PR still leaves the actual in-process per-rank executor threads (threaded.rs:652) unpinned — the placement the PR measures is flare-model's.
Removing worker.rs:71 saves 1 line and keeps the description's own list of "model, peer-rank, execution, and replay worker threads" consistent only if the execution thread is read as serve_rank/flare-model.
Jump: this one line is defensible as "keep the library entry point consistent"; it is a nit on lines, but worth flagging because it hides the threaded.rs gap.
#4 [medium] Nit: replay.rs:171-176 adds a 4-line closure only to pin the heliopause/test replay worker, which the native server never spawns (3 lines)
helios/src/replay.rs:171-176 — the closure is only to add the pin.
.spawn(move || {
flare_eos::prefer_high_capacity_cpus();
run(receiver, completion_sender, ready_sender)
})
ReplayWorker is published for Python (heliopause/src/python.rs:45-46) and used by CUDA integration tests (helios/src/runtime_core/{cooperative,event,programmatic_edge,shared_memory}_tests.rs, helios/tests/tools/*). It is not spawned by the native server: grep ReplayWorker in helios/src/server and helios/src/execution returns nothing, and helios/src/server/runtime.rs uses RankExecutor.
Removing the call restores the one-line .spawn(move || run(receiver, completion_sender, ready_sender)) at replay.rs:173 and saves the 4-line closure (net −3 lines). Nothing the description claims is served is lost: none of the four measured critical threads (flare-model, flare-roce, plus the threaded rank threads) is a flare-cuda replay worker.
Caveat to note in the report: if maintainers consider heliopause's GraphReplayWorker a latency-critical serving thread, this stays. I read the PR's own measurements as naming only the execution/WFET thread and the RoCE proxy.
#6 [medium] Rejected candidates and open question: deployment-only CPUAffinity alternative; magic numbers; heap use; cpu_set_t loop
Deliberately rejected candidates, so the report does not re-litigate them:
-
"The change is unnecessary; operators should set CPUAffinity / taskset." Rejected as a subtraction finding. The charter says to look for "a way to solve it without new code at all", but the PR's measured A/B on one live server (144.88 vs 123.66 tok/s) is about placement, which a static systemd cpuset (the default 0-19 quoted in the PR) does not fix, and pinning the whole process to 5-9,15-19 would also move HTTP/frontend/offload threads off the shared core budget. Cannot show from the code that a deployment-only fix suffices. Report it as an open question only.
-
Threshold 90% and midpoint as two magic numbers. Kept as a clamp only: the fallback removal (see the fallback finding) removes the second number entirely; the remaining
*10 >= *9is used by three tests and removing it would leave nothing to select. -
u64::from(cap) * 10 >= u64::from(max_cap) * 9. Could becap >= max_cap / 10 * 9? No — that truncates differently and changes behaviour at boundaries; the widening to u64 costs nothing and is correct. -
let _ = unsafe { libc::sched_setaffinity(…) };ignoring the result. Correct for a best-effort hint (no I/O error can be surfaced usefully from a thread entry point); not a subtraction. -
max_cpus = std::mem::size_of::<libc::cpu_set_t>() * 8andCPU_ISSETloop. This is the only portable way with libc's fixed-size cpu_set_t;sched_getaffinityreturns the mask size but Rust's libc exposesCPU_COUNT/CPU_ISSETonly against the fixed struct. No shorter equivalent. -
heap allocations in prefer_high_capacity_cpus(aVecand aStringper allowed CPU). Runs once per thread at startup, ~20 sysfs reads. Not worth an optimisation; not a subtraction. -
Anything needing a new test, comment, doc or option — out of lens.
#5 [low] No finding: windows.rs no-op stub is required by eos/src/lib.rs's cfg re-export; gating four call sites instead would be longer
eos/src/windows.rs:219-220 adds pub fn prefer_high_capacity_cpus() {} (2 lines incl. doc).
The stub is required as written: eos/src/lib.rs:9-16 re-exports unix::* on #[cfg(unix)] and windows::* on #[cfg(windows)], and prefer_high_capacity_cpus is called unconditionally from helios. Without a Windows definition the Windows build fails. So the tutorial alternative is to not call it from four places and instead gate the four call sites:
#[cfg(unix)]
flare_eos::prefer_high_capacity_cpus();
That deletes the Windows stub (2 lines) but adds #[cfg(unix)] four times (4 lines) — net worse, and it spreads a platform condition into helios. Recommend keeping the stub. Also check eos/src/unix.rs:215/247: the function has one prefer_high_capacity_cpus body selected by #[cfg(target_os = "linux")] / #[cfg(not(target_os = "linux"))] inside the unix module, so BSD/macOS get the empty body without a second stub — that is already the minimal form.
Conclusion: no finding here; the PR note "the eos/src/windows.rs no-op stub was not compiled on a Windows host" is a coverage gap, not a subtraction, and I should not propose adding a test.