Skip to content

Reject amsgrad in DeepSpeedCPUAdam instead of ignoring it - #8694

Merged
delock merged 1 commit into
deepspeedai:masterfrom
vineethsaivs:fix/cpu-adam-reject-amsgrad
Sep 29, 2026
Merged

delock merged 1 commit into
deepspeedai:masterfrom
vineethsaivs:fix/cpu-adam-reject-amsgrad

Conversation

@vineethsaivs

Copy link
Copy Markdown
Contributor

DeepSpeedCPUAdam(amsgrad=True) silently runs plain Adam. The CPU kernel has no AMSGrad path, so the flag is stored in the param group and never read. With "amsgrad": true in the optimizer config, FusedAdam raises, but turning on offload_optimizer swaps in CPU Adam and the run trains with a different algorithm and no warning.

Fix: reject amsgrad in add_param_group, the same way FusedAdam and FusedLamb do. That covers the constructor, the engine's config path, ZenFlow's subclass and groups added later. __del__ now skips the C++ destroy when construction failed, so the error isn't followed by an AttributeError.

Test: test_cpu_adam_rejects_amsgrad fails on master (DID NOT RAISE) and passes with the fix. tests/unit/ops/adam/ and the Muon partial-training tests pass: 158 passed, 14 skipped.

The CPU Adam kernel has no AMSGrad path, so amsgrad=True was stored in
the param group and then dropped: the optimizer ran plain Adam. FusedAdam
and FusedLamb already raise for this, so the same config failed on GPU but
silently changed the algorithm once optimizer offload was enabled.

Check amsgrad in add_param_group, which covers the constructor and groups
added later, and skip the C++ destroy in __del__ when construction failed.

Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
@delock
delock added this pull request to the merge queue Sep 29, 2026
Merged via the queue into deepspeedai:master with commit 53e336c Sep 29, 2026
14 of 18 checks passed
@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot added the skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants