Skip to content

Pin Helios execution and RoCE proxy threads to high-capacity CPUs on asymmetric Linux topologies - #576

Open
fordbmorris wants to merge 1 commit into
NVIDIA:mainfrom
fordbmorris:pr/cpu-capacity-pinning
Open

fordbmorris wants to merge 1 commit into
NVIDIA:mainfrom
fordbmorris:pr/cpu-capacity-pinning

Conversation

@fordbmorris

@fordbmorris fordbmorris commented Nov 28, 2026 •

Copy link
Copy Markdown

Why

On asymmetric ARM64 Linux SoCs such as NVIDIA GB10 (DGX Spark: 10 Cortex-A725 efficiency cores with sysfs cpu_capacity 718–731 alongside 10 Cortex-X925 performance cores with cpu_capacity 997–1,024), the Linux scheduler places Helios execution threads and the busy-polling RoCE proxy thread onto efficiency cores on some launches and performance cores on others. Efficiency-core placement slows one-shot RoCE collectives, inflates inter-graph host wake gaps, and creates launch-to-launch timing variance that distorts speculative drafting choices.

What Changed

  • eos/src/unix.rs (+ no-op stub in eos/src/windows.rs): add select_high_capacity_cpus and prefer_high_capacity_cpus, which intersect strictly with the thread's existing sched_getaffinity mask, read /sys/devices/system/cpu/cpu<N>/cpu_capacity, select CPUs >= 90% of max allowed capacity (falling back above midpoint to never collapse below 2 cores), and no-op when cpu_capacity is absent, homogeneous, or already single-tier.
  • Defer flare_eos::prefer_high_capacity_cpus() in Helios critical worker threads until after child-thread spawning so background threads retain the unnarrowed process affinity mask:
    • helios/src/server/runtime.rs (flare-model): called after RankExecutor::new, crate::offload::open (host prefix offload, KV codec pool, and disk threads), and ImagePreparation::new, right before worker.run(&mut executor).
    • helios/src/execution/worker.rs (flare-execution): called after RankExecutor::new.
    • helios/src/execution/threaded.rs (flare-rank-*): called after GraphExecutor::new_unstarted.
    • helios/src/execution/parallel.rs (serve_rank): called after GraphExecutor::new_unstarted (no non-critical helper threads are spawned in serve_rank).
    • helios/src/replay.rs (flare-cuda): called on worker entry before the replay loop.
  • helios/native/roce_proxy.c: vendor the exact pin_high_capacity_cpus() and "flare-roce" thread-naming hunk merged in feat(b12x/comm/roce): pin RoCE proxy thread to high-capacity CPUs on asymmetric Linux topologies local-inference-lab/flashinfer#156 (335459b2). Existing core ABIs and operator cpusets remain unchanged.

Claimed Benefit & Supporting Evidence (4× DGX Spark GB10 TP4, --roce-ring, Inkling 2 Small NVFP4 core gb10-tp4-202611271425)

  • Thread placement & non-inheritance: Across 6 consecutive launches, 48/48 critical threads stayed on Cortex-X925 (vs 4/4 unpinned launches landing on A725). On the updated binary (4c82ab5b), inspecting /proc/<pid>/task/*/status across all four ranks during live serving confirmed flare-model, flare-roce, and peer serve_rank threads had Cpus_allowed_list=5-9,15-19 while the ImagePreparation child thread spawned by flare-model, flare-http, tokio-rt-worker, and CUDA driver helper threads retained 0-19.
  • Variance & throughput: batch=1, width=8 graph-time CV dropped 6.7× (4.82% -> 0.72%); controlled A/B C8 64k decode rose +17.2% (123.66 -> 144.88 tok/s); 8k–128k cold prefill rose +2.6% to +17.3%.
  • Node-level nsys: C1 width-1 RoceOneshotLaunch dropped -31.0% (2.77 -> 1.91 ms); p90 inter-graph host wake gap dropped 61× (1,880 -> 30.9 us).
  • ARM64 test suites & live serving (4c82ab5b):
    • cargo test --locked --release --manifest-path eos/Cargo.toml: 5/5 passed on ARM64 Linux (dgx2).
    • cargo test --locked --release --manifest-path helios/Cargo.toml --features roce,runtime-core,server: 1,728/1,728 passed (44 GPU-only ignored), including all 6 execution::roce::tests.
    • Live four-Spark serving via flare run on existing ABI-14 core gb10-tp4-202611271425: 60.0 tok/s short, 79.4 tok/s 256-token coding, 0/16 ConnectX-7 RDMA port errors, clean Orbit drain.

Limitations: Tested on ARM64 Linux (NVIDIA GB10, schedutil). On x86_64 Linux, /sys/devices/system/cpu/cpu<N>/cpu_capacity is absent so the helper is a no-op. eos/src/windows.rs was not compiled on Windows. Host prefix offload (--prefix-cache-memory) was not exercised on multi-host TP4 and is protected by deferring prefer_high_capacity_cpus() past crate::offload::open.

Discord: woooflet

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 576.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The DGX Spark placement work is well-targeted and preserves operator cpusets, but two concrete defects block merge: a vendored roce_proxy.c that diverges from its pinned FlashInfer source (falsifying NOTICE and duplicating 66 untested C lines), and an affinity mask inherited from flare-model onto offload, disk, and image-preparation threads.

  • Blockers: 2
  • Should fix: 1
  • Subtractive suggestions: 1
  • Nits: 2

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@lukealonso lukealonso added the area:orbit Orbit host agents, orchestration, and package-cache management. label Nov 28, 2026
@original-el8
original-el8 self-requested a review November 28, 2026 21:28

@original-el8 original-el8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinning critical execution threads to high-capacity CPUs on asymmetric ARM64 hosts addresses a real throughput and jitter problem on GB10, and the eos/src/unix.rs tier-selection logic cleanly respects operator cpusets and no-ops on homogeneous or x86_64 systems. Two blockers need resolution before merge:

  1. Child-thread affinity inheritance in helios/src/server/runtime.rs:565: Calling flare_eos::prefer_high_capacity_cpus() at entry to the flare-model thread runs before RankExecutor::new, crate::offload::open (host prefix offload, codec, and disk threads), and ImagePreparation::new (helios/src/server/runtime.rs:682-725). On Linux, spawned child threads inherit their parent's affinity mask, so background offload, disk, and image-preparation threads inherit the Cortex-X925-only mask instead of remaining free to run on efficiency cores. Move the prefer_high_capacity_cpus() call in flare-model to right before worker.run(&mut executor) (and verify helios/src/execution/parallel.rs:536 does not narrow affinity before spawning non-critical helper threads).
  2. Vendored helios/native/roce_proxy.c fork and duplicate C logic (helios/native/roce_proxy.c:186-258): helios/native/roce_proxy.c must remain identical to FlashInfer's pinned flashinfer/experimental/b12x/comm/roce/_roce_proxy.c (lines 6-8), and this duplicates 66 lines of untested C capacity-selection logic alongside eos/src/unix.rs. Either sync the change through FlashInfer PR #156 first, or apply flare_eos::prefer_high_capacity_cpus() from Rust around proxy thread creation without modifying the vendored C file.
  3. Commit message and sign-off hygiene: Update the commit message so it matches the PR description (the commit message still states 6-launch and serving runs "follow immediately"), include the reviewing model identity in Design-Signed-Off-By (Antigravity omits the model), and refresh the docs/design-review.md digest (eb2f is stale on main).

@flare-autobot flare-autobot added performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 29, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The core tier-selection helper is sound, but editing vendored roce_proxy.c breaks its byte-identity contract and the flare-model entry pin leaks onto background threads and halves the KV-codec pool.

  • Blockers: 2 · Should fix: 2 · Subtract/Simplify: 3 · Nits: 0
Walkthrough
  • eos/src/unix.rs:172-248 & eos/src/windows.rs:219-220: adds select_high_capacity_cpus (≥ 90% capacity filter, midpoint fallback, ≥ 2-CPU guard), Linux prefer_high_capacity_cpus, non-Linux/Windows no-op stubs, and 3 unit tests (:254-314).
  • helios/src/server/runtime.rs:568: calls flare_eos::prefer_high_capacity_cpus() as the first statement of the flare-model thread, before RankExecutor::new, crate::offload::open, and ImagePreparation::new.
  • helios/src/execution/parallel.rs:539: calls prefer_high_capacity_cpus() at entry to serve_rank, before manifest validation.
  • helios/src/execution/worker.rs:71 & helios/src/replay.rs:174: call prefer_high_capacity_cpus() at entry to the flare-execution and flare-cuda worker threads.
  • helios/native/roce_proxy.c:1505-1577: duplicates the Linux cpu_capacity affinity logic in C and calls pthread_setname_np(..., "flare-roce") plus pin_high_capacity_cpus() at the top of proxy_main.
Merge Risk: High · up to 4b41ddc
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@fordbmorris
fordbmorris force-pushed the pr/cpu-capacity-pinning branch from 4b41ddc to 4c82ab5 Compare November 30, 2026 00:38
@fordbmorris

fordbmorris commented Nov 30, 2026 •

Copy link
Copy Markdown
Author

Thanks @original-el8 for the thorough review. Rebased onto current main (3801ff1d, commit ba2796c0) and addressed all three blockers:

  1. Child-thread affinity inheritance:
    • Moved flare_eos::prefer_high_capacity_cpus() in helios/src/server/runtime.rs (flare-model) to after RankExecutor::new, crate::offload::open, and ImagePreparation::new, right before worker.run(&mut executor).
    • Moved the call in helios/src/execution/worker.rs (flare-execution) to after RankExecutor::new, added an explicit post-init call for flare-rank-* peer threads in helios/src/execution/threaded.rs, and moved helios/src/execution/parallel.rs (serve_rank) to after GraphExecutor::new_unstarted (verified serve_rank spawns no non-critical helper threads).
    • Verified on live 4-Spark GB10 serving (gb10-tp4-202611271425) via /proc/<pid>/task/*/status: flare-model, flare-roce, and all three peer serve_rank threads have Cpus_allowed_list=5-9,15-19, while the ImagePreparation child thread spawned by flare-model, flare-http, tokio-rt-worker, and CUDA driver threads retain 0-19.
  2. Vendored helios/native/roce_proxy.c sync:
    • local-inference-lab/flashinfer#156 has now merged into FlashInfer main (335459b2), and the roce_proxy.c hunk here is byte-for-byte identical to 335459b2 (cleanly layered on main's roce_proxy_dlopen.c build).
  3. Commit message, validation, and sign-off:
    • Rewrote the commit message and PR description to match the completed ARM64 unit tests (eos 5/5, helios --features roce,runtime-core,server 1,728/1,728) and live 4-Spark serving validation (60.0 tok/s short, 79.4 tok/s coding, 0/16 ConnectX-7 RDMA port errors, clean Orbit drain).
    • Updated trailers to Design-Signed-Off-By: Antigravity (Gemini-4-Neon); design-review=2e5b (verified against main's docs/design-review.md via .githooks/commit-msg) and Signed-off-by: woooflet <ford@fordmorris.com>.

Ready for re-review!

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The rework clears two of the three prior blockers — helios/native/roce_proxy.c now syncs the exact hunk merged upstream in local-inference-lab/flashinfer#156 (335459b2), and eagerly spawned background threads now stay on the full process cpuset. One Round 2 regression remains: selene::shared::codec::cpu_pool() is a lazy OnceLock first touched inside worker.run, halving and P-core-pinning flare-kv-codec-* on --prefix-cache-memory.

  • Blockers: 1 · Should fix: 0 · Subtract/Simplify: 2 · Nits: 1
Walkthrough
  • eos/src/unix.rs:188-330 & eos/src/windows.rs:219-220: adds select_high_capacity_cpus (≥ 90% of max allowed capacity, midpoint fallback, ≥ 2-CPU floor), Linux prefer_high_capacity_cpus (strict intersection with current sched_getaffinity via /sys/devices/system/cpu/cpu<N>/cpu_capacity), non-Linux/Windows no-op stubs, and three isolated pure-function unit tests.
  • helios/src/server/runtime.rs:721-724: calls flare_eos::prefer_high_capacity_cpus() on flare-model after RankExecutor::new (:585), crate::offload::open (:696), and ImagePreparation::new (:719), immediately before worker.run(&mut executor) (:729).
  • helios/src/execution/worker.rs:86, helios/src/execution/threaded.rs:683, helios/src/execution/parallel.rs:573, & helios/src/replay.rs:174: narrows flare-execution (after RankExecutor::new), each flare-rank-* peer thread (after GraphExecutor::new_unstarted), serve_rank, and flare-cuda (worker entry).
  • helios/native/roce_proxy.c:1505-1577: vendors pin_high_capacity_cpus() and pthread_setname_np(pthread_self(), "flare-roce") at proxy_main entry verbatim from merged local-inference-lab/flashinfer#156 (335459b2), compiled through helios/native/roce_proxy_dlopen.c:236.
Merge Risk: Medium · up to ba2796c
  • Host prefix-cache KV-codec regression (--prefix-cache-memory): Deferring prefer_high_capacity_cpus() past crate::offload::open (helios/src/server/runtime.rs:696,724) protects eager offload/disk/image threads but misses the lazy flare-kv-codec-* rayon pool (selene/src/shared/codec.rs:37-60), built on cold-start async host compression from the narrowed flare-model thread — half the threads, P-core-only affinity.
  • No x86_64/Windows runtime regression, but zero aarch64 CI execution: On homogeneous or non-cpu_capacity Linux hosts and Windows (eos/src/windows.rs:220) the helper is a clean no-op with zero hot-path overhead; however .github/workflows/native-serving.yml:16-22 (not opened) runs only x86_64 Linux and Windows, so neither the Linux sysfs narrowing path nor the C proxy helper runs in CI.
  • Cross-PR rebase overlap: Open PR Avoid THP compaction stalls in eos::map_host and report offload startup timings #625 modifies eos/src/unix.rs (including mod tests) and sibling PR roce_proxy: raise ring mailbox window to 16 and drain relays eagerly in pipelined ops #577 modifies helios/native/roce_proxy.c; coordinate merge/rebase order.
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings
  • ✅ Security / malicious screen: Read-only /sys/devices/system/cpu/cpu<N>/cpu_capacity integer parsing plus standard sched_getaffinity/sched_setaffinity/pthread_setname_np; no new env vars, network I/O, or untrusted input handling.
  • ✅ Charter & value fit: Targets DGX Spark (GB10), a named charter platform, via a single model-agnostic runtime OS primitive; upstream RoCE proxy sync follows @original-el8's Round 1 direction once Blocker 1 stops pinning offload codec workers.
  • ⚠️ Related / duplicate / conflict check: No competing affinity change on main; open PR Avoid THP compaction stalls in eos::map_host and report offload startup timings #625 edits eos/src/unix.rs and sibling PR roce_proxy: raise ring mailbox window to 16 and drain relays eagerly in pipelined ops #577 edits helios/native/roce_proxy.c, so merge order will require a minor rebase.
  • ⚠️ Tests & verification evidence: Unit tests (eos/src/unix.rs:270-330) are isolated and pass on ARM64 per author report (5/5 eos, 1,728/1,728 helios --features roce,runtime-core,server), but CI (.github/workflows/native-serving.yml:16-22 (not opened)) runs x86_64 Linux/Windows only — never executing the cpu_capacity or C proxy paths — and the author's GB10 /proc and throughput evidence omits --prefix-cache-memory, where Blocker 1 triggers.
Blockers (1)

1. Lazy flare-kv-codec-* rayon pool is still sized and pinned on the narrowed flare-model thread (helios/src/server/runtime.rs:721-729, selene/src/shared/codec.rs:37-60, selene/src/memory.rs:1898-1901,2005-2013,2341-2370,3064-3075)

  • The comment at helios/src/server/runtime.rs:721-723 claims narrowing after crate::offload::open (:696) leaves host offload/codec/disk threads on the full process cpuset. flare-offload-* (helios/src/offload/transfer.rs:509-536) and flare-offload-disk (selene/src/disk.rs:372,732) are spawned eagerly there, but codec::cpu_pool() is a lazy OnceLock not touched during offload::open (AsyncCompressor::new at selene/src/memory.rs:1986-1998,2313 creates only channels and an empty queue).
  • With async CPU KV compression (helios/src/offload/transfer.rs:466-482, selene/src/memory.rs:2286-2314), the first outbound checkpoint store drives Worker::run → service_store (helios/src/server/runtime.rs:2380-2388) → MemoryStore::poll (selene/src/memory.rs:3064-3075) → drain_compressed (:2368-2370) → AsyncCompressor::pump_spawns (:2005-2013) → host_compress_pool() (:1898-1901) → cpu_pool() on the already-narrowed flare-model thread.
  • Inside cpu_pool(), std::thread::available_parallelism() (selene/src/shared/codec.rs:41-43) reads the caller's affinity mask and rayon::ThreadPoolBuilder::build() spawns all workers from that thread. On GB10 (0-19 narrowed to 5-9,15-19) this halves the pool (5 instead of 10 workers), pins codec workers to P-cores where they contend with flare-model/flare-roce instead of using efficiency cores (violating docs/prefix-cache-offload.md:919-928 and contradicting runtime.rs:721-723), and adds pool creation latency inside store.poll(). It also races with helios/src/offload/transfer/codec.rs:353,514,751 — whichever of flare-model or flare-offload-0 calls cpu_pool() first fixes pool size and affinity for the process.
  • Fix: Eagerly warm crate::shared::codec::cpu_pool() during MemoryStore::open when codec_enabled / async_encoder.is_some() (e.g., inside AsyncCompressor::new or before returning at selene/src/memory.rs:2307-2315, or in crate::offload::open when CPU KV compression is active) so it runs on the unnarrowed flare-model thread before helios/src/server/runtime.rs:724, and avoids spawning codec threads when offload compression is disabled.
Should Fix (0)

None.

Subtract / Simplify (2)
  1. Remove dead min_cap == max_cap check (eos/src/unix.rs:201-203): With positive capacities, every CPU satisfies cap * 10 >= max_cap * 9, so selected.len() == allowed_with_capacity.len() and the guard at :221 already returns None. Deleting :201-203 preserves exact parity with roce_proxy.c:1510-1569.
  2. Tighten visibility and collapse the Unix cfg stub (eos/src/unix.rs:188,231-264): Since eos/src/lib.rs:12 re-exports pub use unix::*;, marking select_high_capacity_cpus as fn keeps an internal helper off flare_eos's public API. Likewise, prefer_high_capacity_cpus (:231-264) can use one signature with #[cfg(target_os = "linux")] inside the body instead of repeating the pub fn declaration.
Nits (1)
  • NOTICE:16-19: The f5f5341d FlashInfer commit link was already stale across prior roce_proxy.c syncs (#251, #279, #325); updating NOTICE:17 to 335459b2 (matching the synced local-inference-lab/flashinfer#156 hunk) keeps attribution accurate for the file this PR modifies.
Dropped on verification
  • Correctness flare run fails at "Prepare execution": cuGraphAddKernelNode_v2 CUDA_ERROR_INVALID_VALUE (qwen3.8-flash TP2, RTX PRO 5000 Blackwell 48 GB) #2 / Discovery A3 (byte-identity contract broken across 4 witnesses): Dropped as Major/Blocker. @original-el8's Round 1 review explicitly authorized syncing through local-inference-lab/flashinfer#156 first, now merged (335459b2), satisfying roce_proxy.c:8, roce_proxy_dlopen.c:7-9, and docs/roce-ring.md:361-364. docs/TODO.txt:80-86 (ABI 10/11) and NOTICE:17 were already stale from earlier syncs; reduced NOTICE:17 to a 1-line Nit.
  • Correctness Message prefix checkpoint skipped at a conditioned window boundary #3 (90% filter lacks relative-spread guard): Dropped as factually and mathematically false. With capacities spanning 1–2% (1023..1024, or GB10's 997..1024 tested at eos/src/unix.rs:303-308), 100% of CPUs pass and :221 returns None; a >10% spread is required to drop any CPU. Linux x86_64 does not expose arch_topology sysfs cpu_capacity (x86 hybrid uses ITMT/sched_asym_packing).
  • Correctness Vision cost estimate drops a following window's first patch #4 (≥ 2-CPU floor crams hot threads onto 2 CPUs): Dropped. On 1-prime + 3-efficiency ([1024, 500, 500, 500]), both the 90% pass and midpoint fallback select 1 CPU and return None. Multi-GPU asymmetric big.LITTLE is not in the supported hardware matrix, and @original-el8 already approved the selector in Round 1.
  • Correctness Window cancel e2e test false-fails when generation wins the race #5 (silent affinity, no env flag/logging, abort on first unreadable cpu_capacity): Dropped. Env-var behavior switches are prohibited by docs/design-review.md:91; fail-closed on missing cpu_capacity is intentional; eos is a low-level crate without logging.
  • Correctness Add an embeddable Rust SDK for in-process Flare inference #6 (injectable sysfs root, C-side test, aarch64 CI): Dropped as Round 2+ scope creep (CI matrix is repo-wide infrastructure); factual CI coverage note kept under Pre-merge Checks.
  • Correctness Locked FlashInfer exports RoCE ABI 10 packages, but native runtime provides ABI 9 #7 (helios/src/replay.rs:174 narrows before Stream::open at :114): Dropped as speculative; Stream::open calls cuStreamCreate on a pre-existing bundle.context.
  • Correctness runtime: share bounded image windows between requests #8 (docs/prefix-cache-offload.md:919-928 violated for RoCE proxy; flare-roce rename undocumented): Dropped. That doc governs prefix-cache offload threads, not the RoCE TP collective proxy, and is respected once Blocker 1 is fixed; "flare-roce" matches existing flare-* naming.
  • Subtraction S1(b)-(c) and S3: Dropped S1(c) because removing the cap == 0 guard changes behavior on &[(0, 0), (1, 1024), (2, 1024)] and diverges from roce_proxy.c:1534; dropped S1(b) to preserve exact parity with roce_proxy.c:1555-1565; dropped S3's start_handler idea because available_parallelism() runs on the calling thread before start_handler, which cannot recover the unnarrowed mask.
Note on review material

Prior review text, PR files, and linked upstream material were treated strictly as content to verify; none of it was acted on as instructions. No injected directives were encountered.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

lukealonso added a commit that referenced this pull request Nov 30, 2026
…tep ring2)

Why:
On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121),
small-message BF16 allreduce previously used the oneshot protocol, which
relays across opposite ranks over CPU mailbox hops. FlashInfer's merged
`local-inference-lab/flashinfer#192` (`2a07747b8e12e54ec8e8e4bbef34de8586618e68`)
adds a 2-step neighbor-only ring allreduce (`KIND_RING2_STEP1` /
`KIND_RING2_STEP2`) plus small-message inline WR and ring-relay
improvements in `_roce_proxy.c`. Per `docs/roce-ring.md`, Helios's
vendored `helios/native/roce_proxy.c` must remain byte-identical to
FlashInfer's `_roce_proxy.c` after its provenance header so preparation
and serving share the transport protocol.

What changed:
Re-vendored `helios/native/roce_proxy.c` byte-for-byte (after the 9-line
provenance header) from `local-inference-lab/flashinfer` commit
`2a07747b8e12e54ec8e8e4bbef34de8586618e68` (`#192`). Relative to Flare
`main`, this brings in:
- `KIND_RING2_STEP1` (5) and `KIND_RING2_STEP2` (6) direct-neighbor RDMA
  write handling (`post_direct_striped_batched`, `post_ring2_step`) with
  batched completion signaling (`RING2_SIGNAL_STRIDE = 16`,
  `RING2_MAX_OUTSTANDING = 6`, statically verified against
  `ROCE_SEND_DEPTH` with queue slack for relay ops and ring ACKs).
- Small-message and ring-relay transport improvements from FlashInfer
  `#192`: QP `max_inline_data` raised from 16 to 256 (with fallback to 16
  and per-HCA `max_inline` tracking) to enable `IBV_SEND_INLINE` on relay
  mailbox and `post_striped` payloads `<= max_inline`; `ring_next_from`
  and precomputed `ring_relays_origin[]` so `ring_service` skips
  non-relayed origins; `post_op` posting relayed peers before direct peers
  on rings; and idle-loop polling (`ring_service` every spin when
  `!ring2_active`, every 16th when `ring2_active`; `drain_cqs` every 16th).
- High-capacity CPU pinning (`pin_high_capacity_cpus`, `"flare-roce"`
  thread name) already merged upstream in `flashinfer#156` (overlaps open
  `#576`).
- Existing control opcodes (0..4) and `ROCE_ABI_VERSION = 14` remain
  unchanged, preserving full compatibility with existing ABI-14 cores.

Claimed benefit and result:
Enables native Rust serving (`flare run`) to drive b12x's 2-step RoCE ring
allreduce on 4-rank switchless rings without opposite-rank CPU relay hops.
Note that an isolated `#643`-only run on a `main`-exported core does not
emit kinds 5/6; paired with `local-inference-lab/flashinfer#192`
(`2a07747b8`), `local-inference-lab/flashinfer#193`,
`local-inference-lab/hyperflare-recipes#112`, and
`#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash
serving (`max_tokens = 256`, 5-prompt suite):
- In node-level nsys P=4 traces, `RoceRing2AllReduceLaunch` averages
  31.8-33.0 us/call across 88 calls/round (eliminating opposite-rank CPU
  relay hops on small BF16 allreduces).
- Combined-stack matched-depth GPU round times dropped 1.5-2.2 ms across
  P=1..6 versus pre-existing non-ring2 baseline core
  `gb10-tp4-202611291503` (P=1: 22.3 -> 20.8 ms, P~4: 34.59 -> 32.36 ms,
  P~5: 35.92 -> 34.16 ms; 5-prompt mean 74.02 -> 76.11 tok/s under
  `balanced`, `greedy_code` 74.39 -> 80.89 tok/s).

Supporting evidence and limitations:
- Byte-parity check: `diff` between `tail -n +10 helios/native/roce_proxy.c`
  and `flashinfer@2a07747b8:flashinfer/experimental/b12x/comm/roce/_roce_proxy.c`
  returned 0 bytes diff.
- Native RoCE proxy unit tests (`cargo test --locked --release
  --manifest-path helios/Cargo.toml --features roce --lib --target-dir
  flare-cli/target execution::roce`): **30 passed, 0 failed** (6
  `execution::roce::tests` + 24 `execution::roce_fabric::tests`).
- Full crate tests (`cargo test --locked --release` on `helios` with
  `--features runtime-core,server`, `flare`, `flare-cli`): all passed.
- Live 4-rank multi-GPU collective execution verified on 4x DGX Spark
  dual-port switchless RoCE rings serving both ring2-enabled cores
  (`gb10-tp4-202611301141`, `gb10-tp4-202611301553`, 57 graphs each) and
  legacy non-ring2 ABI-14 core (`gb10-tp4-202611291503`).
- Limitations / unrun checks:
  - Keeping `ROCE_ABI_VERSION = 14` preserves compatibility with existing
    ABI-14 cores, but an older Flare binary without `#643` loading a newer
    ring2-exported core will connect and fail on replay op 1 with
    `unknown op kind 5` rather than rejecting at startup.
  - Collides on `roce_proxy.c` with open `#576` (`pin_high_capacity_cpus`
    from merged `flashinfer#156`) and `#577` (`RING_WINDOW` / `reserve`);
    whichever lands second will rebase cleanly against the vendored file.
  - Non-4-rank ring topologies and non-SM121 RoCE NICs were not benchmarked.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
lukealonso added a commit that referenced this pull request Nov 30, 2026
…tep ring2) (#643)

Why:
On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121),
small-message BF16 allreduce previously used the oneshot protocol, which
relays across opposite ranks over CPU mailbox hops. FlashInfer's merged
`local-inference-lab/flashinfer#192` (`2a07747b8e12e54ec8e8e4bbef34de8586618e68`)
adds a 2-step neighbor-only ring allreduce (`KIND_RING2_STEP1` /
`KIND_RING2_STEP2`) plus small-message inline WR and ring-relay
improvements in `_roce_proxy.c`. Per `docs/roce-ring.md`, Helios's
vendored `helios/native/roce_proxy.c` must remain byte-identical to
FlashInfer's `_roce_proxy.c` after its provenance header so preparation
and serving share the transport protocol.

What changed:
Re-vendored `helios/native/roce_proxy.c` byte-for-byte (after the 9-line
provenance header) from `local-inference-lab/flashinfer` commit
`2a07747b8e12e54ec8e8e4bbef34de8586618e68` (`#192`). Relative to Flare
`main`, this brings in:
- `KIND_RING2_STEP1` (5) and `KIND_RING2_STEP2` (6) direct-neighbor RDMA
  write handling (`post_direct_striped_batched`, `post_ring2_step`) with
  batched completion signaling (`RING2_SIGNAL_STRIDE = 16`,
  `RING2_MAX_OUTSTANDING = 6`, statically verified against
  `ROCE_SEND_DEPTH` with queue slack for relay ops and ring ACKs).
- Small-message and ring-relay transport improvements from FlashInfer
  `#192`: QP `max_inline_data` raised from 16 to 256 (with fallback to 16
  and per-HCA `max_inline` tracking) to enable `IBV_SEND_INLINE` on relay
  mailbox and `post_striped` payloads `<= max_inline`; `ring_next_from`
  and precomputed `ring_relays_origin[]` so `ring_service` skips
  non-relayed origins; `post_op` posting relayed peers before direct peers
  on rings; and idle-loop polling (`ring_service` every spin when
  `!ring2_active`, every 16th when `ring2_active`; `drain_cqs` every 16th).
- High-capacity CPU pinning (`pin_high_capacity_cpus`, `"flare-roce"`
  thread name) already merged upstream in `flashinfer#156` (overlaps open
  `#576`).
- Existing control opcodes (0..4) and `ROCE_ABI_VERSION = 14` remain
  unchanged, preserving full compatibility with existing ABI-14 cores.

Claimed benefit and result:
Enables native Rust serving (`flare run`) to drive b12x's 2-step RoCE ring
allreduce on 4-rank switchless rings without opposite-rank CPU relay hops.
Note that an isolated `#643`-only run on a `main`-exported core does not
emit kinds 5/6; paired with `local-inference-lab/flashinfer#192`
(`2a07747b8`), `local-inference-lab/flashinfer#193`,
`local-inference-lab/hyperflare-recipes#112`, and
`#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash
serving (`max_tokens = 256`, 5-prompt suite):
- In node-level nsys P=4 traces, `RoceRing2AllReduceLaunch` averages
  31.8-33.0 us/call across 88 calls/round (eliminating opposite-rank CPU
  relay hops on small BF16 allreduces).
- Combined-stack matched-depth GPU round times dropped 1.5-2.2 ms across
  P=1..6 versus pre-existing non-ring2 baseline core
  `gb10-tp4-202611291503` (P=1: 22.3 -> 20.8 ms, P~4: 34.59 -> 32.36 ms,
  P~5: 35.92 -> 34.16 ms; 5-prompt mean 74.02 -> 76.11 tok/s under
  `balanced`, `greedy_code` 74.39 -> 80.89 tok/s).

Supporting evidence and limitations:
- Byte-parity check: `diff` between `tail -n +10 helios/native/roce_proxy.c`
  and `flashinfer@2a07747b8:flashinfer/experimental/b12x/comm/roce/_roce_proxy.c`
  returned 0 bytes diff.
- Native RoCE proxy unit tests (`cargo test --locked --release
  --manifest-path helios/Cargo.toml --features roce --lib --target-dir
  flare-cli/target execution::roce`): **30 passed, 0 failed** (6
  `execution::roce::tests` + 24 `execution::roce_fabric::tests`).
- Full crate tests (`cargo test --locked --release` on `helios` with
  `--features runtime-core,server`, `flare`, `flare-cli`): all passed.
- Live 4-rank multi-GPU collective execution verified on 4x DGX Spark
  dual-port switchless RoCE rings serving both ring2-enabled cores
  (`gb10-tp4-202611301141`, `gb10-tp4-202611301553`, 57 graphs each) and
  legacy non-ring2 ABI-14 core (`gb10-tp4-202611291503`).
- Limitations / unrun checks:
  - Keeping `ROCE_ABI_VERSION = 14` preserves compatibility with existing
    ABI-14 cores, but an older Flare binary without `#643` loading a newer
    ring2-exported core will connect and fail on replay op 1 with
    `unknown op kind 5` rather than rejecting at startup.
  - Collides on `roce_proxy.c` with open `#576` (`pin_high_capacity_cpus`
    from merged `flashinfer#156`) and `#577` (`RING_WINDOW` / `reserve`);
    whichever lands second will rebase cleanly against the vendored file.
  - Non-4-rank ring topologies and non-SM121 RoCE NICs were not benchmarked.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
…x topologies

On asymmetric ARM64 Linux SoCs such as NVIDIA GB10 (10 Cortex-A725
efficiency cores with sysfs cpu_capacity 718..731 alongside 10
Cortex-X925 performance cores with cpu_capacity 997..1024), the Linux
scheduler places Helios's execution threads onto efficiency cores on some
launches and performance cores on others. Efficiency-core placement slows
one-shot RoCE collectives, inflates inter-graph host wake gaps, and
creates launch-to-launch throughput jitter that distorts speculative
drafting choices.

Changes (rebased onto main after NVIDIA#643 already vendored pin_high_capacity_cpus
in helios/native/roce_proxy.c from merged local-inference-lab/flashinfer#156):
- Add flare_eos::select_high_capacity_cpus and prefer_high_capacity_cpus
  in eos/src/unix.rs (with a no-op stub in eos/src/windows.rs and unit
  tests in eos/src/unix.rs). On Linux, prefer_high_capacity_cpus reads
  /sys/devices/system/cpu/cpu<N>/cpu_capacity across the thread's current
  sched_getaffinity mask, selects CPUs at or above 90% of the maximum
  allowed capacity (falling back above midpoint so busy threads never
  collapse onto fewer than two cores), and no-ops when cpu_capacity is
  absent, homogeneous, or already single-tier.
- Call flare_eos::prefer_high_capacity_cpus() in Helios critical worker
  threads after child-thread spawning so background threads keep the full
  process affinity mask:
  - helios/src/server/runtime.rs (flare-model): called after
    RankExecutor::new, crate::offload::open (host prefix offload, KV
    codec pool, and disk threads), and ImagePreparation::new, immediately
    before worker.run(&mut executor).
  - helios/src/execution/worker.rs (flare-execution): called after
    RankExecutor::new.
  - helios/src/execution/threaded.rs (flare-rank-*): called after
    GraphExecutor::new_unstarted.
  - helios/src/execution/parallel.rs (serve_rank): called after
    GraphExecutor::new_unstarted.
  - helios/src/replay.rs (flare-cuda): called on worker entry before the
    replay loop.
- Existing core ABIs and operator cpusets remain unchanged.

Measured benefit on four DGX Spark GB10 nodes (--roce-ring, Inkling 2
Small NVFP4 TP4 core gb10-tp4-202611271425):
- Across 6 consecutive launches, 48/48 critical threads stayed on
  Cortex-X925 (vs 4/4 unpinned launches landing on Cortex-A725).
- Batch=1 width=8 graph-time CV dropped 6.7x (4.82% to 0.72%); controlled
  A/B C8 64k decode rose 17.2% (123.66 to 144.88 tok/s); 8k-128k cold
  prefill rose 2.6%-17.3%.
- Node-level nsys showed C1 width-1 RoceOneshotLaunch dropped 31.0%
  (2.77 to 1.91 ms) and p90 inter-graph host wake gap dropped 61x
  (1,880 to 30.9 us).

Validation and limitations:
- ARM64 Linux (dgx2): cargo test --locked --release --manifest-path
  eos/Cargo.toml passed 5/5 (asymmetric, homogeneous, single-tier,
  zero-capacity, and three-tier unit tests); cargo test --locked
  --release --manifest-path helios/Cargo.toml --features
  roce,runtime-core,server passed 1,728/1,728 (44 GPU-only ignored).
- Live four-Spark serving via flare run confirmed flare-model,
  flare-roce, and peer serve_rank threads pinned to Cpus_allowed_list
  5-9,15-19 across all 13 checkpoints of a 2-hour production soak while
  the ImagePreparation child thread, flare-http, tokio-rt-worker, and
  CUDA helper threads remained unconstrained on 0-19.
- Limitations: tested on ARM64 Linux (NVIDIA GB10, schedutil); on x86_64
  Linux sysfs cpu_capacity is absent so the helper is a no-op; the
  eos/src/windows.rs stub was not compiled on Windows; host prefix
  offload with --prefix-cache-memory was not exercised on multi-host TP4
  (verified by placement order after crate::offload::open).

Design-Signed-Off-By: Antigravity (Gemini-4-Neon); design-review=2e5b
Signed-off-by: woooflet <ford@fordmorris.com>
@fordbmorris

Copy link
Copy Markdown
Author

Rebased onto latest main (571a4471) after merged #643 already vendored pin_high_capacity_cpus() in helios/native/roce_proxy.c (from merged local-inference-lab/flashinfer#156):

  • Dropped the now-redundant helios/native/roce_proxy.c hunk so this PR is pure Rust (eos/src/{unix,windows}.rs + helios/src/{execution,replay,server}).
  • Preserved deferred placement of flare_eos::prefer_high_capacity_cpus() in helios/src/server/runtime.rs after RankExecutor::new, crate::offload::open, and ImagePreparation::new, so child threads keep the full process affinity mask (0-19 verified across all 13 checkpoints of a 2-hour 4-Spark GB10 production soak while flare-model, flare-roce, and peer serve_rank stayed on Cortex-X925 5-9,15-19).
  • Re-verified on rebased main: cargo test --locked --manifest-path eos/Cargo.toml (5/5 passed) and cargo test --locked --manifest-path helios/Cargo.toml --features roce,runtime-core,server --lib execution::roce:: (6/6 passed).

Discord: woooflet

@fordbmorris
fordbmorris force-pushed the pr/cpu-capacity-pinning branch from ba2796c to ca0c982 Compare December 2, 2026 04:47
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Dropping the redundant helios/native/roce_proxy.c hunk (landed on main via #643) leaves a clean, minimal pure-Rust change, and the tier-selection helper plus eagerly-spawned thread placement are sound. One Round 2 blocker remains at ca0c982: selene::shared::codec::cpu_pool() is still initialized lazily on the narrowed flare-model thread under --prefix-cache-memory with CPU KV compression.

  • Blockers: 1 · Should fix: 1 · Subtract/Simplify: 2 · Nits: 2
Walkthrough
  • eos/src/unix.rs:183-264 & eos/src/windows.rs:219-220: adds select_high_capacity_cpus (≥ 90% of max allowed capacity, midpoint fallback, ≥ 2-CPU floor), Linux prefer_high_capacity_cpus (strict intersection with the calling thread's sched_getaffinity mask via /sys/devices/system/cpu/cpu<N>/cpu_capacity), non-Linux/Windows no-op stubs, and three isolated unit tests (eos/src/unix.rs:270-330).
  • helios/src/server/runtime.rs:781-784: calls flare_eos::prefer_high_capacity_cpus() on flare-model after RankExecutor::new (:657), crate::offload::open (:756), and ImagePreparation::new (:779), immediately before worker.run(&mut executor) (:789).
  • helios/src/execution/worker.rs:86: narrows flare-execution after RankExecutor::new (:75).
  • helios/src/execution/threaded.rs:683 & helios/src/execution/parallel.rs:578: narrow each flare-rank-* peer thread and serve_rank after GraphExecutor::new_unstarted.
  • helios/src/replay.rs:173-176: narrows flare-cuda at worker entry before run(...).
Merge Risk: Medium · up to ca0c982
  • Unresolved --prefix-cache-memory CPU KV-codec regression: Deferring prefer_high_capacity_cpus() past crate::offload::open (helios/src/server/runtime.rs:756,784) protects eagerly spawned offload, disk, and image-preparation threads, but misses the lazy flare-kv-codec-* rayon pool (selene/src/shared/codec.rs:37-60), creating a per-launch race that halves codec workers (5 vs 10 on GB10) and pins them onto P-cores alongside flare-model/flare-roce.
  • Rebase drift against current main: main has moved past this branch's base (571a4471), notably rewriting eos/src/unix.rs (#625, #667, now 1,367 lines) and updating the crate::offload::open call site right above helios/src/server/runtime.rs:784 (#628).
  • Zero aarch64 CI execution: On homogeneous/x86_64 Linux and Windows the helper is a clean no-op with zero steady-state overhead, so x86_64/Windows regressions are unlikely, but .github/workflows/native-serving.yml:16-22 (not opened) never executes the asymmetric Linux cpu_capacity path.
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings
  • ✅ Security / malicious screen: Read-only /sys/devices/system/cpu/cpu<N>/cpu_capacity integer parsing and standard sched_getaffinity/sched_setaffinity syscalls; no new env vars, network I/O, or untrusted input handling.
  • ✅ Charter & value fit: Targets DGX Spark (GB10), a named charter hardware target, via a single general runtime OS primitive in eos/; removing roce_proxy.c resolves all vendored-file provenance concerns, and fixing Blocker 1 restores full compliance with docs/prefix-cache-offload.md:919-928.
  • ⚠️ Related / duplicate / conflict check: No competing Rust affinity PR exists (#643 already merged the C roce_proxy.c half on main), but main has moved ahead in eos/src/unix.rs (#625, #667) and helios/src/server/runtime.rs (#628), requiring a rebase; open #640 also edits helios/src/execution/threaded.rs.
  • ⚠️ Tests & verification evidence: The three unit tests in eos/src/unix.rs:270-330 are deterministic and isolated (no global state mutation), but .github/workflows/native-serving.yml:16-22 (not opened) runs only x86_64 Linux and Windows (never executing the asymmetric Linux path), --prefix-cache-memory with CPU KV compression was not exercised on GB10, and the latest comment narrows cited testing to eos (5/5) and helios --lib execution::roce:: (6/6) rather than the full helios suite.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:orbit Orbit host agents, orchestration, and package-cache management. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants