Skip to content

[PyTorch] Add FusedAdam.update_param - #3825

Merged
pggPL merged 4 commits into
NVIDIA:mainfrom
CarlosGomes98:fix/reload-master-params
Dec 1, 2026
Merged

pggPL merged 4 commits into
NVIDIA:mainfrom
CarlosGomes98:fix/reload-master-params

Conversation

@CarlosGomes98

@CarlosGomes98 CarlosGomes98 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Add a method that replaces a parameter and its FP32 master weights without resetting Adam history, for use after loading model weights without optimizer state. It accepts full FP32 values when store_param_remainders is enabled, writing the BF16 high bits with the same rounding convention as AdamFunctorMasterParamRemainder, and supports quantized and DTensor parameters.

The method rejects tensors the optimizer does not own (e.g. param.data), DTensor masters whose mesh, placements or shape differ from the parameter and mismatched local shapes, all before mutating any state.

Description

Please include a brief summary of the changes, relevant motivation and context.

Fixes # (issue)

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

@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Nov 6, 2026

@timmoon10 timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall this is a good idea. The optimizer state for master weights can get weird and esoteric (especially the BF16 remainders trick) and it's not reasonable for users to interact with it directly. With some minor tweaks, this API is very straightforward.

Comment thread docs/api/pytorch.rst Resolved
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · Add the FP32 input check before merging so invalid reloads leave weights and optimizer state untouched.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches callers that choose to use FusedAdam's new parameter-update method.

Add the FP32 input check before merging so invalid reloads leave weights and optimizer state untouched.

Findings

  1. P1 Non-FP32 values overwrite weights ▶

Summary

Adds FusedAdam.update_param to reload model weights and master weights without resetting Adam history.

  • FusedAdam replaces parameter values while keeping its Adam history.

Reviews (4) · Last reviewed commit: "Debug doc generation" · Reviewed by Greptile

@cspades

cspades commented Nov 20, 2026

Copy link
Copy Markdown
Member

/te-ci L1 pytorch

Comment thread tests/pytorch/test_fused_optimizer.py Resolved

@timmoon10 timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, pending CI

@timmoon10

Copy link
Copy Markdown
Member

/te-ci pytorch L1

@timmoon10 timmoon10 changed the title [PyTorch] Add FusedAdam.reload_master_param [PyTorch] Add FusedAdam.update_param Dec 1, 2026
CarlosGomes98 and others added 4 commits December 1, 2026 09:49
Add a method that replaces a parameter and its FP32 master weights without
resetting Adam history, for use after loading model weights without
optimizer state. It accepts full FP32 values when store_param_remainders is
enabled, writing the BF16 high bits with the same rounding convention as
AdamFunctorMasterParamRemainder, and supports quantized and DTensor
parameters.

The method rejects tensors the optimizer does not own (e.g. param.data),
DTensor masters whose mesh, placements or shape differ from the parameter,
non-FP32 values and mismatched local shapes, all before mutating any state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Gomes <cgomes@nvidia.com>
Signed-off-by: Carlos Gomes <cgomes@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
Signed-off-by: Tim Moon <tmoon@nvidia.com>
@CarlosGomes98
CarlosGomes98 force-pushed the fix/reload-master-params branch from a509755 to 1963bc5 Compare December 1, 2026 08:49
@pggPL
pggPL merged commit d535a1b into NVIDIA:main Dec 1, 2026
15 checks passed
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.

4 participants