Enable CPU Optimizer Support for bitsandbytes#1901
Open
jiqing-feng wants to merge 14 commits intobitsandbytes-foundation:mainfrom
Open
Enable CPU Optimizer Support for bitsandbytes#1901jiqing-feng wants to merge 14 commits intobitsandbytes-foundation:mainfrom
jiqing-feng wants to merge 14 commits intobitsandbytes-foundation:mainfrom
Conversation
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Contributor
Author
|
Hi @matthewdouglas |
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Contributor
Author
|
Hi @matthewdouglas . The failed tests seems like the CI node does not have avx512. Please rerun the CI to see if I fixed this issue. |
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.
Summary
This PR enables all bitsandbytes optimizers (32-bit and 8-bit blockwise) to run on CPU. Previously optimizers were restricted to CUDA/XPU only.
Motivation
Users on CPU-only machines had to fall back to vanilla PyTorch optimizers, losing the benefits of 8-bit state compression. This PR removes that limitation.
Changes
Python CPU Kernels (
bitsandbytes/backends/cpu/ops.py)_optimizer_update_32bit_cpu(Adam, AdEMAMix, LAMB/LARS, Lion, SGD, RMSprop)_optimizer_update_8bit_blockwise_cpuwith blockwise quantization/dequantizationOptimizer Framework (
bitsandbytes/optim/optimizer.py,bitsandbytes/functional.py)get_state_buffer: CPU uses regular tensors; paged optimizers fall back to non-paged with warningto_gpu: skips CPU parametersis_on_gpu: accepts all-CPU tensor sets, rejects mixed CPU/GPUNative C++ Kernels (
csrc/cpu_ops.cpp,csrc/cpu_ops.h,csrc/pythonInterface.cpp)quantize_cpu_bf16/quantize_cpu_fp16for direct half-precision quantizationTests (
tests/test_optim.py)no_cpu=Truefilters — all optimizer tests now run on CPUExample (
examples/cpu/cpu_training.py)JackFram/llama-68m+ Alpaca, supporting multiple optimizers,--comparemode, and HF Trainer integrationSupported Optimizers on CPU
How to Test
pytest tests/test_optim.py -x -v -k "cpu" python examples/cpu/cpu_training.py --optimizer adamw8bit --steps 20