Skip to content

[Engine] inkling2: zero-copy mapped staging and CUDA graph capture for asymmetric dual-GPU (cuda-ep2) - #6815

Closed
cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:perf/inkling2-cuda-graph-ep2
Closed

cobra91 wants to merge 0 commit into
Niko1221:mainfrom
cobra91:perf/inkling2-cuda-graph-ep2

Conversation

@cobra91

@cobra91 cobra91 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Problem and result

In cuda-ep2 mode on non-P2P dual-GPU configurations (e.g. Windows WDDM / PCIe setups without NVLink), CUDA Graph capture was hardcoded to disabled (runner_->use_cuda_graph = false). Consequently, every token execution incurred eager kernel launches across both GPUs (~240 individual kernel launches per token driven by the host CPU), limiting decode performance to 61.8 - 62.8 tok/s even with asymmetric zero-P2P tail-skip.

With this PR:

  1. Inter-GPU activation staging buffers (h_ep_x, h_ep_idx, h_ep_w, h_ep_y) are allocated as pinned mapped memory (cudaHostAllocPortable | cudaHostAllocMapped) with direct device pointer resolution on both GPUs (cudaHostGetDevicePointer).
  2. Replaces host-memory staging bounce with asynchronous device-to-device transfers between mapped pointers and cross-device events (ev_moe_ready, ev_peer_done).
  3. Enables multi-GPU stream capture via cudaStreamCaptureModeGlobal in forward_seq, forward_tree_verify, and forward_batched, seamlessly capturing both the local GPU 0 looped core visits (36 visits) and the mapped peer dispatches on GPU 1 (12 visits) into a single unified CUDA Graph.
  4. Decode performance jumps from 61.8 - 62.8 tok/s to 76.6 - 76.7 tok/s (+24% faster decode over PR [Engine] inkling2: zero-P2P tail-skip for asymmetric dual-GPU and sm_75 TC fallback #6811, and +70% faster than upstream v0.2.20 cuda-ls at 45.0 tok/s). Prefill reaches 106.9 - 116.9 ppts (+53% to +66% over upstream 70.1 ppts).

Related discussion

Builds directly upon PR #6811 (zero-P2P tail-skip). Replaces eager dispatch with hardware graph execution.

Approach

  • In engine/src/inkling2/cuda/ink_runner.cuh:
    • Declare dual device pointers d_ep_x[2], d_ep_w[2], d_ep_y[2], d_ep_idx[2].
    • In init_dual_gpu, allocate mapped portable host memory and resolve device pointers for primary and peer GPUs.
    • In run_visit, use cudaMemcpyDeviceToDevice across mapped buffers for peer dispatches instead of host-bounce copies.
    • Use cudaStreamCaptureModeGlobal during stream capture when ep2_active is true.
    • Remove hardcoded use_cuda_graph = false; in EP2 initialization.
  • In engine/src/inkling2/cuda/ink_cuda_backend.cu:
    • Allow runner_->use_cuda_graph in cuda-ep2 mode when vf_graph_ok && !model_.ls_active.

Validation

Passed:

  • Build: MSVC 19.51, CUDA 13.4, Ninja (cmake --build build --target strata-inkling).
  • Hardware: NVIDIA GeForce RTX 5080 16 GB (Blackwell sm_120) + GeForce RTX 4060 Ti 16 GB (Ada sm_89), non-P2P PCIe, Windows 11.
  • Command: strata-inkling.exe --bench --native Inkling-2-Mini-UD-Q4_K_XL.gguf --draft off --gpus 2 --prompt-len 64 --gen 128

Failed:

  • none observed

Not run:

  • Hardware execution on native NVLink hardware (verified on consumer non-P2P PCIe where inter-GPU staging operates; NVLink systems use direct cudaMemcpyPeerAsync).
  • HIP (AMD ROCm) and SYCL backends (this change modifies CUDA-specific backend files ink_runner.cuh and ink_cuda_backend.cu only).

Limits

  • Single-slot sequential decode (M=1) and batched decode are captured; Layer-Split (cuda-ls) remains on eager multi-stage pipeline handoffs.

@cobra91

cobra91 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

For anyone wanting to test the full Inkling 2 dual-GPU stack together (#6811 + #6815 + #6823 + #6832 + #6982) without mixing scopes across individual PRs, a dedicated integration branch is available at cobra91/Strata-DualGPU:lab/inkling2-full (0f302f582, smoke-tested on 2x 16 GB UD-Q4_K_XL --gpus 2 --kv k8v4: 1536 + 1536 / 0 host, 80.1 tok/s decode).

@cobra91 cobra91 closed this Nov 24, 2026
@cobra91
cobra91 deleted the perf/inkling2-cuda-graph-ep2 branch November 24, 2026 22:49
@cobra91
cobra91 restored the perf/inkling2-cuda-graph-ep2 branch November 26, 2026 14:00
@cobra91 cobra91 reopened this Nov 26, 2026
@cobra91 cobra91 closed this Nov 26, 2026
@cobra91
cobra91 force-pushed the perf/inkling2-cuda-graph-ep2 branch from b938229 to c234774 Compare November 26, 2026 14:00
@cobra91
cobra91 deleted the perf/inkling2-cuda-graph-ep2 branch November 26, 2026 14:00
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