Skip to content

helios/roce: pin proxy polling thread to high-capacity CPUs and name thread - #633

Closed
original-el8 wants to merge 1 commit into
NVIDIA:mainfrom
liquidgravityai:perf/roce-proxy-high-capacity-cpus
Closed

original-el8 wants to merge 1 commit into
NVIDIA:mainfrom
liquidgravityai:perf/roce-proxy-high-capacity-cpus

Conversation

@original-el8

Copy link
Copy Markdown
Collaborator

Problem

On asymmetric Linux systems (such as ARM big.LITTLE / NVIDIA Grace CPUs), proxy_main in helios/native/roce_proxy.c starts the RoCE RDMA polling thread without setting a thread name or constraining its CPU affinity within the process's allowed mask. When the OS scheduler places or migrates that polling thread onto lower-capacity CPUs, doorbell polling, completion draining, and ring relay forwarding incur avoidable CPU-side latency and jitter.

Restricting the thread within its existing sched_getaffinity mask using Linux sysfs cpu_capacity keeps it on high-capacity cores when multiple capacity tiers are present, while acting as a no-op on homogeneous systems, non-Linux hosts, or masks without multiple tiers or fewer than two high-capacity CPUs. Naming the thread "flare-roce" makes it directly identifiable in OS tools and profilers.

What changed (before -> after)

  • helios/native/roce_proxy.c:
    • Before: proxy_main ran with the inherited thread name and process CPU affinity mask unmodified.
    • After: Under #ifdef __linux__, proxy_main calls pthread_setname_np(pthread_self(), "flare-roce") and pin_high_capacity_cpus(). pin_high_capacity_cpus() reads /sys/devices/system/cpu/cpu<id>/cpu_capacity for each CPU in the thread's sched_getaffinity mask; if count >= 2 and min_cap != max_cap, it narrows the mask to CPUs with capacity >= 0.9 * max_cap (falling back to capacity > (min_cap + max_cap) / 2 if fewer than 2 qualify) and applies sched_setaffinity only when 2 <= selected < count. If sysfs cpu_capacity is absent, unparseable, homogeneous, or already restricted to one tier, the mask is left unchanged.
    • Preserved ROCE_SEND_DEPTH / 6 in reserve(), its world = 16 ACK safety bound, and ROCE_ABI_VERSION 14 unchanged.
  • Compatibility: No model core format, Protobuf schema, or RoCE wire/shared-memory ABI (ROCE_ABI_VERSION 14) changes.

Claimed benefit and measured results

Prevents the RoCE proxy polling thread from running on lower-capacity cores on asymmetric ARM hosts and labels the thread flare-roce in OS and profiler traces without changing RDMA queue reservation or homogeneous-host scheduling.

  • Combined-stack TP4 serving verification (4x DGX Spark GB10 / SM121, DeepSeek-V4.1-Flash TP4 via flare run):
    • Scope note: This end-to-end TP4 flare run verification integrates the combined SM121/RoCE kernel, recipe, and scheduler optimization set; isolated single-PR TP4 serving A/B was not run separately.
    • Hardware & exported package: 4x NVIDIA DGX Spark (GB10, SM121, 48 SMs, 121 GiB unified LPDDR5x, dual-rail ConnectX-7 200 GbE RoCEv2), deepseek-ai/DeepSeek-V4.1-Flash-1017 TP4 exported package (draft_tokens = 7, speculative_token_capacity = 256, graph_budget = 80, prefill_chunk = 8192, row_shard_prefill = True, row_shard_attention = True, adaptive_verification_alpha = 0.75), served via flare run (27,051,776 logical KV tokens/rank, up from 26,272,640 baseline).
    • Correctness & stability qualification:
      • Greedy math (17 * 23 = 391): pass
      • Concurrent multimodal vision (4/4 distinct images, 4 vision graph launches): 4/4 pass
      • Cold needle-in-a-haystack (8K, 16K, 32K, 64K, 128K, 0 reused tokens): 5/5 pass (128K in 11.71 s)
      • Concurrent 4 x 32K long-context stress: 4/4 pass in 12.19 s, 0 failed requests, 0 preemptions
    • llm-decode-bench v0.8.0 (exact native token counting, 30 s/cell sustained decode, 0 errors, 0 CJK):
      • Integrated scout prefill (prompt_tokens / client TTFT): 8K 8,639 tok/s (0.95 s), 32K 10,994 tok/s (2.98 s, vs 10,810 tok/s baseline), 128K 11,349 tok/s (11.55 s, vs 11,181 tok/s baseline); cold 64K pass-2 prefill reached 11,390.9 tok/s wall (11,462.6 tok/s GPU).
      • Sustained decode (C = 1, 2, 4, 8):
        • 8K: 67.7 / 106.5 / 159.1 / 224.6 tok/s (vs 65.4 / 107.1 / 152.5 / 218.6 tok/s matching draft_tokens = 7, alpha = 0.75 baseline)
        • 32K: 71.2 / 107.6 / 163.1 / 227.6 tok/s (vs 70.2 / 105.0 / 154.9 / 222.4 tok/s baseline)
        • 128K: 69.1 / 99.2 / 154.0 / 219.9 tok/s (12-cell geomean 126.61 tok/s vs 124.96 tok/s baseline; B16xW1 pure 1-token/lane GPU step 75.70 ms -> 70.54 ms, -6.8%)
        • 8K C=16 / C=32 under alpha = 0.75 (272.5 / 411.0 tok/s): at alpha = 0.75 with max_verification_token_budget = 256, unclamped calibration offers ~2.8–2.9 drafts/lane on low-acceptance prose (49.4%–51.8% accept rate vs 59.7%–62.2% baseline), increasing packed verification rows; C=32 fixed-prompt sweep (P=256) reached 419.93 tok/s.
      • Coding Peak (5/5 runs, 0 CJK): 109.0 tok/s median, 110.7 tok/s mean, 118.0 tok/s peak (vs 116.5 tok/s baseline).
    • Sustained long-form generation (46,766 completion tokens: 27,108 reasoning + 19,658 HTML/JS code, temperature = 1.0, adaptive draft_tokens = 7):
      • End-to-end decode: 118.23 tok/s (179.53 tok/s 1s peak, 162.56 tok/s 5s peak; vs 114.68 tok/s fixed-W=8 baseline and 87.74 tok/s flat-ceiling adaptive W=6 baseline)
      • Reasoning segment: 105.49 tok/s (4.19 mean tokens/step, 5.40 offered drafts/round)
      • Code segment (19,655 tokens up to 47K context): 141.85 tok/s (6.11 mean tokens/step, 6.59 offered drafts/round, 77.6% accept rate, per-depth survival [0.955, 0.904, 0.854, 0.791, 0.715, 0.614, 0.279]).

Supporting evidence and material limitations

  • C compilation with strict warnings (-std=gnu11 -Wall -Wextra -Werror):
    • cc -std=gnu11 -Wall -Wextra -Werror -c helios/native/roce_proxy.c -o /dev/null: passed with 0 warnings.
    • cc -std=gnu11 -Wall -Wextra -Werror -c helios/native/roce_proxy_dlopen.c -o /dev/null: passed with 0 warnings.
  • CPU unit tests (CUDA_VISIBLE_DEVICES="", --locked):
    • cargo test --locked --manifest-path helios/Cargo.toml --features runtime-core,server,roce --lib -- execution::roce: 30 passed, 0 failed, 0 ignored (includes native_proxy_abi_matches_core_contract and lazy_libibverbs_loader_resolves_symbols_or_reports_install_hint linking the compiled roce_proxy_dlopen.c / roce_proxy.c object).
    • cargo test --locked --manifest-path helios/Cargo.toml --features runtime-core,server,roce --lib -- roce: 42 passed, 0 failed, 0 ignored.
    • cargo test --locked --manifest-path helios/Cargo.toml --features runtime-core,server --lib: 1,738 passed, 6 failed, 46 ignored (the 6 failures are unrelated frontend template fixture tests that require FLARE_TEST_TEMPLATE_DIR to be set).
    • cargo check --locked --manifest-path flare-cli/Cargo.toml: passed cleanly.
  • Material limitations: The live 4x DGX Spark SM121 TP4 RoCE flare run validation above exercises the combined SM121/RoCE kernel, recipe, and scheduler optimization set; isolated single-PR TP4 serving A/B and direct cpu_capacity sysfs pinning ablation were not run separately (thread naming and cpu_capacity affinity narrowing are verified by inspection, strict compilation, and CPU RoCE unit tests).

Discord: el8

…thread

On asymmetric ARM systems (such as NVIDIA Grace / GB10 big.LITTLE
topologies), the Linux scheduler can place or migrate the RoCE RDMA proxy
polling thread onto lower-capacity efficiency cores, adding tail latency
to doorbell polling, completion draining, and relay forwarding. Calling
`pthread_setname_np(pthread_self(), "flare-roce")` identifies the proxy
thread in profilers and OS tools, and `pin_high_capacity_cpus()` restricts
the thread's affinity mask within its existing allowed CPUs to the
high-capacity tier while leaving homogeneous, single-tier, non-Linux, or
<2-CPU environments unchanged.

Before -> after:
- `helios/native/roce_proxy.c`: previously `proxy_main()` left the thread
  unnamed and inherited the process CPU affinity mask unmodified. Added
  Linux-only `pin_high_capacity_cpus()` (reading
  `/sys/devices/system/cpu/cpu<id>/cpu_capacity` for CPUs in
  `sched_getaffinity`, selecting `>= 90%` of `max_cap` or fallback
  `> (min_cap + max_cap) / 2` when `>= 2` and `< count` CPUs qualify) and
  invoked `pthread_setname_np(pthread_self(), "flare-roce")` and
  `pin_high_capacity_cpus()` at the start of `proxy_main()`.
- Preserved `ROCE_SEND_DEPTH / 6` in `reserve()`, its world=16 ACK safety
  bound, and `ROCE_ABI_VERSION 14` unchanged.

Claimed benefit:
Prevents the RoCE proxy polling thread from running on lower-capacity CPUs
on asymmetric Linux hosts and makes the thread identifiable as
`flare-roce` in OS and profiler traces without altering wire layout,
send-queue reservation, or homogeneous-host affinity.

Supporting evidence and material limitations:
- `cc -std=gnu11 -Wall -Wextra -Werror -c helios/native/roce_proxy.c -o /dev/null`
  and `cc -std=gnu11 -Wall -Wextra -Werror -c helios/native/roce_proxy_dlopen.c -o /dev/null`:
  passed with 0 warnings.
- `CUDA_VISIBLE_DEVICES="" cargo test --locked --manifest-path helios/Cargo.toml --features runtime-core,server,roce --lib -- execution::roce`:
  30 passed, 0 failed, 0 ignored.
- `cargo check --locked --manifest-path flare-cli/Cargo.toml`: passed.
- Combined-stack 4x DGX Spark (SM121) TP4 RoCE serving via `flare run`
  (integrating the companion b12x kernel, recipe, and scheduler
  optimizations) passed end-to-end qualification; isolated single-PR TP4
  serving A/B and direct `cpu_capacity` sysfs pinning ablation were not run
  separately.

Design-Signed-Off-By: Antigravity (Gemini 4 Hydrogen); design-review=2e5b
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 633.
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

Review Stopped

Auto-Review halted due to finding: Another open pull request already covers this change, or more of it.
Value Proposition Report

@flare-autobot flare-autobot added duplicate This issue or pull request already exists 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 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists 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.

2 participants