Commit a746b27
committed
Honor adam_w_mode in the CPU multi_tensor_adam binding
The CPU fused_adam extension created its Adam_Optimizer once with
default arguments and ignored the mode parameter, so FusedAdam on the
CPU backend always applied decoupled (AdamW) weight decay even when
constructed with adam_w_mode=False. Keep one optimizer instance per
mode instead; everything else is already passed per call.
This surfaced as cpu-torch-latest failures in the fp32-adam case of
test_fused_adam_matches_torch. The test's bf16 cases are dropped:
torch.optim in bf16 does its math in bf16 while the fused kernels
compute in fp32, so it was never a valid bf16 reference. Low-precision
dtypes get an explicit fp32-math reference in the FusedAdam rework.
Signed-off-by: PKUWZP <zhipeng.rainbowserie@gmail.com>1 parent a1040cb commit a746b27
2 files changed
Lines changed: 13 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | | - | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
108 | | - | |
109 | | - | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
0 commit comments