Skip to content

[PyTorch] Deprecate unused is_cg_capturable in parallel_cross_entropy - #3455

Merged
ptrendx merged 3 commits into
NVIDIA:mainfrom
pggPL:cross_entropy_deprecate_cg_flag
Sep 1, 2026
Merged

[PyTorch] Deprecate unused is_cg_capturable in parallel_cross_entropy#3455
ptrendx merged 3 commits into
NVIDIA:mainfrom
pggPL:cross_entropy_deprecate_cg_flag

Conversation

@pggPL

@pggPL pggPL commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Description

Since #3273 the fused cross entropy backward reconstructs the derivative from saved statistics and no longer contains the torch.equal-based synchronization point. The is_cg_capturable flag therefore has no effect — the operation is always CUDA graph capturable.

This PR marks the flag as deprecated on the public parallel_cross_entropy API (docstring note + FutureWarning when set) and removes the dead internal plumbing. The parameter is kept in the signature for backward compatibility, since Megatron-LM passes it explicitly.

Should also be mentioned as deprecated in the v2.19 release notes.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Deprecate is_cg_capturable in parallel_cross_entropy: docstring now states it is unused, and passing True emits a FutureWarning.
  • Remove the flag from CrossEntropyFunction, _parallel_cross_entropy_overwrite_input and the Triton cross_entropy_backward wrapper, where it was already a no-op.

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Since NVIDIA#3273 the cross entropy backward no longer contains a
synchronization point, so the operation is always CUDA graph capturable
and the flag has no effect. Keep accepting it on the public API for
backward compatibility (with a FutureWarning), drop the dead internal
plumbing.

Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
@pggPL

pggPL commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/te-ci pytorch L0

@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR retains the public is_cg_capturable parameter for compatibility while marking nondefault use as deprecated and removing its no-op internal plumbing.

  • Adds public API documentation and a FutureWarning when is_cg_capturable=True.
  • Removes the flag from the custom autograd function, overwrite helper, and Triton backward wrapper.
  • Keeps forward inputs, backward gradient slots, and internal call sites aligned.

Confidence Score: 5/5

The PR appears safe to merge because the public signature remains compatible and all affected internal call contracts remain aligned.

The retained public parameter emits the intended warning for its only nondefault value, while the internal autograd and Triton paths consistently remove the dead argument without leaving mismatched callers or gradient slots.

Important Files Changed

Filename Overview
transformer_engine/pytorch/cross_entropy.py Deprecates the public no-op flag while consistently removing it from internal calls and preserving custom-autograd arity.
transformer_engine/pytorch/triton/cross_entropy.py Removes an unused optional argument from an undocumented internal wrapper whose sole repository caller is updated in the same change.

Reviews (1): Last reviewed commit: "Drop removal promise from deprecation no..." | Re-trigger Greptile

@fheinecke fheinecke added the 2.19 label Sep 1, 2026
@fheinecke

Copy link
Copy Markdown
Collaborator

/te-ci pytorch L0

@ptrendx
ptrendx merged commit 918a61e into NVIDIA:main Sep 1, 2026
21 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants