Skip to content
Open
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
9 changes: 8 additions & 1 deletion torchao/_models/llama/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,16 @@ def run_evaluation(
assert groupsize in [32, 64, 128, 256], (
f"int4wo groupsize needs to be one of [32,64,128,256] but got {groupsize}"
)
int4_packing_format = (
"plain_int32" if device == "xpu" else "tile_packed_to_4d"
)
quantize_(
model.to(device),
Int4WeightOnlyConfig(group_size=groupsize, use_hqq=use_hqq, version=1),
Int4WeightOnlyConfig(
group_size=groupsize,
use_hqq=use_hqq,
int4_packing_format=int4_packing_format,
),
)
if "uintx" in quantization:
# uintx-nbits-groupsize
Expand Down
9 changes: 8 additions & 1 deletion torchao/_models/llama/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,16 @@ def ffn_or_attn_only(mod, fqn):
], (
f"int4wo group_size needs to be one of [32,64,128,256] but got {group_size}"
)
int4_packing_format = (
"plain_int32" if device == "xpu" else "tile_packed_to_4d"
)
quantize_(
model,
Int4WeightOnlyConfig(group_size=group_size, use_hqq=use_hqq, version=1),
Int4WeightOnlyConfig(
group_size=group_size,
use_hqq=use_hqq,
int4_packing_format=int4_packing_format,
),
)
elif "int4dq-" in quantization:
from torchao.dtypes import CutlassInt4PackedLayout
Expand Down