Skip to content

Avoid redundant CUDA graph RNG registration - #3836

Draft
LiRunGuo wants to merge 3 commits into
NVIDIA:mainfrom
LiRunGuo:fix/graph-rng-registration-capability-r2
Draft

LiRunGuo wants to merge 3 commits into
NVIDIA:mainfrom
LiRunGuo:fix/graph-rng-registration-capability-r2

Conversation

@LiRunGuo

@LiRunGuo LiRunGuo commented Nov 8, 2026 •

Copy link
Copy Markdown

Description

Fixes #3645.

PyTorch builds that auto-register CUDA graph RNG state expose
CUDAGraph.register_generator_state() as a deprecated no-op. Transformer
Engine currently treats method availability as proof that explicit
registration is required, so every forward, backward, and wgrad graph emits
warnings. Pipeline-parallel training multiplies that warning volume across
layers and microbatches, and the resulting stderr traffic can delay graph
capture enough to trip a distributed watchdog.

This change probes the installed implementation once per process by capturing a
tiny random operation and checking whether replay advances the default CUDA
generator without explicit registration. Builds that auto-register RNG state
advance across replays and skip the per-graph registration loop. Builds that
still require explicit registration, including the NGC 26.09 case noted in the
issue, retain the existing behavior. The probe restores the original generator
state. A unit test covers both branches.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes

  • Cache a capability result that distinguishes required graph RNG registration
    from PyTorch's deprecated no-op implementation.
  • Preserve the explicit registration path for older or vendor-patched PyTorch
    builds that still need it.
  • Add coverage for both API behaviors.

Validation

Validated on an NVIDIA RTX A6000 with PyTorch 2.14.1+cu130 and CUDA 13.0.

The affected PyTorch build emitted the expected C++ deprecation warning outside
Python's warning machinery:

Warning: CUDAGraph.register_generator_state() is deprecated, and will be
removed in a future PyTorch release. It is now a no-op and can be safely
removed from your code.

The behavioral probe correctly inferred that explicit registration is
unnecessary. RNG advanced across graph replays, and backward remained finite:

explicit_registration_required False
cached_result_matches True
dropout_replays_differ True
backward_grad_finite True
PASS

The focused capability test passed both legacy and auto-registration cases:

2 passed, 25 warnings in 4.87s

qa/L0_license/test.sh and the changed-file pre-commit checks also pass.

This draft was prepared with AI assistance. The human author must review the
complete diff and validation results before marking it ready for maintainer
review.

Probe the installed PyTorch CUDAGraph registration API once and skip explicit per-graph registration only when it reports that registration is deprecated and is now a no-op. Preserve the existing path on builds that still require registration.

Signed-off-by: RunguoLi <li19107254665@gmail.com>
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Nov 8, 2026
Signed-off-by: RunguoLi <li19107254665@gmail.com>
Signed-off-by: RunguoLi <li19107254665@gmail.com>

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

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PyTorch] CUDA graph RNG registration floods training logs on automatic-registration builds

1 participant