Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observer Restructure: Remove Observers, calibration, and applying frozen steps from lifecycle #189

Merged
merged 28 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/compressed_tensors/quantization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
from .quant_config import *
from .quant_scheme import *
from .lifecycle import *
from .cache import QuantizedKVParameterCache
200 changes: 0 additions & 200 deletions src/compressed_tensors/quantization/cache.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/compressed_tensors/quantization/lifecycle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
# flake8: noqa
# isort: skip_file

from .calibration import *
from .forward import *
from .frozen import *
from .initialize import *
from .compressed import *
from .apply import *
Expand Down
17 changes: 1 addition & 16 deletions src/compressed_tensors/quantization/lifecycle/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@

import torch
from compressed_tensors.config import CompressionFormat
from compressed_tensors.quantization.lifecycle.calibration import (
set_module_for_calibration,
)
from compressed_tensors.quantization.lifecycle.compressed import (
compress_quantized_weights,
)
from compressed_tensors.quantization.lifecycle.frozen import freeze_module_quantization
from compressed_tensors.quantization.lifecycle.initialize import (
initialize_module_for_quantization,
)
Expand Down Expand Up @@ -233,6 +229,7 @@ def apply_quantization_status(model: Module, status: QuantizationStatus):
:param model: model to apply quantization to
:param status: status to update the module to
"""

current_status = infer_quantization_status(model)

if status >= QuantizationStatus.INITIALIZED > current_status:
Expand All @@ -243,18 +240,6 @@ def apply_quantization_status(model: Module, status: QuantizationStatus):
)
)

if current_status < status >= QuantizationStatus.CALIBRATION > current_status:
# only quantize weights up front when our end goal state is calibration,
# weight quantization parameters are already loaded for frozen/compressed
quantize_weights_upfront = status == QuantizationStatus.CALIBRATION
model.apply(
lambda module: set_module_for_calibration(
module, quantize_weights_upfront=quantize_weights_upfront
)
)
if current_status < status >= QuantizationStatus.FROZEN > current_status:
model.apply(freeze_module_quantization)

if current_status < status >= QuantizationStatus.COMPRESSED > current_status:
model.apply(compress_quantized_weights)

Expand Down
80 changes: 0 additions & 80 deletions src/compressed_tensors/quantization/lifecycle/calibration.py

This file was deleted.

Loading
Loading