Commit f2233a6
fix(optim): honor user-provided max_unorm in LAMB (+ 8-bit arg guards) (#1998)
* fix(optim): honor user-provided max_unorm in LAMB (+ 8-bit arg guards)
The LAMB, LAMB8bit and LAMB32bit constructors accepted a max_unorm
argument but passed a hardcoded 1.0 to the base optimizer, so the user
value never reached the optimizer config. On the 32-bit LAMB path
(LAMB with the default optim_bits=32, and LAMB32bit) max_unorm drives
the trust-ratio clipping of the update, so this silently ignored the
setting -- e.g. a tighter max_unorm had no effect and max_unorm could
not be changed from 1.0. Thread the argument through in all three
classes.
Note: the 8-bit blockwise update kernel does not apply update-norm
clipping, so max_unorm has no numerical effect on LAMB8bit; the value
is now stored consistently and this limitation is documented in the
docstring.
Also complete the 8-bit optimizer signature/doc cleanup started for
Adam8bit/AdamW8bit (relates to #1261), mirroring their guards on
parameters the base optimizer ignores:
- LAMB8bit: raise on amsgrad=True (unused) and note it in the docstring.
- Adagrad8bit: raise on optim_bits != 8 (always 8-bit) and note it.
Tests (tests/test_optim.py):
- test_lamb_max_unorm_changes_update: behavioral check on the 32-bit
path -- a tight vs loose max_unorm now yields different updates
(fails on main where the value was ignored).
- test_lamb_max_unorm_threaded_to_config: the value reaches
optimizer.args for all three LAMB classes.
- guards for LAMB8bit amsgrad and Adagrad8bit optim_bits.
Relates to #1261
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Reject non-default max_unorm in LAMB8bit (review feedback)
The 8-bit blockwise update does not implement update-norm clipping, so
threading max_unorm through LAMB8bit left a silent no-op: a user passing
e.g. max_unorm=0.1 would reasonably assume it takes effect. Reject any
non-default value instead, consistent with the amsgrad guard (the
default 1.0 is allowed for signature compatibility).
Config-threading test now covers the 32-bit classes only; add a guard
test for LAMB8bit max_unorm.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent a229e65 commit f2233a6
3 files changed
Lines changed: 83 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
113 | 118 | | |
114 | 119 | | |
115 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
109 | 123 | | |
110 | 124 | | |
111 | 125 | | |
| |||
116 | 130 | | |
117 | 131 | | |
118 | 132 | | |
119 | | - | |
| 133 | + | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
| |||
172 | 186 | | |
173 | 187 | | |
174 | 188 | | |
175 | | - | |
| 189 | + | |
176 | 190 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
0 commit comments