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

Depreciate get_observer #214

Merged
merged 3 commits into from
Jan 29, 2025
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
11 changes: 5 additions & 6 deletions src/compressed_tensors/quantization/quant_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import torch
from compressed_tensors.utils import Aliasable
from compressed_tensors.utils.helpers import deprecated
from pydantic import BaseModel, Field, field_validator, model_validator


Expand Down Expand Up @@ -123,12 +124,6 @@ class QuantizationArgs(BaseModel, use_enum_values=True):
),
)

def get_observer(self):
"""
:return: torch quantization FakeQuantize built based on these QuantizationArgs
"""
return self.observer

@field_validator("type", mode="before")
def validate_type(cls, value) -> QuantizationType:
if isinstance(value, str):
Expand Down Expand Up @@ -250,6 +245,10 @@ def pytorch_dtype(self) -> torch.dtype:
else:
raise ValueError(f"Invalid quantization type {self.type}")

@deprecated("QuantizationArgs.observer")
def get_observer(self) -> str:
return self.observer

Comment on lines +248 to +251
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to move the location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated definitions should be moved to the bottom, as they're less relevant for a reader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same logic behind private functions being towards the bottom


def round_to_quantized_type(
tensor: torch.Tensor, args: QuantizationArgs
Expand Down
4 changes: 2 additions & 2 deletions src/compressed_tensors/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def deprecated(future_name: Optional[str] = None, message: Optional[str] = None)
"""
Decorator to mark functions as deprecated

:param new_function: Function called in place of depreciated function
:param message: Depreciation message, replaces default depreciation message
:param new_function: Function called in place of deprecated function
:param message: Deprecation message, replaces default deprecation message
"""

def decorator(func: Callable[[Any], Any]):
Expand Down