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

Clean up observer defaulting logic, better error message #200

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 5 additions & 11 deletions src/compressed_tensors/quantization/quant_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ def get_observer(self):
"""
:return: torch quantization FakeQuantize built based on these QuantizationArgs
"""

# No observer required for the dynamic case
if self.dynamic:
self.observer = None
return self.observer

return self.observer

@field_validator("type", mode="before")
Expand Down Expand Up @@ -217,15 +211,15 @@ def validate_model_after(model: "QuantizationArgs") -> Dict[str, Any]:
warnings.warn(
"No observer is used for dynamic quantization, setting to None"
)
model.observer = None
observer = None

# if we have not set an observer and we
# are running static quantization, use minmax
if not observer and not dynamic:
model.observer = "minmax"
elif observer is None:
# default to minmax for non-dynamic cases
observer = "minmax"

# write back modified values
model.strategy = strategy
model.observer = observer
return model

def pytorch_dtype(self) -> torch.dtype:
Expand Down
2 changes: 1 addition & 1 deletion src/compressed_tensors/registry/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def get_from_registry(
retrieved_value = _import_and_get_value_from_module(module_path, value_name)
else:
# look up name in alias registry
name = _ALIAS_REGISTRY[parent_class].get(name)
name = _ALIAS_REGISTRY[parent_class].get(name, name)
# look up name in registry
retrieved_value = _REGISTRY[parent_class].get(name)
if retrieved_value is None:
Expand Down
Loading