Commit 45813c3
Fix Lion to use decoupled weight decay in the Triton 32-bit kernel
Follow-up to bitsandbytes-foundation#1993, which fixed the same coupled-vs-decoupled weight-decay bug
for Lion in the default backend and the CUDA 32-bit kernel. matthewdouglas
invited a Triton follow-up when approving bitsandbytes-foundation#1993.
_optimizer_update_1state_32bit_triton_kernel folded weight decay into the
gradient (coupled L2) for every 1-state optimizer, Lion included. Lion requires
*decoupled* (AdamW-style) decay applied to the param directly (p *= 1 - lr*wd),
outside the sign update (Chen et al. 2023); folding decay into the gradient
corrupts the input to sign(), changing the update direction, not just its
magnitude. This mirrors the CUDA 32-bit fix exactly: exclude LION (id 4) from
the gradient fold, and shrink the param in the LION branch before the sign
update.
The existing test_lion32bit_weight_decay (added in bitsandbytes-foundation#1993) is parametrized over
get_available_devices(), so it already exercises this kernel on XPU hardware in
CI. Like bitsandbytes-foundation#1993's CUDA change, the Triton kernel is XPU-only and cannot be built
or run on the available hardware.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 5e7ff4e commit 45813c3
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
274 | 278 | | |
275 | 279 | | |
276 | 280 | | |
| |||
289 | 293 | | |
290 | 294 | | |
291 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
292 | 302 | | |
293 | 303 | | |
294 | 304 | | |
| |||
0 commit comments