Skip to content

[Engine] enable route tail-skip and configurable hot split for --peer-device - #6304

Closed
cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:pr/peer-tail-skip-hot
Closed

cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:pr/peer-tail-skip-hot

Conversation

@cobra91

@cobra91 cobra91 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Problem and result

When --peer-device is used to offload MoE experts across multi-GPU setups (especially asymmetric pairs like RTX 5080 + RTX 4060 Ti, or bandwidth-constrained links such as PCIe Gen4 x2/x4 and eGPU), decode throughput suffers from three compounding issues:

  1. Route tail-skip was globally disabled: In generate.cpp:14183, o.peer_device < 0 excluded peer configurations from the default STRATA_ROUTE_TAIL_SKIP=7, and expert_source.cpp:5028 had d.peer == nullptr hard-coded in the skip logic. Consequently, missed experts routed at low rank (ranks 7–9 in top-10) were forced across PCIe to the peer card or host CPU even though their router weight is negligible, inflating PCIe offload traffic to 48.1% of all routed experts.
  2. Hardcoded hot-split default: STRATA_PEER_HOT defaulted to 0.45 (moving 45% of the first 8,700 ranked experts to the peer card), which was tuned for identical GPUs on symmetrical x16 links. On asymmetric GPUs or narrow PCIe slots, this forced half the most critical experts onto the slower card over the bottlenecked link, with no command-line flags to adjust it (STRATA_PEER_HOT was an undocumented environment variable only).
  3. Unmitigated CPU spin-polling on stream queries: PeerExperts::finish spun on cudaStreamQuery(stream_) in an empty loop across 48 layers per window, consuming 100% of a CPU core and creating interconnect contention with CPU pool workers.

Result:

  • Enabling route tail-skip on missed experts (STRATA_ROUTE_TAIL_SKIP=7) reduces peer PCIe offload from 48.1% down to 26.0%–27.4% and increases primary GPU expert cache hits to 97.0%–97.7%.
  • Adding --peer-hot <frac> and --peer-hot-at <n> CLI flags allows users with asymmetric GPUs to set --peer-hot 0 (keeping all top-tier experts on the primary GPU), eliminating PCIe transfer penalties on the critical path.
  • Adding _mm_pause() inside PeerExperts::finish eliminates tight CPU spin contention during stream queries.
  • On an asymmetric dual-GPU system (RTX 5080 16GB PCIe Gen5 x16 + RTX 4060 Ti 16GB PCIe Gen4 x2), decode throughput increases from 66.9 tok/s to 84.7–87.4 tok/s (+30.6% sustained speedup across 2,500 generated tokens) with 141,249 tail-misses cleanly skipped and 0 token divergence.

Related discussion

Follow-up to #6303 ([Engine] allow layer-major prefill super-chunks with --peer-device) addressing the decode bottleneck in asymmetric dual-GPU configurations.

Approach

  1. engine/src/core/expert_source.cpp:
    • In expert_pool_dispatch_multi: remove d.peer == nullptr from the tail_rank > 0 condition. Tail-skip logic now checks tail_rank > 0 && d.remote_count == 0, inspecting d.host_res to skip low-rank misses on the primary GPU without dispatching them to the peer card or CPU pool.
  2. engine/src/core/peer_experts.cpp:
    • In PeerExperts::finish: add _mm_pause() inside while ((e = cudaStreamQuery(stream_)) == cudaErrorNotReady) (guarded with #if defined(_MSC_VER) || defined(__x86_64__) || defined(_M_X64)) to relieve memory bus and hyper-thread contention during per-layer polling.
  3. engine/src/program/generate.cpp:
    • In struct Options: add double peer_hot = -1.0; int64_t peer_hot_at = -1;.
    • In CLI argument parsing: add --peer-hot <frac> and --peer-hot-at <n>, with help text in usage().
    • In profile hot-reordering: use o.peer_hot / o.peer_hot_at when provided, falling back to existing STRATA_PEER_HOT / STRATA_PEER_HOT_AT environment variables or default 0.45 / 8700.
    • In default path selection: remove o.peer_device < 0 from lines 14183 and 14188 so STRATA_ROUTE_TAIL_SKIP=7 is enabled by default in peer mode when experts are missed.

Validation

Passed:

  • strata.exe --serve --peer-device 1 --peer-hot 0.0 --vram-reserve-mib 1400
    • Revision: commit on pr/peer-tail-skip-hot (branched from origin/main 58ee322)
    • Environment: Windows 11, MSVC 19.41, CUDA 13.4, SM 8.9 + SM 12.0
    • Primary GPU: NVIDIA GeForce RTX 5080 (16GB, SM 12.0)
    • Peer GPU: NVIDIA GeForce RTX 4060 Ti (16GB, SM 8.9, PCIe Gen4 x2, 3.2 GB/s)
    • Model: Swift-Qwen3.8-Flash-Next (IQ2_XS, 24,576 experts, 48 layers, spec 8)
    • Results observed:
      • 500 tokens: 84.7 tok/s decode (vs 66.9 tok/s baseline).
      • 2,500 tokens sustained: 87.4 tok/s decode in 28.61s (vs 66.9 tok/s baseline, +30.6% speedup).
      • Route tail-skip log: strata serve: route tail skip: 141249 missed experts skipped (150883 entries) since the start.
      • Speculative acceptance: 71.0%–73.7% maintained with zero divergence.
      • Expert cache hit rate: 97.0%–97.7% primary hit rate (+26.0%–27.4% over PCIe).

Failed:

  • None observed.

Not run:

  • Non-CUDA builds (Metal, HIP/ROCm, SYCL) and non-x86 architectures (arm64 pause instruction), as the test hardware is dual NVIDIA CUDA x86_64.

Limits

  • On symmetrical setups (e.g. 2x identical GPUs on x16 links), the existing default of --peer-hot 0.45 remains unchanged unless explicitly configured via --peer-hot 0.0 or STRATA_PEER_HOT=0.0.

@cobra91
cobra91 force-pushed the pr/peer-tail-skip-hot branch from 32c933b to 92b907d Compare November 20, 2026 10:05
@cobra91

cobra91 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto v0.2.17 (3142b66b9).

Benchmarked in isolation on Strata v0.2.17 with an asymmetric dual-GPU setup (RTX 5080 + RTX 4060 Ti over PCIe Gen4 x2):

  • Setting --peer-hot 0.0 prevents demoting 3,915 top hot experts to the slow link, reducing PCIe bus traffic from 46.4% down to 28.2%.
  • Cold decode speed improves from 41.0 to 47.5 tok/s (+15.8%), and peak synthetic decode reaches 123.9 tok/s (vs 113.4 tok/s vanilla).
  • The _mm_pause() in PeerExperts::finish eliminates tight CPU core spin-waiting during stream query.

Clean and fully mergeable on v0.2.17.

@cobra91 cobra91 closed this Nov 24, 2026
@cobra91
cobra91 deleted the pr/peer-tail-skip-hot branch November 24, 2026 22:49
@cobra91
cobra91 restored the pr/peer-tail-skip-hot branch November 26, 2026 14:01
@cobra91 cobra91 reopened this Nov 26, 2026
@cobra91 cobra91 closed this Nov 26, 2026
@cobra91
cobra91 force-pushed the pr/peer-tail-skip-hot branch from 92b907d to c234774 Compare November 26, 2026 14:01
@cobra91
cobra91 deleted the pr/peer-tail-skip-hot branch November 26, 2026 14:01
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