Skip to content

Commit bcc60b8

Browse files
committed
Changed the conversion function name for better understanding
Signed-off-by: Hrishith Thadicherla <[email protected]>
1 parent 4d62165 commit bcc60b8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

modelopt/onnx/quantization/int4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
# supported and working
9999
CLIP_MIN = 1e-5
100100

101-
def convert_ml_dtypes_int4_to_int8_format(tensor):
101+
def safe_cupy_array(tensor):
102102
"""
103103
Convert ml_dtypes.int4 tensor to numpy.int8 for CuPy compatibility.
104104

tests/gpu/onnx/test_quantize_onnx_torch_int4_awq.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ def _forward_loop(model, dataloader):
9494
scale_awq_lite = find_init(onnx_model_awq_lite, scale_names[i])
9595

9696
if int4.has_cupy:
97-
wq_onnx_awq_lite = int4.convert_ml_dtypes_int4_to_int8_format(wq_onnx_awq_lite)
98-
scale_awq_lite = int4.convert_ml_dtypes_int4_to_int8_format(scale_awq_lite)
97+
wq_onnx_awq_lite = int4.safe_cupy_array(wq_onnx_awq_lite)
98+
scale_awq_lite = int4.safe_cupy_array(scale_awq_lite)
9999

100100
wq_onnx_awq_lite = dq_tensor(wq_onnx_awq_lite, scale_awq_lite, block_size)
101101
wq_torch_awq_clip = model_torch_copy.net[i * 2].weight_quantizer(
102102
model_torch_copy.net[i * 2].weight
103103
)
104104
wq_onnx_awq_clip = find_init(onnx_model_awq_clip, wq_names[i])
105105
scale_awq_clip = find_init(onnx_model_awq_clip, scale_names[i])
106-
106+
107107
if int4.has_cupy:
108-
wq_onnx_awq_clip = int4.convert_ml_dtypes_int4_to_int8_format(wq_onnx_awq_clip)
109-
scale_awq_clip = int4.convert_ml_dtypes_int4_to_int8_format(scale_awq_clip)
108+
wq_onnx_awq_clip = int4.safe_cupy_array(wq_onnx_awq_clip)
109+
scale_awq_clip = int4.safe_cupy_array(scale_awq_clip)
110110

111111
wq_onnx_awq_clip = dq_tensor(wq_onnx_awq_clip, scale_awq_clip, block_size)
112112

0 commit comments

Comments
 (0)