Skip to content

Commit 9d2ee69

Browse files
Add typo checker (#846)
* Add typo checker Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4bb944f commit 9d2ee69

File tree

14 files changed

+48
-33
lines changed

14 files changed

+48
-33
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ repos:
5151
additional_dependencies:
5252
- tomli
5353

54+
- repo: https://github.com/crate-ci/typos
55+
rev: v1.36.2
56+
hooks:
57+
- id: typos
58+
5459
- repo: https://github.com/pycqa/isort
5560
rev: 6.0.1
5661
hooks:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AutoRound
66
<h3> Advanced Quantization Algorithm for LLMs</h3>
77

88
[![python](https://img.shields.io/badge/python-3.10%2B-blue)](https://github.com/intel/auto-round)
9-
[![version](https://img.shields.io/badge/release-0.7.0-green)](https://github.com/intel/auto-round)
9+
[![version](https://img.shields.io/badge/release-0.7.1-green)](https://github.com/intel/auto-round)
1010
[![license](https://img.shields.io/badge/license-Apache%202-9C27B0)](https://github.com/intel/auto-round/blob/main/LICENSE)
1111
<a href="https://huggingface.co/Intel">
1212
<img alt="Model Checkpoints" src="https://img.shields.io/badge/%F0%9F%A4%97%20HF-Models-F57C00">

auto_round/compressors/base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
set_module,
9595
to_device,
9696
to_dtype,
97-
unsupport_meta_device,
97+
unsupported_meta_device,
9898
)
9999
from auto_round.wrapper import WrapperLinear, WrapperMultiblock, unwrapper_block, unwrapper_layer, wrapper_block
100100

@@ -260,7 +260,7 @@ def __init__(
260260
elif tokenizer is None and iters > 0:
261261
raise ValueError("A tokenizer must be set for non-str model input")
262262
self.low_cpu_mem_usage = bool(low_cpu_mem_usage)
263-
if unsupport_meta_device(model):
263+
if unsupported_meta_device(model):
264264
raise RuntimeError(
265265
"AutoRound does not support parameters on meta device. "
266266
"Please use more GPUs by setting `--device 0,1,2,3` or just place the model on CPU."
@@ -345,7 +345,7 @@ def __init__(
345345
elif tokenizer is None and iters > 0:
346346
raise ValueError("A tokenizer must be set for non-str model input")
347347
self.low_cpu_mem_usage = bool(low_cpu_mem_usage)
348-
if unsupport_meta_device(model):
348+
if unsupported_meta_device(model):
349349
raise RuntimeError(
350350
"AutoRound does not support parameters on meta device. "
351351
"Please use more GPUs by setting `--device_map 0,1,2,3` or just place the model on CPU."
@@ -624,20 +624,20 @@ def _set_auto_device_map_in_block(self, block: torch.nn.Module, input_ids: list[
624624
device_0_memory = get_device_memory(
625625
self.device_list[0] if hasattr(self, "device_list") and self.device_list else 0
626626
)
627-
block_memory, input_ouput_memory = estimate_tuning_block_mem(block, input_ids)
627+
block_memory, input_output_memory = estimate_tuning_block_mem(block, input_ids)
628628
if self.low_gpu_mem_usage:
629-
input_ouput_memory = 0
629+
input_output_memory = 0
630630

631631
mem_per_param_scale = 13 if self.mem_per_param_scale is None else self.mem_per_param_scale
632632
if self.iters == 0:
633633
mem_per_param_scale = 1 # for rtn
634634

635-
if (block_memory * mem_per_param_scale + input_ouput_memory) < device_0_memory:
635+
if (block_memory * mem_per_param_scale + input_output_memory) < device_0_memory:
636636
return # fit in one GPU
637637

638638
device_map = {}
639639
device_memory = {device: get_device_memory(int(device.split(":")[1])) for device in cuda_devices}
640-
device_memory[device_0] = device_0_memory - input_ouput_memory
640+
device_memory[device_0] = device_0_memory - input_output_memory
641641

642642
device_idx = 0
643643
# First, fill device 0 to its maximum capacity, then distribute the remaining layers evenly across other devices
@@ -864,7 +864,7 @@ def remove_duplicates(lst):
864864
format = "auto_round:auto_awq"
865865
elif is_nv_fp(self.data_type) or is_mx_fp(self.data_type):
866866
format = f"auto_round:{self.data_type}"
867-
elif is_static_wfp8afp8(self): # staic wfp8afp8
867+
elif is_static_wfp8afp8(self): # static wfp8afp8
868868
format = f"auto_round:{AutoRoundFormat.FP8_STATIC.value}"
869869
elif self.data_type == "fp" and self.bits == 8 and self.act_bits >= 16: # woq fp8
870870
format = f"auto_round:{AutoRoundFormat.FP8.value}"

auto_round/export/export_to_gguf/convert_hf_to_gguf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7458,7 +7458,7 @@ def set_gguf_parameters(self):
74587458
layer_norm_eps = hparams["layer_norm_epsilon"]
74597459
intermediate_size = hparams["intermediate_size"] if "intermediate_size" in hparams else 4 * embed_dim
74607460
num_layers = hparams["num_layers"]
7461-
# ignore for now as EXAONE-3.0-7.8B-Instruct attentino_dropout is 0.0
7461+
# ignore for now as EXAONE-3.0-7.8B-Instruct attention_dropout is 0.0
74627462
# attention_dropout_rate = hparams["attention_dropout"]
74637463
# ignore for now as EXAONE-3.0-7.8B-Instruct embed_dropout is 0.0
74647464
# embed_dropout_rate = hparams["embed_dropout"]
@@ -7707,7 +7707,7 @@ def __init__(self, *args, **kwargs):
77077707
def get_attn_layers(self):
77087708
# Explicit list of layer type names
77097709
if layer_types := self.hparams.get("layer_types"):
7710-
return [i for i, typ in enumerate(layer_types) if typ == "attention"]
7710+
return [i for i, layer_type in enumerate(layer_types) if layer_type == "attention"]
77117711

77127712
# Layer types indicated by index or period
77137713
attn_layers = self.hparams.get("attn_layer_indices", [])

auto_round/export/export_to_gguf/packing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,11 @@ def q6_k_quant_block(blocks: np.array, scale=None, d_scale=None, original=False,
751751

752752
tmp_L = all_L.reshape(nb, 4, 64) & 0xF
753753
output_ql = (tmp_L[:, ::2] | (tmp_L[:, 1::2] << 4)).reshape(nb, QK_K // 2).cpu().numpy().astype(np.uint8)
754-
ouptut_qh = (all_L >> 4).reshape(nb, 2, 4, 32) << torch.tensor([0, 2, 4, 6], device=all_L.device).reshape(
754+
output_qh = (all_L >> 4).reshape(nb, 2, 4, 32) << torch.tensor([0, 2, 4, 6], device=all_L.device).reshape(
755755
1, 1, 4, 1
756756
)
757757
output_qh = (
758-
np.bitwise_or.reduce(ouptut_qh.cpu().numpy(), axis=2, dtype=np.uint8) # pylint: disable=E1121
758+
np.bitwise_or.reduce(output_qh.cpu().numpy(), axis=2, dtype=np.uint8) # pylint: disable=E1121
759759
.reshape(nb, QK_K // 4)
760760
.astype(np.uint8)
761761
) # pylint: disable=E1121

auto_round/inference/auto_quantizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ def post_init(self):
270270
raise ValueError("group_size must be greater than 0 or equal to -1")
271271

272272
def get_loading_attributes(self):
273-
loading_attibutes_dict = {"backend": self.backend}
274-
return loading_attibutes_dict
273+
loading_attributes_dict = {"backend": self.backend}
274+
return loading_attributes_dict
275275

276276
def to_dict(self):
277277
config_dict = super().to_dict()

auto_round/inference/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def find_backend(backend: str, orig_backend: str = None):
788788
target_info = BackendInfos[key]
789789
if (
790790
target_info.packing_format == orig_info.packing_format
791-
or orig_info.packing_format in target_info.convertable_format
791+
or orig_info.packing_format in target_info.convertible_format
792792
):
793793
return key
794794

auto_round/low_cpu_mem/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,16 +423,16 @@ def _layer_wise_to(module, name, device_or_dtype):
423423
module.get_bias = partial(_get_value, name, "bias")
424424
module.update = partial(_update, name, module)
425425

426-
def _repalce_to(module, name):
426+
def _replace_to(module, name):
427427
if len(module._modules) > 0:
428428
for n, m in module.named_children():
429429
if len(name) > 0:
430430
n = name + "." + n
431-
_repalce_to(m, n)
431+
_replace_to(m, n)
432432
module.ori_to = module.to
433433
module.to = partial(_layer_wise_to, module, name)
434434

435-
_repalce_to(empty_model, "")
435+
_replace_to(empty_model, "")
436436

437437

438438
def load_model_with_hooks(

auto_round/testing_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def is_itrex_available():
4747
return importlib.util.find_spec("intel_extension_for_transformers") is not None
4848

4949

50-
def is_flash_attn_avaliable():
50+
def is_flash_attn_available():
5151
return importlib.util.find_spec("flash_attn") is not None
5252

5353

@@ -203,7 +203,7 @@ def require_vlm_env(test_case):
203203

204204
env_check = True
205205
# pip install flash-attn --no-build-isolation
206-
env_check &= is_flash_attn_avaliable()
206+
env_check &= is_flash_attn_available()
207207

208208
# pip install git+https://github.com/haotian-liu/LLaVA.git@v1.2.2
209209
env_check &= importlib.util.find_spec("llava") is not None

auto_round/utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def get_scale_shape(weight, group_size):
220220
return shape
221221

222222

223-
def unsupport_meta_device(model):
223+
def unsupported_meta_device(model):
224224
"""Checks if the model is a valid model for auto_round.
225225
226226
Args:
@@ -810,8 +810,8 @@ def is_autoround_exllamav2_available():
810810
def get_library_version(library_name):
811811
from packaging.version import Version
812812

813-
python_vesion = Version(sys.version.split()[0])
814-
if python_vesion < Version("3.8"):
813+
python_version = Version(sys.version.split()[0])
814+
if python_version < Version("3.8"):
815815
import warnings
816816

817817
warnings.filterwarnings("ignore", category=DeprecationWarning)
@@ -1290,7 +1290,7 @@ def _gguf_args_check(args_or_ar, formats: list[str] = None, model_type=ModelType
12901290

12911291
pattern = re.compile(r"q\d_k")
12921292
pre_dq_format = ""
1293-
unsupport_list, reset_list = [], []
1293+
unsupported_list, reset_list = [], []
12941294
for format in GGUF_CONFIG:
12951295
if format in formats:
12961296
if format == "q6_k_s":
@@ -1303,7 +1303,7 @@ def _gguf_args_check(args_or_ar, formats: list[str] = None, model_type=ModelType
13031303
else:
13041304
pre_dq_format = format
13051305

1306-
unsupport_list, reset_list = [], []
1306+
unsupported_list, reset_list = [], []
13071307
gguf_config = GGUF_CONFIG[format]
13081308
for k, v in gguf_config.items():
13091309
if not hasattr(args_or_ar, k):
@@ -1315,12 +1315,12 @@ def _gguf_args_check(args_or_ar, formats: list[str] = None, model_type=ModelType
13151315
k = "asym"
13161316
v = not v
13171317
if getattr(args_or_ar, k) != v:
1318-
unsupport_list.append(f"{k}={getattr(args_or_ar, k)}")
1318+
unsupported_list.append(f"{k}={getattr(args_or_ar, k)}")
13191319
reset_list.append(f"{k}={v}")
13201320
setattr(args_or_ar, k, v)
1321-
if len(unsupport_list) > 0:
1321+
if len(unsupported_list) > 0:
13221322
logger.info(
1323-
f"format {format} does not support for {', '.join(unsupport_list)},"
1323+
f"format {format} does not support for {', '.join(unsupported_list)},"
13241324
f" reset to {', '.join(reset_list)}."
13251325
)
13261326
# Removed obsolete commented-out block for improved readability and maintainability.
@@ -2415,7 +2415,7 @@ def module_match_name_list(module, name_list):
24152415
elif module_match_name_list(module, ["DBRXMoeSparseMoeBlock"]):
24162416
return ["w1_linear", "w2_linear", "v1_linear"]
24172417
else:
2418-
# assuing w1, w2, w3 by default
2418+
# assuming w1, w2, w3 by default
24192419
return ["w1", "w2", "w3"]
24202420

24212421

0 commit comments

Comments
 (0)