Skip to content

Implement _dequantize for TorchAO quantizer#13538

Open
jiqing-feng wants to merge 3 commits intohuggingface:mainfrom
jiqing-feng:torchao-dequantize
Open

Implement _dequantize for TorchAO quantizer#13538
jiqing-feng wants to merge 3 commits intohuggingface:mainfrom
jiqing-feng:torchao-dequantize

Conversation

@jiqing-feng
Copy link
Copy Markdown
Contributor

What does this PR do?

Implements the _dequantize() method for TorchAoHfQuantizer, enabling model.dequantize() to convert TorchAO-quantized models back to standard float weights.

Changes

  1. Add _dequantize() method: Iterates all nn.Linear modules, calls weight.dequantize() on TorchAOBaseTensor weights, replaces them with standard nn.Parameter, and resets any overridden extra_repr.

  2. Fix _verify_if_layer_quantized: Added isinstance(module.weight, TorchAOBaseTensor) check so that dequantized layers (which are still nn.Linear but with plain tensor weights) are correctly detected as non-quantized.

- Add _dequantize() method in TorchAoHfQuantizer that dequantizes
  TorchAOBaseTensor weights back to standard nn.Parameter
- Fix _verify_if_layer_quantized to check isinstance(weight, TorchAOBaseTensor)
  so dequantized layers are correctly detected as non-quantized
@github-actions github-actions Bot added size/S PR with diff < 50 LOC and removed size/S PR with diff < 50 LOC labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

quantization size/S PR with diff < 50 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant