Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1430
Summary
Adds 8-bit and 32-bit Cautious AdamW optimizers (
CAdamW,CAdamW8bit, andCAdamW32bit) tobitsandbytes.optim, implementing the C-AdamW algorithm from "Cautious Optimizers: Improving Training with One Line of Code" (Liang et al., 2024; https://github.com/kyleliang919/C-Optim).Details
mask = (exp_avg * grad > 0).to(float32)rescaled by1 / clamp(mean(mask), min=1e-3)to the AdamW update step.exp_avgwith signeddynamicmap,exp_avg_sqwith unsignedudynamicmap) inuint8viaF.quantize_blockwise/F.dequantize_blockwisewhenoptim_bits == 8andp.numel() >= min_8bit_size, falling back tofloat32for smaller tensors oroptim_bits == 32.Optimizer8bitsostate_dict()/load_state_dict()wrap quantization tensors under__bnb_optimizer_quant_state__.Testing
Ran
PYTHONPATH=. pytest tests/test_c_adamw.py -von CPU:uint8/absmaxstate verification,state_dict()round-trip, and argument validation).