From 256766040271b0d3b3a162f220dca0e3e3eb70d5 Mon Sep 17 00:00:00 2001 From: Dipika Date: Sun, 13 Oct 2024 17:01:18 +0000 Subject: [PATCH] fix test case --- .../quantization/lifecycle/forward.py | 11 ++++++++--- .../lifecycle/test_dynamic_lifecycle.py | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compressed_tensors/quantization/lifecycle/forward.py b/src/compressed_tensors/quantization/lifecycle/forward.py index b1ce8b07..30ae063a 100644 --- a/src/compressed_tensors/quantization/lifecycle/forward.py +++ b/src/compressed_tensors/quantization/lifecycle/forward.py @@ -22,7 +22,6 @@ calculate_range, compute_dynamic_scales_and_zp, ) -from compressed_tensors.quantization.lifecycle.initialize import initialize_observers from compressed_tensors.quantization.quant_args import ( QuantizationArgs, QuantizationStrategy, @@ -279,7 +278,10 @@ def wrapped_forward(self, *args, **kwargs): if scheme.input_activations is not None: # calibrate and (fake) quantize input activations when applicable # NOTE: will be moved out of compressed-tensors - if module.quantization_status == QuantizationStatus.CALIBRATION: + if ( + module.quantization_status == QuantizationStatus.CALIBRATION + and not scheme.input_activations.dynamic + ): calibrate_activations( module=module, value=input_, @@ -307,7 +309,10 @@ def wrapped_forward(self, *args, **kwargs): # wrap_module_forward_quantized_attn # NOTE: will be removed from compressed-tensors - if module.quantization_status == QuantizationStatus.CALIBRATION: + if ( + module.quantization_status == QuantizationStatus.CALIBRATION + and not scheme.output_activations.dynamic + ): calibrate_activations( module=module, value=output, diff --git a/tests/test_quantization/lifecycle/test_dynamic_lifecycle.py b/tests/test_quantization/lifecycle/test_dynamic_lifecycle.py index 45d49370..1f88626e 100644 --- a/tests/test_quantization/lifecycle/test_dynamic_lifecycle.py +++ b/tests/test_quantization/lifecycle/test_dynamic_lifecycle.py @@ -23,6 +23,7 @@ def test_apply_tinyllama_dynamic_activations(): + # NOTE: should not calibrate dynamic quant quant_config = get_sample_dynamic_tinyllama_quant_config() model = get_tinyllama_model()