Recommendation: Changes Requested
Pinning latency-critical execution and RoCE proxy threads to high-capacity CPUs on asymmetric ARM64 Linux hosts (DGX Spark GB10) directly addresses a real scheduling jitter problem, and the core tier-selection helper in eos/src/unix.rs cleanly respects existing operator cpusets and no-ops on homogeneous or x86_64 systems. However, two concrete blockers remain (consistent with @original-el8's review, plus critical system-level interactions verified against main): (1) editing vendored helios/native/roce_proxy.c breaks its byte-identity contract with FlashInfer and duplicates 66 untested C lines when main (#589) already provides the Flare-owned roce_proxy_dlopen.c wrapper; and (2) pinning at entry to flare-model (helios/src/server/runtime.rs:568) leaks the narrowed X925-only mask to background offload, disk, image-prep, and KV-codec threads — halving the flare-kv-codec-* rayon pool on GB10 — while moving that call alone would silently unpin same-process threaded TP ranks (flare-rank-*).
Merge Risk
Level: High
- Vendored transport provenance & base-branch conflict: Direct edits to
helios/native/roce_proxy.cfalsifyNOTICE:16-19and collide conceptually withmain's #589 (ba3afb13), which moved compilation tohelios/native/roce_proxy_dlopen.cspecifically to keeproce_proxy.cbyte-for-byte identical to FlashInfer; #589 also modifiedeos/src/unix.rsin the samemod testsregion. - Unintended background-thread & codec-pool narrowing: Pinning at the start of
flare-modelconfinesSCHED_BATCH/nice(10)offload, disk, image-prep, andflare-kv-codec-*threads to performance cores and silently halvesflare-kv-codec-*parallelism viaavailable_parallelism()on prefix-cache workloads (unmeasured by this PR). - Zero aarch64 CI coverage:
native-serving.ymlruns only on x86_64 Linux and Windows, where/sys/devices/system/cpu/cpuN/cpu_capacitydoes not exist; neitherprefer_high_capacity_cpus()norpin_high_capacity_cpus()executes in CI.
Walkthrough
eos/src/unix.rs:172-248&eos/src/windows.rs:219-220: addsselect_high_capacity_cpus(filtering CPUs ≥ 90% of max capacity with a midpoint fallback and ≥ 2-CPU guard), Linuxprefer_high_capacity_cpus(reading/sys/devices/system/cpu/cpu{N}/cpu_capacityfor CPUs insched_getaffinityand applyingsched_setaffinity), non-Linux/Windows no-op stubs, and 3 unit tests forselect_high_capacity_cpus(:254-314).helios/src/server/runtime.rs:568: callsflare_eos::prefer_high_capacity_cpus()as the first statement of theflare-modelthread, prior toRankExecutor::new,crate::offload::open, andImagePreparation::new.helios/src/execution/parallel.rs:539: callsflare_eos::prefer_high_capacity_cpus()at entry toserve_rank(multi-host peer rank execution loop, before manifest validation).helios/src/execution/worker.rs:71&helios/src/replay.rs:174: callflare_eos::prefer_high_capacity_cpus()at entry to theflare-executionandflare-cudaworker threads.helios/native/roce_proxy.c:1505-1577: duplicates the Linuxcpu_capacityaffinity-narrowing logic in C (pin_high_capacity_cpus) and callspthread_setname_np(pthread_self(), "flare-roce")pluspin_high_capacity_cpus()at the top ofproxy_main.
Pre-merge Checks
- [PASS] Security / malicious screen: Read-only
/sys/devices/system/cpu/cpuN/cpu_capacityinteger reads and standard thread affinity/naming syscalls; no env vars, network I/O, or unsafe input handling. - [WARN] Charter & value fit: Right problem and right layer for DGX Spark, but editing vendored
roce_proxy.cbreaks an explicit in-tree invariant reinforced onmainby #589, and leaking affinity onto offload threads contradictsdocs/prefix-cache-offload.md:863-867. - [WARN] Related / duplicate / conflict check: No duplicate affinity work on
main, butmainis 11 commits ahead (50c876df), including #589 (ba3afb13) which addedhelios/native/roce_proxy_dlopen.c, changedhelios/build.rs:67-77, and added tests toeos/src/unix.rs:207-248(rebase required). Sibling open PR #577 by the same author also editshelios/native/roce_proxy.c. - [WARN] Tests & verification evidence: Unit tests cover only the pure
select_high_capacity_cpusselector;native-serving.yml:16-21,47,101-113runs x86_64 Linux + Windows only (rdmajob iscargo checkonly), so neither the Linux ARM64 affinity path nor the C helper runs in CI. All GB10 benchmark numbers are author-supplied and do not cover prefix-cache offload or CPU KV-codec workloads.
Blockers
-
Vendored
helios/native/roce_proxy.cdivergence and duplicated untested C logic (helios/native/roce_proxy.c:1505-1577)- Verified behavior & impact: Adding
pin_high_capacity_cpus()and calls insideproxy_mainmodifies a vendored FlashInfer file whose own header (helios/native/roce_proxy.c:6-8),NOTICE:16-19, anddocs/roce-ring.md:360-364explicitly require keeping identical to FlashInfer's pinned source. Since this PR branched, #589 (ba3afb13) merged onmainadding the Flare-ownedhelios/native/roce_proxy_dlopen.c:7-9,216-236(which#include "roce_proxy.c"and explicitly states "keeping the vendored roce_proxy.c byte-for-byte identical to FlashInfer") and updatedhelios/build.rs:69-74to compile onlyroce_proxy_dlopen.c. The 66-line C function also duplicateseos/src/unix.rs:172-245with no test coverage. - Concrete fix (choose one, after rebasing onto
main):- Preferred (zero vendored diff, zero duplicated C): Revert all edits to
helios/native/roce_proxy.c. Apply affinity from Rust aroundroce_start(self.context)inhelios/src/execution/roce.rs:295using a scoped save-and-restore affinity guard (savesched_getaffinity, callprefer_high_capacity_cpus(), callroce_start, then immediately restore the caller's mask). Important: Do not omit the restore —RoceTransport::connect(roce.rs:295) runs onflare-cli's main thread (flare-cli/src/cluster.rs:203,250) beforeBootstrap::load(flare-cli/src/main.rs:623),Server::start(:631), and peerjoin_peer(cluster.rs:254), so an unscoped pin there would narrow the entire process (shrinkingFrontend'sEncodeThreadBudgetathelios/src/frontend/mod.rs:334,1121and confining Tokio/HTTP and peer offload threads to X925). To preserve the"flare-roce"thread name (which the placement check relies on), wrap the singlepthread_createcall (roce_proxy.c:1674) inhelios/native/roce_proxy_dlopen.cvia#define pthread_create ...(matching its existingibv_*wrapper pattern at:216-232) and callpthread_setname_np(*thread, "flare-roce")on success. - Alternative: Land FlashInfer PR #156 first, re-vendor
roce_proxy.cverbatim from the updated pinned commit, and updateNOTICE:17to the new commit SHA.
- Preferred (zero vendored diff, zero duplicated C): Revert all edits to
- Verified behavior & impact: Adding
-
Child-thread affinity inheritance in
flare-modelconfines demoted background threads, halves the KV-codec pool, and hides a threaded-TP coverage trap (helios/src/server/runtime.rs:568,selene/src/shared/codec.rs:41,helios/src/execution/threaded.rs:652-655)- Verified behavior & impact: Because
flare_eos::prefer_high_capacity_cpus()is the first statement of theflare-modelclosure (runtime.rs:568), Linux affinity inheritance propagates the X925-only mask to every child thread spawned during startup:crate::offload::open(runtime.rs:698) →flare-offload-{rank}(helios/src/offload/transfer.rs:509-535, demoted viaSCHED_BATCH+NICEat:531) andflare-offload-disk(selene/src/offload.rs:676→selene/src/disk.rs:358-360,470,489-491, also demoted viaSCHED_BATCH+NICE).ImagePreparation::new(runtime.rs:721→runtime.rs:1011).- Downstream KV-codec regression: When
flare-offload-{rank}lazily initializesselene/src/shared/codec.rs:37-60(helios/src/offload/transfer/codec.rs:353,514,751),std::thread::available_parallelism()(selene/src/shared/codec.rs:41) honors the inheritedsched_getaffinitymask. On GB10 (10 X925 + 10 A725),flare-kv-codec-*silently shrinks from20 / 2 = 10threads to10 / 2 = 5threads, and all 5nice(10)codec workers (:52) are pinned onto X925 alongside the model worker and RoCE proxy — directly contradictingdocs/prefix-cache-offload.md:863-867("Adding CPU affinity requires a serving-latency measurement that shows a benefit"). - Subtle interaction with moving
:568:flare-rank-{1..N}in same-process threaded TP (helios/src/execution/threaded.rs:652-655) has no direct pin call and is currently pinned only by inheritingflare-model's mask viaRankExecutor::new(runtime.rs:585). Movingruntime.rs:568down to beforeworker.runalone will silently unpin all threaded-TP peer ranks.
- Concrete fix:
- Move
flare_eos::prefer_high_capacity_cpus();inhelios/src/server/runtime.rsfrom:568to right beforeworker.run(&mut executor)(:726), afterRankExecutor::new,crate::offload::open, andImagePreparation::newhave spawned their background threads. - Add an explicit
flare_eos::prefer_high_capacity_cpus();at entry to theflare-rank-*thread closure inhelios/src/execution/threaded.rs:654so same-process threaded TP ranks remain explicitly pinned without relying on parent inheritance.
- Move
- Verified behavior & impact: Because
Should Fix
-
Rebase onto
main(resolving #589 drift ineos/src/unix.rsandhelios/build.rs)main(50c876df) has 11 commits above this PR's base, including #589 (ba3afb13) which addedmap_host_advises_hugepages_and_prefaults_zeroed_pagestoeos/src/unix.rs:207-248and introducedhelios/native/roce_proxy_dlopen.c+helios/build.rs:67-77. Rebasing is required before merge and unlocks the Flare-owned wrapper for Blocker 1.
-
serve_rankmutates the caller's thread affinity permanently and before validation (helios/src/execution/parallel.rs:539)- Verified behavior & impact: Unlike the other call sites (which run on dedicated newly spawned threads),
serve_rankruns on the caller's thread (flare-cli/src/main.rs:560, which exits after return, andheliopause/src/python.rs:548, which runs on the Python interpreter thread insidepy.detach). Callingprefer_high_capacity_cpus()at:539narrows the caller's affinity even if early validation rejects the manifest (:540-550), never restores it on return, and is undocumented in# Safety(:529-532). (Note: do not delete pinning fromserve_rank, as it IS the peer execution loop for multi-host TP ranks 1..N.) - Concrete fix: Move the affinity narrowing after manifest validation (
parallel.rs:550) and use the same scoped save-and-restore RAII affinity guard recommended forroce_startin Blocker 1 so any caller (especially embedded Python viaheliopause) gets its original affinity mask restored on return.
- Verified behavior & impact: Unlike the other call sites (which run on dedicated newly spawned threads),
Subtract / Simplify
- Delete the 66-line C duplicate in
helios/native/roce_proxy.c:1505-1570(covered in Blocker 1) — eliminates the entire duplicated, untested C implementation in favor of the single unit-tested Rust helper ineos/src/unix.rs. - Delete the speculative three-tier fallback and its test (
eos/src/unix.rs:195-204,:298-314) — 27 lines that only trigger on three-tier SoCs (1 prime + mid + little cores), which are not a supported Flare target (AGENTS.md:188-193: no speculative compatibility/fallback layers). The existingselected.len() >= 2 && selected.len() < allowed_with_capacity.len()check at:205already guarantees the selector never collapses onto a single core. - Make
select_high_capacity_cpusprivate (eos/src/unix.rs:172) —eos/src/lib.rs:12usespub use unix::*;, leakingselect_high_capacity_cpusintoflare-eos's public crate API on Unix only (asymmetric with Windows) despite having no external callers. Change to#[cfg(any(target_os = "linux", test))] fn select_high_capacity_cpus(...)(gating avoids adead_codewarning on non-Linux Unix targets like macOS).
Nits
None. (Note: @original-el8's existing review item 3 regarding commit-message text and Design-Signed-Off-By hygiene remains to be addressed on rebase/amend.)
Dropped on verification
flare-input-records(selene/src/input.rs:268-271) claimed to inheritflare-model's narrowed mask: Verified false.InputStore::start_boundedis called insideselene/src/offload.rs:572(prepare_with_inputs, during core loading on the main thread) beforeModelRuntime::startextractsbinding.inputs()athelios/src/server/runtime.rs:531-534and spawnsflare-modelat:565.helios/src/frontend/mod.rs:333-337(default_parallel_encode_threads) claimed to share theavailable_parallelism()shrinkage hazard: Verified false under the current diff.Frontendis constructed athelios/src/frontend/mod.rs:1121viaBootstrap::load(flare-cli/src/main.rs:623) on the main thread beforeServer::start/ModelRuntime::start. (It would become affected only if someone naively narrowed the main thread aroundroce_startwithout restoring it — captured in Blocker 1's fix guidance.)- Correctness F4 suggested fix ("drop the
serve_rankcall site and let the rank's own executor closure pin itself"): Verified false/harmful.serve_rank(helios/src/execution/parallel.rs:533-674) does not spawn a separate executor thread; it is the peer rank's execution loop on multi-host TP (flare-cli/src/main.rs:560). Dropping it would unpin ranks 1–3 on GB10 TP4. Replaced with scoped save-and-restore after validation in Should Fix #2. - Correctness F7 & Value Prop ("silent/unconfigurable affinity violates charter's 'no magic defaults'; add flag/config/logging"): Dropped. Adding a config switch or env var contradicts
AGENTS.md:188-193,449-452, andflare-eoshas zero logging dependencies (eos/Cargo.toml) and already implementslower_priority(eos/src/unix.rs:77-83) silently in the same module. - Correctness F6 ("
selected.len() >= 2floor should take an expected thread count for2P + kEcpusets"): Dropped as speculative complexity for unsupported hardware (AGENTS.md:188-193). - Subtraction F3 ("collapse non-Linux + Windows stubs into
eos/src/lib.rsand dropeos/src/windows.rs"): Dropped. Verifiedeos/src/windows.rs:150,215(release_page_cache,raise_open_file_limit) already establish the crate's uniform pattern of matching Unix/Windows module stubs re-exported viaeos/src/lib.rs:9-16. - Subtraction F4 ("delete
ExecutionWorker::startandReplayWorker::spawncall sites atworker.rs:71andreplay.rs:174"): Dropped as low-signal over-pruning; both are clean 1-line calls on dedicated execution threads with no offload children, keeping qualification benchmarks consistent with serving on GB10. - Doc/TODO update requests (
THIRD_PARTY_NOTICES.md,docs/roce-ring.md,docs/prefix-cache-offload.md,docs/TODO.txt): Dropped as unnecessary once Blockers 1 and 2 are fixed properly (keepingroce_proxy.cidentical and keeping offload/codec threads unpinned preserves all existing docs as accurate). - Commit-body verification (
eb2fdigest,Antigravitymodel name,"follow immediately"wording): Could not be independently verified with available tools (commit message body not exposed); already tracked in@original-el8's review item 3 and not re-asserted as an independently verified finding.