Skip to content

[None][perf] NIXL transfer agent: direct peer copy over NVLink for VRAM writes - #21931

Draft
Wanli-Jiang wants to merge 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/nixl-direct-peer-copy
Draft

Wanli-Jiang wants to merge 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/nixl-direct-peer-copy

Conversation

@Wanli-Jiang

@Wanli-Jiang Wanli-Jiang commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

With TRTLLM_NIXL_DIRECT_COPY=1 on both agents, the receiver exports the fabric handles of its registered VMM chunks in an AgentDesc extension envelope (a raw bounce handshake from an older peer still decodes). The sender imports and maps them, then serves each VRAM -> VRAM write with one gather-scatter kernel (at most 32 CTAs, 256 KiB units, plan read from mapped pinned host memory) and one event, instead of one cuda_ipc copy plus event record per descriptor. Off by default.

Which peers it serves:

  • Any peer whose fabric handles this process may import: the same node, or another node of the same NVLink domain when both processes hold the same IMEX channel (one Slurm job under switch/nvidia_imex, or one Kubernetes ComputeDomain). For any other peer the import fails (CUDA_ERROR_NOT_PERMITTED for another IMEX channel), and that peer keeps the bounce / NIXL path.
  • Imports run on four background threads, so loadRemoteAgent returns at once; writes to a peer go through NIXL until its mapping is published. Mapping a peer's pools costs about 0.2 ms per physical chunk on one node and up to about 1 ms across nodes (seconds for a full KV pool). A generation per peer name drops a mapping made stale by an invalidate or reload during its import.
  • Writes it cannot serve (non-VRAM, sync message, destination outside the mapped regions) keep the bounce / NIXL path; the direct path is tried before bounce.

Kernel: plans whose work units average at most 32 KiB use one warp per unit, larger units one CTA per unit. Small units are what a transfer between ranks with different KV heads per rank produces (ctx TEP -> gen DEP or the reverse moves per-layer head slices, 8 KiB with fp8 KV and 32-token blocks).

Counters on the Python agent: direct_submit_count, direct_cross_node_submit_count, direct_mapped_peer_count.

Evidence, serving (Qwen3.8 FP8 agentic serving, GB300, disaggregated ctx TEP2 + gen TEP2 on one node, ctx workers also with CUDA_DEVICE_MAX_CONNECTIONS=32):

  • 3600 s runs, switch off -> on: c240 output 277.4K / 276.5K -> 284.3K / 284.5K tok/s (+2.5 %, two runs each), TTFT p90 2.14 / 2.33 -> 1.16 / 1.18 s; c256 274.2K -> 294.7K (+7.5 %), TTFT p90 9.13 -> 1.77 s; the c160 latency point x -1.1 % (noise level).
  • Greedy outputs 160/160 identical; GSM8K 95.49 with the switch on.

One more 3600 s run at the highest point measured, concurrency 272, same deployment and configuration with only the switch off: total throughput 279.7K tok/s per GPU and TTFT p90 13.4 s, against 314.5K and 1.30 s with the switch on. One of two runs with the switch on at that concurrency saw 17 KV-transfer timeouts during a whole-deployment stall; the run with the switch off saw none. Whether the stall involves the direct copy is not settled, which is why the switch stays opt-in.

Evidence, transfer microbenchmark (GB300 NVL72; one process per GPU, receiver pools allocated like KVCacheManagerV2 (fabric VMM, 32 MiB chunks, 160 GiB), descriptors produced by the native transceiver's own mappers and routing for Qwen3.8 KV geometry, every destination byte checked):

ctx -> gen placement direct GB/s NIXL GB/s
TP1 -> TP1, TEP2 -> TEP2, DEP2 -> DEP2 one node 637 / 1,257 / 1,039 49 / 47 / 88
TEP2 -> DEP2, DEP2 -> TEP2 (head slices) one node 879 / 956 5 / 6.4
DEP4 -> DEP4, DEP4 -> TEP4, TEP4 -> DEP4 two nodes 1,569 / 1,673 / 1,466 114 / 9.7 / 10
TEP8 -> DEP8, DEP8 -> DEP8, DEP8 -> TEP8 four nodes 2,076 / 2,475 / 2,764 18 / 185 / 18
4 x TEP2 ctx + 2 x TEP4 gen; DEP4 + TEP4 ctx with TEP4 + DEP4 gen four nodes 2,539 / 2,398 120 / 24

GB/s is the bytes of one round of 16 or 32 requests (8K to 64K tokens) over the slowest sender's round time, all senders together; every write to a peer on another node took the direct path.

  • Cross-node bandwidth equals same-node bandwidth (TEP2 -> TEP2: 1,284 vs 1,257 GB/s).
  • The warp-per-unit kernel: head-slice plans +10 % to +29 % against one CTA per unit; head-matched plans unchanged.
  • Ctx and gen started as separate steps of one Slurm job share the IMEX channel and take the direct path. Two separate Slurm jobs (two IMEX channels): every import fails with CUDA_ERROR_NOT_PERMITTED, all writes take NIXL, bytes correct.
  • Time from the last loadRemoteAgent until every peer is mapped: 2 peers on one node 4.0 s; 4 / 8 peers on other nodes 5 to 17 s / 27 to 29 s.
  • One 883 MB write on one node: NIXL 18.10 ms -> direct 1.34 ms (p50).

The cpp_bounce transfer tests set TRTLLM_NIXL_DIRECT_COPY=0, so they keep exercising the bounce when the switch is on in the job environment.

Test Coverage

  • tests/unittest/disaggregated/test_nixl_direct_copy.py: direct peer copy against the descriptors on two GPUs with fabric memory (skips otherwise): mixed descriptor sizes through the CTA-per-unit kernel; head-slice-sized descriptors through the warp-per-unit kernel, with a write issued while the background import may still run and an invalidate + reload of the peer around it; and the same writes through NIXL. The writes checked after the mapping must take the direct path.
  • On GB300 at this head (main a6c28b4, native code rebuilt): test_nixl_direct_copy.py and test_mamba_transfer.py 16 passed.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

…AM writes

With TRTLLM_NIXL_DIRECT_COPY=1 on both agents, the receiver exports the
fabric handles of its registered VMM chunks in an AgentDesc extension
envelope (a raw bounce handshake from an older peer still decodes). The
sender imports and maps them, then serves each VRAM -> VRAM write with one
gather-scatter kernel (at most 32 CTAs, 256 KiB units, plan read from mapped
pinned host memory) and one event, instead of one cuda_ipc copy plus event
record per descriptor. Off by default.

The direct path serves any peer whose fabric handles this process may
import: the same node, or another node of the same NVLink domain when both
processes hold the same IMEX channel (one Slurm job under
switch/nvidia_imex, or one Kubernetes ComputeDomain). A peer whose import
fails (another IMEX channel or NVLink domain) keeps the bounce / NIXL path,
as do writes it cannot serve (non-VRAM, sync message, destination outside
the mapped regions); the direct path is tried before bounce.

Imports run on four background threads, so loadRemoteAgent returns at once
and writes go through NIXL until a peer's mapping is published; a
generation per peer name drops mappings made stale by an invalidate or
reload during the import. Plans whose work units average at most 32 KiB
(per-layer KV head slices between ranks with different KV heads per rank)
use one warp per unit instead of one CTA per unit.

Evidence (Qwen3.8 FP8 agentic serving, GB300, disaggregated, ctx workers
also with CUDA_DEVICE_MAX_CONNECTIONS=32):
- 3600 s runs, switch off -> on: c240 output +2.5 %, TTFT p90 2.14 / 2.33
  -> 1.16 / 1.18 s; c256 output +7.5 %, TTFT p90 9.13 -> 1.77 s.
- Transfer microbenchmark on GB300 NVL72 with the native transceiver's
  mappers: direct 637 to 2,764 GB/s against NIXL 5 to 185 GB/s across
  TP1 / TEP / DEP ctx-gen pairs on one, two and four nodes, every byte
  checked; cross-node bandwidth equals same-node bandwidth.
- Greedy outputs 160/160 identical; GSM8K 95.49 with the switch on.

The cpp_bounce transfer tests set TRTLLM_NIXL_DIRECT_COPY=0, so they keep
exercising the bounce when the switch is on in the job environment.

Signed-off-by: Wanli Jiang <[email protected]>
@Wanli-Jiang
Wanli-Jiang force-pushed the user/williamj/nixl-direct-peer-copy branch from 6dc5e0e to cf8bb49 Compare November 13, 2026 04:27
@Wanli-Jiang Wanli-Jiang changed the title [None][perf] NIXL transfer agent: same-node direct peer copy for VRAM writes [None][perf] NIXL transfer agent: direct peer copy over NVLink for VRAM writes Nov 13, 2026
@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

hand over to disagg team.

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

some further effort to close the gap, but not touch the direct-peer-copy standards: #22412

This branch has not been deployed

No deployments
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