Skip to content

[Engine] Enable GPU-to-GPU doorbell for --expert-gpu with CUDA graphs and DSpark - #357

Open
cobra91 wants to merge 1 commit into
simplexai-labs:mainfrom
cobra91:feat/expert-gpu-p2p
Open

cobra91 wants to merge 1 commit into
simplexai-labs:mainfrom
cobra91:feat/expert-gpu-p2p

Conversation

@cobra91

@cobra91 cobra91 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Git-isolated directly on main (zero overlapping diff lines with #356). At runtime on models where kCpuRows > MAX_NCOLS (e.g. Inkling-2-Mini), #356 is required for ExpertCard initialization (#355).

Problem and result

Previously, --expert-gpu forced Engine::card_moe() to return false, disabling CUDA graph capture and card-side routing (moe_card()) and falling back to host-routed Engine::moe() with per-layer router synchronization (router wait).

This PR enables the GPU-side doorbell (ExpertBell) for --expert-gpu across both single-token decode (n = 1) and DSpark verification windows (n = 1..8):

  • GPU 0 keeps full CUDA graph replay (passes_ / step_passes_) and computes all local cached experts via d_zslots_.
  • Cold experts held on GPU 1 (ExpertCard) are dispatched asynchronously through bell_serve() / bell_job() while GPU 0 runs its own experts, with GPU 1 signaling h_bell_->ack directly from its stream via bell_ack when no CPU fallback experts are needed.

Approach

  • engine/include/strata/poly/kernels.hpp and engine/src/poly/kernels.cu:
    • Extended ExpertBell (kBellJobs = 128, rows, row[kBellJobs]) and bell_ring() (optional rows = 1) to carry multi-row verification windows (n = 1..8).
    • Added bell_ack() kernel so GPU 1 signals bell->ack = seq with __threadfence_system() directly after its D2H cudaMemcpyAsync into h_cpu_.
  • engine/src/poly/expert_card.hpp and engine/src/poly/expert_card.cpp:
    • Extended ExpertCard::start() with optional dst_rows, bell, and seq parameters to copy directly to h_cpu_ and signal bell_ack() without a host cudaStreamSynchronize() or CPU addition loop.
  • engine/src/poly/engine.hpp and engine/src/poly/engine.cpp:
    • Allowed card_moe() and bell_on() for ecard_ when n <= kCpuRows (including when pool_ is active).
    • Updated bell_job(uint32_t seq) to dispatch ecard_ misses asynchronously via bell_ack() when n_host == 0, or overlap ecard_ with pool_take() and cpu_experts() when CPU fallback experts are present.

Validation

  • This PR alone (main + #357): clean single-commit rebase on main (2545ec54e), builds cleanly (strata-poly.exe, Ninja Release, CUDA 13.4 sm_89;120), zero merge conflicts against #356.
  • This PR + #356 on Windows 11 (RTX 5080 16 GB + RTX 4060 Ti 16 GB PCIe Gen4 x2, 302-token prompt, 256 generated tokens, --kv fp8 --max-context 32768):

1. Inkling-2-Mini-UD-Q4_K_XL.gguf (fits across both GPUs: 99.2–99.5% VRAM hits)

Configuration Decode (tok/s) Gain vs #356 alone Prompt (tok/s) VRAM hits Router wait Draft accepted
#356 alone (--expert-gpu 1 --no-draft, host-routed) 60.17 baseline 256.9 99.6% 3.5 ms/tok —
#356 + #357 (--expert-gpu 1 --no-draft, doorbell + bell_ack) 102.84 +70.9% 274.8 99.5% 0.3 ms/tok —
#356 alone (--expert-gpu 1 + DSpark, host-routed) 55.97 baseline 304.0 99.4% 2.8 ms/tok 68 / 103
#356 + #357 (--expert-gpu 1 + DSpark, doorbell + bell_ack) 135.59 +142.3% 316.9 99.2% 0.2 ms/tok 136 / 183

2. Inkling-2-Mini-UD-Q8_K_XL.gguf (21.30 GiB — exceeds single-GPU VRAM, mixed-quant layers)

Configuration Decode (tok/s) Prompt (tok/s) VRAM hits Notes
--layer-split auto --no-draft 3.21 72.1 91.1% Layers 20–23 on card 1: 0/512 experts in VRAM
--layer-split 18 + DSpark (on main) (unsupported) — — Inkling 2's --draft-model runs on one card
Mono (RTX 5080) + DSpark 14.45 118.3 88.0% 1862/3072 experts in VRAM (10.5 GiB outside VRAM)
#356 + #357 (--expert-gpu 1 --no-draft) 14.87 138.8 91.7% 4.6x faster than --layer-split auto
#356 + #357 (--expert-gpu 1 + DSpark) 13.85 135.4 91.2% 2560/3072 experts in VRAM across GPU 0 + GPU 1
  • Verified nvidia-smi reports 0 MiB on both GPUs after exit.

Limits

  • Only tested on Windows 11 with CUDA (RTX 5080 + RTX 4060 Ti, non-P2P).
  • When n_host > 0 (an expert is on neither GPU 0 nor GPU 1), bell_job() still synchronizes GPU 1 on the host to accumulate ecard_ and CPU outputs into h_cpu_.
  • On mixed-quant models where some MoE layers are unsupported by native_mmvq_ids_supported() (e.g. UD-Q8_K_XL layers 20–23), Engine::open() currently disables h_bell_ globally across all layers.

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