Skip to content

[AWQ] Allow for activation quantization #1682

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
32 changes: 14 additions & 18 deletions src/llmcompressor/modifiers/awq/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import warnings
from typing import Dict, List, Optional, Tuple, Union

import torch
Expand Down Expand Up @@ -183,25 +184,20 @@ def validate_model_after(model: "AWQModifier") -> "AWQModifier":

model._group_size = next(iter(group_size_set))

in_num_bits_set = set(
group.input_activations.num_bits
num_bits_set = {
act.num_bits
for group in config.config_groups.values()
if group.input_activations is not None
)
assert len(in_num_bits_set) == 0 or in_num_bits_set == {16}, (
"AWQ activations must be 16-bit precision, "
f"input activations {in_num_bits_set} not allowed"
)

out_num_bits_set = set(
group.output_activations.num_bits
for group in config.config_groups.values()
if group.output_activations is not None
)
assert len(out_num_bits_set) == 0 or out_num_bits_set == {16}, (
"AWQ activations must be 16-bit precision, "
f"output activations {out_num_bits_set} not allowed"
)
for act in (group.input_activations, group.output_activations)
if act is not None
}
if not (len(num_bits_set) == 0 or num_bits_set == {16}):
warnings.warn(
"A strategy including activation quantization was detected. "
"AWQ was originally intended for weight-only quantization. "
"Lower-precision activations are an experimental feature, and "
"overall performance may be poor. If it is, consider using "
"`W4A16` or `W4A16_ASYM` quantization schemes instead."
)

return model

Expand Down
3 changes: 0 additions & 3 deletions tests/llmcompressor/modifiers/awq/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ def test_set_resolved_mappings():

@pytest.mark.unit
def test_validate():
with pytest.raises(ValidationError):
AWQModifier(scheme="W8A8")

with pytest.raises(ValidationError):
AWQModifier(
config_groups={
Expand Down