Skip to content

Commit ce53d12

Browse files
committed
fix lint
Signed-off-by: yyt <yangyit139@gmail.com>
1 parent 07f99cb commit ce53d12

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

tests/ut/quantization/test_w8a16.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import unittest
21
from unittest.mock import MagicMock, patch
32

43
import torch
@@ -38,7 +37,8 @@ def test_apply_with_x_is_int8(self, mock_npu_weight_quant_batchmatmul):
3837
@patch('vllm_ascend.utils.get_ascend_device_type',
3938
return_value=AscendDeviceType._310P)
4039
@patch("torch_npu.npu_weight_quant_batchmatmul")
41-
def test_apply_with_x_is_310p(self, mock_npu_weight_quant_batchmatmul, mock_soc_version):
40+
def test_apply_with_x_is_310p(self, mock_npu_weight_quant_batchmatmul,
41+
mock_soc_version):
4242
layer = MagicMock()
4343
layer.weight.data = torch.randn(128, 256)
4444
layer.weight_scale.data = torch.randn(128, 1)
@@ -87,4 +87,4 @@ def test_process_weights_after_loading_nz(self, mock_npu_format_cast,
8787

8888
self.assertEqual(layer.weight_scale.data.shape, (128, ))
8989
self.assertEqual(layer.weight_offset.data.shape, (128, ))
90-
mock_npu_format_cast.assert_called_once()
90+
mock_npu_format_cast.assert_called_once()

vllm_ascend/quantization/w8a16.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
import torch
2121
import torch_npu
22-
from vllm_ascend.utils import ACL_FORMAT_FRACTAL_NZ, AscendDeviceType, get_ascend_device_type, is_enable_nz
22+
23+
from vllm_ascend.utils import (ACL_FORMAT_FRACTAL_NZ, AscendDeviceType,
24+
get_ascend_device_type, is_enable_nz)
2325

2426

2527
class AscendW8A16LinearMethod:
@@ -29,7 +31,8 @@ class AscendW8A16LinearMethod:
2931

3032
def __init__(self) -> None:
3133
# aclnn quant matmul requires to transpose matrix B, set to true by default.
32-
self.transpose_weight = get_ascend_device_type() != AscendDeviceType._310P
34+
self.transpose_weight = get_ascend_device_type(
35+
) != AscendDeviceType._310P
3336

3437
@staticmethod
3538
def get_weight(
@@ -82,16 +85,14 @@ def apply(
8285
weight=layer.weight.data.transpose(0, 1),
8386
antiquant_scale=layer.weight_scale,
8487
antiquant_offset=layer.weight_offset,
85-
bias=bias
86-
)
88+
bias=bias)
8789
else:
8890
output = torch_npu.npu_weight_quant_batchmatmul(
8991
x=x,
9092
weight=layer.weight,
9193
antiquant_scale=layer.weight_scale,
9294
antiquant_offset=layer.weight_offset,
93-
bias=bias
94-
)
95+
bias=bias)
9596
return output
9697

9798
def process_weights_after_loading(self, layer):

0 commit comments

Comments
 (0)