Skip to content

Generalize persistent buffers for GTP local CUDA graphs - #6713

Open
JF-D wants to merge 1 commit into
NVIDIA:mainfrom
JF-D:jiangfeid/cg_persistent_buffer_fix
Open

JF-D wants to merge 1 commit into
NVIDIA:mainfrom
JF-D:jiangfeid/cg_persistent_buffer_fix

Conversation

@JF-D

@JF-D JF-D commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What does this PR do?

Generalizes fixed-address persistent storage for GTP backward operations captured by local CUDA graphs. It also enables NCCL symmetric-memory one-shot reduce-scatter for GTP + local CUDA graphs.

Problem

Local CUDA graph replay requires every graph-owned communication buffer to retain a stable address. The existing specialized wgrad-ring mechanism has several limitations:

  • it only manages padded wgrad reduce-scatter inputs;
  • it requires an explicitly configured ring size;
  • it does not cover asynchronous reduce-scatter outputs or FP32-accumulation scratch;
  • it cannot naturally allocate graph-owned wgrad inputs from the exact registered symmetric-memory domain required by dense GTP or expert GTP one-shot reduce-scatter;
  • repeated parameter usage, including MTP, can require multiple distinct buffers within one graph.

Consequently, adding another graph-owned GTP tensor requires another specialized lifetime mechanism, while symmetric one-shot RS cannot safely reuse ordinary graph storage.

Solution

This PR replaces the specialized wgrad ring with an automatically sized persistent-buffer plan:

  1. Eager backward discovers each CUDA graph runner’s aligned storage requirements, grouped by allocation domain and dtype.
  2. Before capture, the plan allocates a bounded number of alternating fixed-address arenas outside the CUDA graph memory pool.
  3. Capture bump-allocates stable tensor views from the runner’s assigned arena.
  4. Replay-time CUDA events prevent an arena generation from being reused while earlier graph work is still in flight.
  5. Capture validates that it consumes exactly the capacity discovered during eager execution.

Symmetric reduce-scatter inputs are allocated from the registered memory pool for their exact GTP or expert-GTP process group. Dense and expert GTP therefore cannot alias storage registered for a different communicator, allowing NCCL one-shot RS to work with local CUDA graphs.

Persistent storage coverage

The plan now manages:

  • padded wgrad reduce-scatter inputs;
  • graph-owned asynchronous reduce-scatter outputs;
  • FP32 reduce-scatter all-to-all scratch;
  • FP32 accumulation output scratch;
  • repeated GTP parameter usage, including MTP.

Ungraphed execution continues to use the existing eager buffer pools and cache paths.

The centralized discovery, allocation, and replay-fencing API can also support additional graph-owned GTP storage in the future. This PR does not add CUDA graph offloading support.

Contribution process

Pre-checks

  • I have added relevant unit tests
  • I have added relevant functional tests
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Convergence

1/4 Nemotron-4 Proxy, 8 nodes, blue: eager, red: partialcg, no mtp.
Screenshot 2026-08-24 at 4 02 18 PM

@JF-D
JF-D requested review from a team as code owners August 20, 2026 17:40
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically converted to draft because all PRs must start as drafts.

When you are ready for review, click Ready for Review to begin the review process. This will:

  1. Add the oncall reviewer (optional reviewer)
  2. Add required review teams based on your changes

See the contribution guide for more details.

@svcnvidia-nemo-ci
svcnvidia-nemo-ci marked this pull request as draft August 20, 2026 17:40
@copy-pr-bot

copy-pr-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@JF-D
JF-D marked this pull request as ready for review August 20, 2026 17:41
@JF-D JF-D self-assigned this Aug 20, 2026
@JF-D JF-D linked an issue Aug 20, 2026 that may be closed by this pull request
@JF-D
JF-D force-pushed the jiangfeid/cg_persistent_buffer_fix branch from 6e2a660 to d07354c Compare August 24, 2026 18:37
@JF-D
JF-D requested a review from a team as a code owner August 24, 2026 18:37
@JF-D
JF-D requested a review from a team August 24, 2026 18:37
@JF-D

JF-D commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

/claude strict-review

@JF-D

JF-D commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@claude strict-review

@JF-D JF-D added the nemotron label Aug 24, 2026
@JF-D JF-D changed the title [refactor] Generalize persistent buffers for GTP local CUDA graphs Generalize persistent buffers for GTP local CUDA graphs Aug 24, 2026
@JF-D

JF-D commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

Signed-off-by: Jiangfei Duan <jiangfeid@nvidia.com>
@JF-D
JF-D force-pushed the jiangfeid/cg_persistent_buffer_fix branch from d07354c to cc5af1f Compare August 24, 2026 22:55
@fanshiqing

Copy link
Copy Markdown
Member

/claude strict-review

@JF-D

JF-D commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

This PR will be split into 3 PRs. Two split PRs before this one: #6862, #6867. This PR is a stack version and will be updated to support oneshotRS after previous PRs are merged.

This branch was previously deployed

2 inactive deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] GTP+CG

2 participants