29 lines
802 B
Diff
29 lines
802 B
Diff
--- a/torchtune/training/quantization.py
|
|
+++ b/torchtune/training/quantization.py
|
|
@@ -17,11 +17,20 @@ try:
|
|
except ImportError:
|
|
# torchao 0.6 and before
|
|
from torchao.dtypes import TensorCoreTiledLayoutType as TensorCoreTiledLayout
|
|
|
|
-from torchao.quantization import (
|
|
- int4_weight_only,
|
|
- int8_dynamic_activation_int4_weight,
|
|
- quantize_,
|
|
-)
|
|
+try:
|
|
+ from torchao.quantization import (
|
|
+ int4_weight_only,
|
|
+ int8_dynamic_activation_int4_weight,
|
|
+ quantize_,
|
|
+ )
|
|
+except ImportError:
|
|
+ # torchao 0.17+ renamed these. Not needed for Qwen3 QNN export path.
|
|
+ int4_weight_only = None
|
|
+ int8_dynamic_activation_int4_weight = None
|
|
+ try:
|
|
+ from torchao.quantization import quantize_
|
|
+ except ImportError:
|
|
+ quantize_ = None
|
|
|
|
try:
|