Skip to content

[Engine] Maximize dual-GPU peer utilization with P2P shared expert, in-graph peer routing, DFlash2 peer offload, and HC Q8 DP4A v2 - #7079

Open
midhatn wants to merge 3 commits into
Niko1221:mainfrom
midhatn:feat/v0221-dual-gpu-max-pr
Open

midhatn wants to merge 3 commits into
Niko1221:mainfrom
midhatn:feat/v0221-dual-gpu-max-pr

Conversation

@midhatn

@midhatn midhatn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Problem and result

On dual sm_70 (2× Tesla V100-SXM2-16GB over NVLink NV6) running Qwen3.8-Flash-Next-UD-IQ2_XS-v31-Q8 in --peer-device 1, stock v0.2.21 left peer GPU 1 at only ~17.9–19.9% decode utilization while GPU 0 spent >33 ms per speculative verification window waiting on host/device work and P2P stalls.

Stacks on #7040 (85751bae1 / cherry-picked here as the first commit) and supersedes #6210, maximizing dual-GPU decode overlap with no change to single-GPU behavior and controlled mirrored A-B-B-A (200 W / 1020 MHz / 877 MHz) verification:

  • Offload all 48 pre-router shared experts to peer GPU 1 over P2P (STRATA_PEER_SHARED=1, opt-in): copies shared-expert weights to peer GPU 1, runs shared_expert_multi concurrently on peer_sh_cs_ during GDN/QSA residual prep, and scatters results back via NVLink.
  • Keep expert cache hit planning on-device (STRATA_VERIFY_DEVICE_HITS=1, opt-in): builds hit/miss slot plans directly via device kernels (verify_kernels.cu) instead of synchronous H2D/D2H bookkeeping.
  • Move peer weight/activation transfers & graph events in-graph (STRATA_PEER_IN_GRAPH=1, opt-in): fuses peer transfers and shared-expert synchronization inside CUDA Graph capture.
  • Offload DFlash2 drafter to peer GPU 1 (STRATA_DF2_PEER=1, opt-in) & tune V100 peer reservation (STRATA_PEER_HOT_AT / --vram-reserve-later-mib): overlaps draft speculation cleanly while keeping primary expert slots high.
  • Fused GR Q8_0 DP4A v2 (STRATA_HC_Q8_DP4A=2 in fused_gr.cu) & P2P word copy helpers (copy_i32_from_mapped / p2p_copy_words).

Measured mirrored A-B-B-A (2 × V100-SXM2-16GB, 200 W / 1020 MHz / 877 MHz clock-locked, STRATA_ROUTE_TAIL_SKIP=0):

  • Seeded3 decode median: 95.00 -> 105.45 tok/s (+11.0%; code_cpp 28.91 vs 33.38 ms/w, prose 107.5 vs 95.0 tok/s, needle64k 3/3 needles passing)
  • Pagoda HTML decode mean: 99.75 -> 106.20 tok/s (+6.5%, html_ok=True)
  • Profiled Pagoda decode: 89.3 -> 102.1 tok/s (+14.3%)
  • GPU 1 decode utilization: 17.9% -> 44.9% median on seeded3 (peak 64%), 19.9% -> 46.7% mean on Pagoda, with 0 ECC errors and 0 Xids.

Related discussion

Stacks on #7040 (feat/sm70-peer-dense-hc-dp4a); supersedes #6210 (closed).

Approach

  • Opt-in multi-GPU peer decode switches (STRATA_PEER_SHARED=1, STRATA_VERIFY_DEVICE_HITS=1, STRATA_PEER_IN_GRAPH=1, STRATA_DF2_PEER=1, STRATA_HC_Q8_DP4A=2, plus [Engine] Offload GDN gate/QSA Q to P2P peer and add opt-in sm_70 DP4A HC up-proj #7040's STRATA_PEER_GDN_Z=1 and STRATA_PEER_QSA_Q=1) scoped cleanly to Verifier / DFlash2 / fused_gr.cu / generate.cpp.
  • All new behaviors are gated behind explicit opt-in flags or --peer-device paths so default single-GPU and existing paths remain untouched.

Validation

Passed:

  • gr_parity --selftest on 2 × Tesla V100-SXM2-16GB (sm_70, CUDA 12.9, GCC 14.3.0) with STRATA_TSUM=1 STRATA_GR_Q8_DOWN_MODE=2 STRATA_HC_Q8_DP4A=2: gr_read/gr_write: 0 failures, gr_parity OK.
  • git diff --check origin/main..HEAD on 2af30ccaa: passed cleanly.
  • Controlled clock-locked mirrored A-B-B-A (n=2 rounds each on seeded3 + pagoda, 200.00 W / 1020 MHz / 877 MHz, ECC=0, 0 Xids):
    • stock v0.2.21: needle64k 93.4/93.8, code_cpp 107.0/108.0, prose 95.0/95.0, voxel_pagoda 100.7/98.8 (mean 99.75, GPU1 19.9%).
    • Phase 4 (6163759fa): needle64k 94.8/95.0 (needles_ok=True), code_cpp 105.4/105.5 (28.89-28.91 ms/w), prose 107.2/107.8, voxel_pagoda 106.3/106.1 (mean 106.20, html_ok=True, GPU1 46.7%).
    • Further confirmed in community A-B-B-A (logs/v0221_community_abba): p4_base needle64k 95.3/94.9, code_cpp 106.0/105.9 (28.74-28.79 ms/w), prose 107.8/107.8, voxel_pagoda 105.0/105.2.

Failed:

  • none observed

Not run:

  • HIP, SYCL, Metal, Windows MSVC, multi-GPU topologies without NVLink P2P (PCIe-only fallback paths remain unbenchmarked for STRATA_DF2_PEER=1).

Limits

Measured on one dual-V100-SXM2-16GB NVLink system with Qwen3.8-Flash-Next-UD-IQ2_XS-v31-Q8. All new switches are opt-in and require STRATA_Q8_INPLACE=1 / P2P peer support where indicated. If #7040 merges first, this PR can be rebased cleanly onto main to drop the stacked #7040 commit.

…d sm_70 DP4A HC up-proj

- Add opt-in Verifier dense offloads for --peer-device multi-GPU decode:
  STRATA_PEER_GDN_Z=1 (offloads 36 GDN attn_gate projections, ~443 MiB) and
  STRATA_PEER_QSA_Q=1 (offloads 12 QSA attn_q projections, ~295 MiB) onto the
  P2P peer GPU alongside peer experts, using mapped P2P copy kernels so
  multi-GPU CUDA graphs avoid in-graph cudaMemcpyAsync deadlocks.
- Account for offloaded peer dense buffer headroom in PeerExperts reserve
  sizing when STRATA_PEER_GDN_Z / STRATA_PEER_QSA_Q are enabled.
- Add opt-in STRATA_HC_Q8_DP4A=1 sm_61+/sm_70 coalesced uint4 __dp4a
  hyper-connection up-projection kernel (gr_up_q8_dp4a_kernel, 0 register
  spill, plain shared-memory loads), eliminating gr_mid_q8_kernel.
…-graph peer routing, DFlash2 peer offload, and HC Q8 DP4A v2
@midhatn

midhatn commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Added commit 39d58b8e75967bdd5df05a49d08974e544e8f56a fixing an MMU fault (Xid 31) when DFlash2 runs under --layer-split (multi_gpu == true, !df2_first):

  • Cause: df2_head_dev did not check !multi_gpu, so when df2.device() != 0 && !native_head.is_split(), it passed head_device = 0 even though df2.bind(...) receives &last_st->head on the drafter's own GPU (CUDA1). That launched kernels::gather_rows on CUDA0 reading a CUDA1 pointer.
  • Fix: Guard the peer fallback with !multi_gpu && in engine/src/program/generate.cpp.
  • Verified live on Dual Tesla V100-SXM2-16GB (rebased onto v0.2.23 with Qwen3.8-Flash-Next GSQ-RCO IQ3_S @ 262144 ctx):
    • --layer-split auto (DFlash2 on CUDA1 last stage, 8 ms graph capture): 142.4–156.4 tok/s short prompt prefill, 79.9–84.9 tok/s decode, 0 Xids, 0 NVLink errors.
    • --peer-device 1 (STRATA_DF2_PEER=1 + STRATA_PEER_HEAD_SPLIT=1): 95.8 tok/s short prompt prefill, 95.6 tok/s decode, 0 Xids, 0 NVLink errors.

…-split

Under --layer-split (multi_gpu == true, !df2_first), df2.bind(...)
receives &last_st->head, which already resides on the same GPU as
df2.device(). Omitting !multi_gpu caused df2_head_dev to evaluate to 0
(CUDA0) instead of -1, launching gather_rows on CUDA0 reading a CUDA1
device pointer (MMU Xid 31 fault).
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