Skip to content

[Engine] peer_experts: unified zero-P2P direct hardware signaling & autonomous dual-GPU decode window - #7310

Open
cobra91 wants to merge 5 commits into
Niko1221:mainfrom
cobra91:feat/peer-device-bundle
Open

cobra91 wants to merge 5 commits into
Niko1221:mainfrom
cobra91:feat/peer-device-bundle

Conversation

@cobra91

@cobra91 cobra91 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem and result:
On asymmetric dual-GPU setups without CUDA P2P (p2p=0, e.g. RTX 5080 PCIe Gen5 x16 + RTX 4060 Ti PCIe Gen4 x2 on Windows 11 WDDM), --peer-device 1 currently incurs per-layer host synchronization overhead (cudaStreamQuery / CPU polling) during verify windows. On Qwen 3.8 Flash-Next (Swift-IQ2_XS), decode speed stays around 20.15–22.11 tok/s even with --resident-experts and tuned routing.
With this consolidated PR (STRATA_PEER_DIRECT_SIGNAL=1 + STRATA_PEER_AUTONOMOUS=1), dual-GPU decode jumps from 22.11 to 54.48 tok/s (2.46x) with default --mmap-experts, from 21.04 to 192.00 tok/s (9.13x) at --spec 4 --resident-experts, and reaches 232.63 tok/s (6.33 tokens/round) at --spec 8 --resident-experts --ram-keep-gib 8 with STRATA_DF_PDL=1.

Related discussion:
Consolidates the peer_experts / autonomous dual-GPU decode work from #6419 and #6815 onto current main (c23477403). (Unrelated to #6811, which targets inkling2.)

Approach:

  1. Direct hardware GPU-to-GPU PCIe flag handoff (STRATA_PEER_DIRECT_SIGNAL=1, opt-in):
    • PeerExperts::launch(), scatter_rows_and_signal_f32(), and signal_stream_done() fuse row scatter with __threadfence_system() and a mapped host completion flag so the primary GPU polls in hardware without per-layer host spin-wait.
  2. Autonomous hardware-synchronized dual-GPU decode window (STRATA_PEER_AUTONOMOUS=1, opt-in):
    • Coordinates primary and peer GPUs across the verify window via mapped PCIe doorbells (Verifier, PeerExperts, generate.cpp), preserving autonomous mode even when experts spill beyond both GPUs.
  3. Why tuning knobs and --ram-keep-gib matter (54.48 -> 192.00 -> 232.63 tok/s):
    • Under default settings (--mmap-experts, STRATA_PEER_HOT=0.45), hot experts are routed to the slower Gen4 x2 peer and uncached experts hit mmap, capping autonomous decode at 54.48 tok/s.
    • Pairing STRATA_PEER_DIRECT_SIGNAL=1 and STRATA_PEER_AUTONOMOUS=1 with --resident-experts + STRATA_PEER_HOT=0.0 + STRATA_ROUTE_TAIL_SKIP=7 + STRATA_ADAPT_OVERLAP=1 + STRATA_ADAPT_SIGNAL=copy keeps hot experts on the primary GPU and resident in RAM, pushing --spec 4 to 192.00 tok/s and --spec 8 (STRATA_DF_PDL=1, --ram-keep-gib 8, 5.70 GiB page-locked) to 232.63 tok/s.
    • Note on --ram-keep-gib: on this 32 GB Windows 11 host, values < 8 (3–6) exceed cuMemHostAlloc and fall back to VirtualLock (pinned 0.00 GiB), whereas 8–10 achieve full page-locking (3.47–5.79 GiB pinned, 17.7–20.2 ms/round). Because changing --ram-keep-gib shifts how many experts stay in RAM vs file/CPU, borderline IQ2_XS prompts can switch between high-acceptance counting (3.88–6.33 tok/round, 188–232 tok/s) and low-acceptance prose (1.07 tok/round, 60.5 tok/s), while two identical runs at a fixed --ram-keep-gib remain deterministic (372/383 at 6, 33/1385 at 8).
  4. Setup detection & opt-in asymmetric --peer-device profile (terminal/setup.py):
    • asymmetric_dual_gpu_info() compares compute capability, VRAM, and pcie_link() bandwidth across a 2-GPU CUDA pair, ensures the stronger GPU is placed as primary (main), surfaces the detected asymmetry and recommended knobs, and lets users opt in via --peer-asymmetric-tune (or interactive prompt) to write STRATA_PEER_DIRECT_SIGNAL=1, STRATA_PEER_AUTONOMOUS=1, STRATA_PEER_HOT=0.0, STRATA_ADAPT_OVERLAP=1, STRATA_ADAPT_SIGNAL=copy into cfg["env"].

Validation:

  • Passed (build):
    • cmake -B build -S engine -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="89;120" && cmake --build build --target strata -j 8 on Windows 11 (MSVC 19.51, CUDA 13.4.92), commit ca426b6d9 on top of c23477403.
  • Passed (setup unit tests):
    • py -m unittest tools.test_setup_peer_asymmetric tools.test_setup_pcie -v (8 tests passed: asymmetric RTX 5080 + RTX 4060 Ti detection, reversed-order stronger-primary selection, PCIe-only asymmetry tie-breaker, symmetric pair no-op, and PCIe parsing checks).
  • Passed (hardware A/B benchmarks, Windows 11, RTX 5080 16 GB sm_120 + RTX 4060 Ti 16 GB sm_89, p2p=0, Qwen 3.8 Flash-Next Swift-IQ2_XS, --peer-device 1 --kv int8 --prefill 2048, STRATA_SM120_PERF=1):
Workload & Knobs Baseline (0 / 0) PR #7310 (1 / 1) Speedup / Notes
--mmap-experts, default peer knobs (--spec 4, 24-tok, --max-new 256) 22.11 tok/s (11577.8 ms) 54.48 tok/s (4698.8 ms) 2.46x (+146%)
--mmap-experts, PEER_HOT=0.0, TAIL_SKIP=7, ADAPT_OVERLAP=1, ADAPT_SIGNAL=copy (--spec 4, 24-tok, --max-new 500) 20.15 tok/s (24810.9 ms) 76.82 tok/s (6508.5 ms) 3.81x (+281%)
--resident-experts, tuned knobs, --ram-keep-gib 8 (--spec 4, 41-tok, --max-new 500) 21.04 tok/s (23768.8 ms) 60.11–60.52 tok/s (8262.3 ms) 2.88x (467 rounds, 1.07 tok/r, 17.7 ms/r, 5.79 GiB pinned)
--resident-experts, tuned knobs, --ram-keep-gib 10 (--spec 4, 41-tok, --max-new 500) 21.04 tok/s (23768.8 ms) 192.00 tok/s (2604.2 ms) 9.13x (129 rounds, 3.88 tok/r, 20.2 ms/r, 3.47 GiB pinned)
--resident-experts, tuned knobs, --ram-keep-gib 8, STRATA_DF_PDL=1 (--spec 8, 41-tok, --max-new 500) — 232.63 tok/s (2149.3 ms) 80 rounds, 6.33 tok/r, 426/453 accepted, 5.70 GiB pinned
  • All runs exited cleanly with 0 MiB / 0 MiB residual VRAM on nvidia-smi.
  • Failed:
    • None observed on the tested CUDA configurations or Python unit tests.
  • Not run:
    • HIP and SYCL builds/hardware runs were not executed (changes are opt-in and target CUDA peer_experts / elementwise.cu).
    • Hardware P2P (p2p=1 / NVLink) pairs were not tested on this rig.

Limits:

  • Both STRATA_PEER_DIRECT_SIGNAL=1 and STRATA_PEER_AUTONOMOUS=1 (as well as --peer-asymmetric-tune in terminal/setup.py) are opt-in and preserve existing default behavior when unset.
  • Tested on Windows 11 WDDM asymmetric dual-GPU (sm_120 + sm_89, p2p=0); HIP/SYCL and NVLink behavior remains unverified by hardware runs here.

…PU decode window

- Rebase on PR Niko1221#274 (direct hardware flag handoff opt-in via STRATA_PEER_DIRECT_SIGNAL=1)
- Add system fences (__threadfence_system) on PCIe doorbells and scatter completion signals to prevent mutual wait_flag_ge deadlocks
- Add all_gpu_resident check in Verifier::init and refresh_ar to gracefully disable autonomous mode when host expert fallback is required
- Ensure safe pre-launch gather for PLE and propagate return status from peer_->launch_window
@github-actions github-actions Bot added the needs-format Title or template does not follow CONTRIBUTING.md yet label Nov 27, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the pull request. To keep the tracker readable, every item needs an area prefix in the title and the parts of the pull request template filled in. This one is missing:

  • Fill in "Validation": the exact commands, the revision and environment tested, what you saw. Keep Passed, Failed and Not run apart.

Edit the pull request (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

@github-actions github-actions Bot removed the needs-format Title or template does not follow CONTRIBUTING.md yet label Nov 27, 2026
@github-actions

Copy link
Copy Markdown

Thanks, this follows the format now.

@cobra91

cobra91 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@dailybarid Following your 2x RTX 3060 12 GB (sm_86, p2p=0, 31 GB RAM, Linux) benchmarks in #6811 (comment): if your setup and time allow, we would be very interested in seeing how --peer-device 1 vs layer split (--gpus 0,1) compares on a symmetric 12 GB p2p=0 pair with this PR (#7310 targets Qwen3.6 / Qwen3.8 Flash-Next, separate from inkling2).

  • On an asymmetric p2p=0 pair (RTX 5080 PCIe 4.0 x16 + RTX 4060 Ti PCIe 4.0 x2), --peer-device 1 with STRATA_PEER_DIRECT_SIGNAL=1 and STRATA_PEER_AUTONOMOUS=1 wins clearly because the stronger card keeps the dense/attention/draft critical path while the slower card acts as a secondary expert tier.
  • On a symmetric 12 GB p2p=0 pair (2x RTX 3060), layer split distributes dense weights and KV across 24 GB total, whereas --peer-device 1 keeps dense weights + KV on GPU 0. Having empirical A/B numbers (--gpus 0,1 vs --peer-device 1 with STRATA_PEER_DIRECT_SIGNAL=1 STRATA_PEER_AUTONOMOUS=1 STRATA_PEER_HOT=0.0 STRATA_ADAPT_OVERLAP=1 STRATA_ADAPT_SIGNAL=copy) on 2x RTX 3060 12 GB would help identify the real crossover point between the two modes.

@cobra91

cobra91 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased/merged onto Niko1221/Strata:main (8db8753d5, v0.2.23 / 0.1.71) in 299728dbc (single conflict in docs/SETTINGS.md resolved).

Re-verified on Windows 11 (RTX 5080 16 GB + RTX 4060 Ti 16 GB, p2p=0, Qwen 3.8 Flash-Next Swift-IQ2_XS, DFlash2 --spec 8, --kv q4_0 --kv-resident 32768, STRATA_PEER_DIRECT_SIGNAL=1, STRATA_PEER_AUTONOMOUS=1):

  • Build & unit tests: strata.exe (Release, CUDA 89;120) builds cleanly ([173/173]); tools.test_setup_peer_asymmetric + tools.test_setup_pcie pass (8/8 OK).

Context sweep (--resident-budget-gib 0, counting greedy, 500 generated tokens)

--max-context Decode (500 tok) Speculation Experts in VRAM (GPU 0 + GPU 1) Pinned KV RAM
65,536 (64K) 269.19 tok/s 65 rounds, 439/439 (7.75 tok/r) 17,750 / 24,576 (6,997 + 10,753) 0.42 GiB
131,072 (128K) 270.72 tok/s 65 rounds, 438/438 (7.74 tok/r) 17,667 / 24,576 (6,913 + 10,754) 0.84 GiB
196,608 (192K) 273.48 tok/s 65 rounds, 438/438 (7.74 tok/r) 17,589 / 24,576 (6,830 + 10,759) 1.27 GiB
262,144 (256K) 225.95 tok/s 101 rounds, 399/427 (4.95 tok/r) 17,510 / 24,576 (6,747 + 10,763) 1.69 GiB

(Note: when also locking 5.70 GiB resident RAM via VirtualLock on this 32 GB Windows host under tight commit, runs at 131072/196608 hit [pinned-memory-exhausted] during verify staging allocation.)

Real filled-context checks past --kv-resident 32768 (500 generated tokens)

Prompt filled --max-context Prefill Decode (500 tok) Speculation
2,047 tok (2K) 65,536 373.41 tok/s (412.7 engine) 201.30 tok/s DFlash2 --spec 8 (256 gen)
40,959 tok (40K) 65,536 (--kv q4_0) 495.74 tok/s (82.6 s) 237.01 tok/s 64 rounds, 441/441 (7.89 tok/r)
131,071 tok (128K) 196,608 (--kv q4_0) 835.97 tok/s (156.8 s) 222.02 tok/s 64 rounds, 441/441 (7.89 tok/r)
131,071 tok (128K) 196,608 (--kv int8) 851.76 tok/s (153.9 s) 231.40 tok/s 64 rounds, 441/441 (7.89 tok/r, 2.32 GiB pinned KV)

All runs exited 0 cleanly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant