Skip to content

[None][perf] NIXL bounce: push gather into the peer's mapped arena - #22412

Closed
Wanli-Jiang wants to merge 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/bounce-push-gather
Closed

Wanli-Jiang wants to merge 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/bounce-push-gather

Conversation

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

With kv_cache_bounce_size_mb set, the bounce transport gathers each chunk of a KV transfer into a local staging region of its arena, posts one NIXL write of that region into the region the receiver granted, and the receiver scatters it into the destination blocks. Between NVLink peers that NIXL write is a UCX cuda_ipc copy-engine copy, and one sender's copies run one at a time: on GB300 a 128 MiB chunk copies at about 750 GB/s, but the copies queue behind each other, and a larger arena, more chunks in flight, UCX_CUDA_IPC_MAX_STREAMS or copy_stream_count do not change that. The staged path tops out at 55-76 % of a direct peer copy on the shapes below.

This change adds push_gather (agent_bounce_params: {push_gather: "1"} or TRTLLM_NIXL_BOUNCE_PUSH_GATHER=1, off by default):

  • The bounce arena is already fabric memory on MNNVL parts. Each agent now advertises the arena's CU_MEM_HANDLE_TYPE_FABRIC handle and its address range in the bounce handshake (handshake format 2; format 1 blobs from older peers still decode, without an export).
  • A sender with push_gather maps the peer's arena when it loads the peer (one import and map of one allocation, 0.1-5 ms). The gather kernel then writes each chunk straight into the region the receiver granted and sends DATA once the kernel has completed. There is no local staging region and no NIXL write per chunk; the receiver side (credits, scatter, ACK) is unchanged.
  • A chunk's gather starts once its GRANT arrives (eager gather does not apply: there is no remote target before the grant).
  • A peer whose arena cannot be mapped (not fabric memory, another NVLink domain or IMEX channel) keeps the staged path; the reason is logged once when the peer is loaded.
  • A granted region outside the mapped arena abandons the flow (kProtocolError), like a credit/chunk size mispair.
  • In-flight chunks and orphaned gathers hold a reference to the mapping, so invalidateRemoteAgent or a reload never unmaps memory a kernel may still write. A failed request whose push gather may still be running defers its cancel until the kernel is done, as it already does for an in-flight write.

The KV layouts measured here (Qwen3.8 FP8, about 98 KB per descriptor) never use bounce under the default admission gate (at least 1024 descriptors averaging at most 16 KiB), so every bounce row below also sets min_descriptor_count: "0" and max_average_descriptor_size: "32MB". This PR does not change the gate.

Performance

Transfer benchmark on GB300 NVL72: the KV layout of Qwen3.8 FP8 (12 attention layers, 2 KV heads, head dim 256, 32 tokens per block), 16 concurrent requests of about 575 MB, the same descriptors for every path. Aggregate GB/s over the timed rounds; every run compared all bytes, 0 mismatches.

Shape Standard NIXL Bounce, staged (4 GiB, 128 MiB chunks) Bounce, push gather (512 MB arena) Direct peer copy (#21931)
ctx TP2 → gen TP2, one node 61 946 1,199 1,224
ctx TP2 → gen TP2, two nodes of one rack — 915 1,173 1,269
ctx DP4 → gen DP4, two nodes — — 1,349 1,537
ctx TP4 → gen DP4, two nodes — — 1,159 1,431

Served agentic multi-turn traffic: disaggregated, ctx TP2 + gen TP2 on one node, 256 concurrent sessions, 900 s windows, arms paired on the same node, every arm configured the same on both instances.

Transfer path Runs Total tokens/s/GPU P90 interactivity (tok/s/user) TTFT p50 TTFT p90
Standard NIXL 2 248.1K 114.2 1.57 s 11.22 s
Bounce, staged (4 GiB arena, 128 MiB chunks, 16 in flight) 2 260.5K 109.6 1.17 s 5.82 s
Bounce, push gather (512 MB arena, 32 MiB chunks) 3 262.9K 107.2 1.04 s 4.92 s
Bounce, push gather (4 GiB arena, 128 MiB chunks, 16 in flight) 2 263.7K 107.3 0.91 s 5.08 s
Direct peer copy (#21931) 5 265.4K 107.0 0.83 s 4.48 s

The standard NIXL row comes from an earlier run of the same deployment. Against it, push gather recovers 90 % of the direct peer copy's throughput gain with 128 MiB chunks; the staged path recovers 72 %. With 32 MiB chunks the remaining TTFT gap grows with prompt length and appears only in load bursts (each chunk is one GRANT / DATA / ACK round), and a larger arena alone does not close it.

Test Coverage

  • cpp/tests/unit_tests/executor/bounce/bounceMessageCodecTest.cpp: handshake round trip with the arena export; a format-1 blob still decodes; a truncated handle is rejected.
  • cpp/tests/unit_tests/executor/bounce/bounceConfigTest.cpp: TRTLLM_NIXL_BOUNCE_PUSH_GATHER parses.
  • cpp/tests/unit_tests/executor/bounce/bounceAgentE2ETest.cpp: PushGatherTransfersIntact, four concurrent multi-chunk requests with push_gather on, data verified (push where the arena can be mapped, staged otherwise).
  • tests/unittest/llmapi/test_llm_args.py: test_agent_bounce_param_keys_match_cpp_env_knobs covers the new key in both allowlists.
  • The transfer benchmark above at this head's bounce sources on GB300 (native code rebuilt): push gather and staged bounce on the TP2 → TP2, TP2 → DP2 and DP2 → DP2 shapes, every byte compared, 0 mismatches. The C++ unit tests above have not run yet.

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.

Each agent advertises its bounce arena's CU_MEM_HANDLE_TYPE_FABRIC
handle and address range in the bounce handshake (handshake format 2;
format 1 blobs still decode, without an export). With
agent_bounce_params push_gather (TRTLLM_NIXL_BOUNCE_PUSH_GATHER, off by
default) a sender maps the peer's arena when it loads the peer, and the
gather kernel writes each chunk straight into the region the receiver
granted, then sends DATA once the kernel has completed. There is no
local staging region and no NIXL write per chunk; the receiver side is
unchanged.

A chunk's gather starts once its GRANT arrives. Peers whose arena cannot
be mapped keep the staged path. A granted region outside the mapped
arena abandons the flow. In-flight chunks and orphaned gathers hold the
mapping, and a failed request whose push gather may still run defers its
cancel until the kernel is done.

Signed-off-by: Wanli Jiang <[email protected]>
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