Repository navigation
[quantization] quantize on the fly through a "quantize" load operation - #50240
ArthurZucker wants to merge 34 commits into
Conversation
|
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. Pages changed in this PR: |
IlyasMoutawwakil
left a comment
There was a problem hiding this comment.
thanks ! much cleaner ! i'm not very knowledgeable about most of these quantizers specifics but tests should catch if anything is not right.
i have two questions one about making dequantization not require kernels (i later saw many quantizers also use third party functions so maybe we can give up on that 🥲). and one about the dropped tests.
on a side note, now that everything passes by conversion ops, should we also make it clear what gets reversed and what not during saving, mostly to protect reloading and for users to know what to expect. for me it's smth like:
- quantize/dequantize: never reversed because the user already has the original on disk, if they do on-the-fly quant/dequant, it's generally bcz they want that to be saved.
- serialize/deserialize: should be reversed (swizzle, etc) bcz otherwise they will be applied a second time at reload.
- model weight conversions: should probably be reversed ? (renames, packed experts, etc) following the bf16 path.
| ## Dequantizing bitsandbytes models | ||
|
|
||
| Once quantized, you can [`~PreTrainedModel.dequantize`] a model to the original precision but this may result in some quality loss. Make sure you have enough GPU memory to fit the dequantized model. | ||
| Pass `dequantize=True` to load a pre-quantized bitsandbytes checkpoint back in its original precision. This may result in some quality loss, and requires enough memory to fit the dense model. |
There was a problem hiding this comment.
did we ever confirm this ? that dequantization can result in quality loss
| from .hub_kernels import get_kernel | ||
|
|
||
| self.hf_quantizer = hf_quantizer | ||
| self.kernel = get_kernel("kernels-community/quantization-eetq", version=1) |
There was a problem hiding this comment.
dequantization shouldn't require a kernel (per @SunMarc suggestion), because a user might specifically want to dequantize because they don't have the right hardware for the kernels.
There was a problem hiding this comment.
yes let's add the torch ops as a fallback if possible.
…on: pin its output
…ad op, uncompressed checkpoints no longer force it
… the checkpoint format; drop no-op after-load hook
…hts load decompressed, compressed-tensors only sets up activation / kv cache quantization
Replaces WeightTransform.quantization_operation: the op is appended last to each param's converter.
…n, model.dequantize() too
…converters of modules keeping their packed tensors
…emm keeps input_scale_ub through loading
…buffer kept; serialize visits every module; gptq/awq/auto_round/quark dequantize moved to a follow-up
…vfp4 loads pre-quantized checkpoints with dequantize=True
…ers removed, shorter suffix handling
…ix and name boundaries to #50245
a3a741f to
4f11091
Compare
…t, and saves it back
…nd saves it back; dequantize=True is plain dense
…h; bnb docs: dequantize keeps the quantized values
…kip kernel checks when dequantizing; eetq says why it can't
…-load' into quantize-load-operation
|
[For maintainers] Suggested jobs to run (before merge) run-slow: bitnet_integration, bnb, compressed_tensors_integration, fbgemm_fp8, finegrained_fp8, higgs, hqq, metal, mxfp4, nvfp4, sinq |
# Conflicts: # src/transformers/quantizers/quantizer_eetq.py
… set per param by the plan; no quantization code left in core
|
Merged into #50245: |
…(reverts the #50240 merge here)
Replaces
WeightTransform.quantization_operationwith a"quantize"entry inget_load_operations, as asked in the #50238 review.