Skip to content

Add the support of variable dtypes of params and grads in capturable Fused Adam. - #3414

Open
ptrendx wants to merge 2 commits into
NVIDIA:mainfrom
ptrendx:pr_fused_adam_variable_dtypes
Open

Add the support of variable dtypes of params and grads in capturable Fused Adam.#3414
ptrendx wants to merge 2 commits into
NVIDIA:mainfrom
ptrendx:pr_fused_adam_variable_dtypes

Conversation

@ptrendx

@ptrendx ptrendx commented Aug 21, 2026

Copy link
Copy Markdown
Member

Description

Added support for the types of parameters and gradients to differ in FusedAdam(capturable=True) to get it to parity with non-capturable mode.

Fixes #3358

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:

  • Change A
  • Change B

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

Fused Adam.

Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
@ptrendx

ptrendx commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

/te-ci

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR brings capturable FusedAdam to parity with its non-capturable mode by dispatching parameter and gradient element types independently.

  • Splits capturable Adam kernel templates into separate parameter and gradient types.
  • Validates parameter and gradient dtype homogeneity independently before launch.
  • Adds CUDA graph numerical coverage for FP32 parameters with BF16 gradients and BF16 parameters with FP32 gradients and master weights.
  • Corrects the capturable-master tensor-list diagnostic from four lists to five.

Confidence Score: 5/5

The PR appears safe to merge, with the mixed-dtype dispatch guarded by existing list validation and covered by capturable numerical tests.

The changed kernels consistently use independently dispatched parameter and gradient types, preserve the optimizer’s moment and master-weight contracts, and introduce no accepted correctness or security failure.

Important Files Changed

Filename Overview
transformer_engine/common/multi_tensor/adam.cu Independently dispatches parameter and gradient types in both capturable Adam kernels while retaining homogeneous-list validation and correct typed pointer arithmetic.
tests/pytorch/test_fused_optimizer.py Adds focused CUDA graph comparisons against non-capturable FusedAdam for both supported mixed parameter/gradient dtype directions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["FusedAdam capturable step"] --> B["Parameter-dtype bucket"]
  B --> C["Validate homogeneous parameter dtype"]
  B --> D["Validate homogeneous gradient dtype"]
  C --> E["Dispatch PARAM_T"]
  D --> F["Dispatch GRAD_T"]
  E --> G["Capturable Adam kernel"]
  F --> G
  G --> H["Update parameters and optimizer state"]
Loading

Reviews (1): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile

@vthumbe1503 vthumbe1503 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

FusedAdam(capturable=True) rejects FP32 parameters with BF16 grad_dtype

2 participants