Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 3 additions & 19 deletions benchmarks/benchmark_aq.py
Copy link
Contributor Author

@namgyu-youn namgyu-youn Oct 2, 2025

Choose a reason for hiding this comment

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

How about inlining _int8wo_api, _int8da_int8w_api, _int4wo_api ? They are used only once across codebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I think that's fine if they're only used in benchmarks

Copy link
Contributor

Choose a reason for hiding this comment

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

also cc @jainapurva, can you take a look at the benchmark changes?

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
_replace_with_custom_fn_if_matches_filter,
quantize_,
)
from torchao.quantization.subclass import (
Int4WeightOnlyQuantizedLinearWeight,
Int8WeightOnlyQuantizedLinearWeight,
)


def _int8wo_api(mod, **kwargs):
Expand Down Expand Up @@ -117,14 +113,6 @@ def _ref_change_linear_weights_to_woqtensors(model, filter_fn=None, **kwargs):
return _ref_change_linear_weights_to_woqtensors


_ref_change_linear_weights_to_int8_woqtensors = (
_get_ref_change_linear_weights_to_woqtensors(Int8WeightOnlyQuantizedLinearWeight)
)
_ref_change_linear_weights_to_int4_woqtensors = (
_get_ref_change_linear_weights_to_woqtensors(Int4WeightOnlyQuantizedLinearWeight)
)


torch._dynamo.config.cache_size_limit = 50000


Expand Down Expand Up @@ -186,20 +174,16 @@ def _bench_quantized_tensor_subclass_perf(api, ref_api, M, N, K, kwargs=None):

for M, N, K in all_shapes:
_bench_quantized_tensor_subclass_perf(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporarily updated to use new APIs 2 times to fix CI, but maybe we can update _bench_quantized_tensor_subclass_perf to compare only original vs. new quantization flows?

_int8da_int8w_api, _ref_change_linear_weights_to_int8_dqtensors, M, N, K
_int8da_int8w_api, _int8da_int8w_api, M, N, K
)

print("_int8wo_api")

for M, N, K in all_shapes:
_bench_quantized_tensor_subclass_perf(
_int8wo_api, _ref_change_linear_weights_to_int8_woqtensors, M, N, K
)
_bench_quantized_tensor_subclass_perf(_int8wo_api, _int8wo_api, M, N, K)

print("_int4wo_api")
kwargs = {"groupsize": 32, "version": 1}

for M, N, K in all_shapes:
_bench_quantized_tensor_subclass_perf(
_int4wo_api, _ref_change_linear_weights_to_int4_woqtensors, M, N, K, kwargs
)
_bench_quantized_tensor_subclass_perf(_int4wo_api, _int4wo_api, M, N, K, kwargs)
Loading
Loading