Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

[pre-commit.ci] pre-commit autoupdate (#1661)

pre-commit-ci[bot]e4f94931407e
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 174e75b0f..0d16fb6c5 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,7 +13,7 @@ repos:
args: [--fix=lf]
- repo: https://github.com/Lucas-C/pre-commit-hooks
- rev: v1.5.5
+ rev: v1.5.6
hooks:
- id: insert-license
files: |
@@ -30,7 +30,7 @@ repos:
]
- repo: https://github.com/psf/black-pre-commit-mirror
- rev: 25.12.0
+ rev: 26.3.1
hooks:
- id: black
files: (.*\.py)$
@@ -46,10 +46,10 @@ repos:
- id: blacken-docs
args: [--line-length=120, --skip-errors]
additional_dependencies:
- - black==25.9.0
+ - black==26.3.1
- repo: https://github.com/codespell-project/codespell
- rev: v2.4.1
+ rev: v2.4.2
hooks:
- id: codespell
args: [-w]
@@ -57,17 +57,17 @@ repos:
- tomli
- repo: https://github.com/crate-ci/typos
- rev: v1
+ rev: v1.45.0
hooks:
- id: typos
- repo: https://github.com/pycqa/isort
- rev: 7.0.0
+ rev: 8.0.1
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.14.10
+ rev: v0.15.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
diff --git a/auto_round/compressors/base.py b/auto_round/compressors/base.py
index 7838c5769..a8735407e 100644
--- a/auto_round/compressors/base.py
+++ b/auto_round/compressors/base.py
@@ -1420,7 +1420,7 @@ class BaseCompressor(object):
if use_blockwise_quantization: # The ram usage is a little higher
all_to_quantized_module_names = list(dict.fromkeys(all_to_quantized_module_names))
- all_blocks = self.quant_block_list if self.quant_block_list else get_block_names(self.model)
+ all_blocks = self.quant_block_list or get_block_names(self.model)
pbar = tqdm(range(sum(len(block) for block in all_blocks)))
for block_names in all_blocks:
for block_name in block_names:
@@ -1513,7 +1513,7 @@ class BaseCompressor(object):
"""
all_to_quantized_module_names = list(set(all_to_quantized_module_names))
- all_blocks = self.quant_block_list if self.quant_block_list else get_block_names(self.model)
+ all_blocks = self.quant_block_list or get_block_names(self.model)
if not all_blocks:
raise ValueError("Could not find any blocks. Check the model or quant_block_list.")
diff --git a/auto_round/compressors/mllm/processor.py b/auto_round/compressors/mllm/processor.py
index 1063beed4..b42962cbb 100644
--- a/auto_round/compressors/mllm/processor.py
+++ b/auto_round/compressors/mllm/processor.py
@@ -27,6 +27,7 @@ Support Matrix
✔ means support, - means support but cannot infer or not test infert yet, X means not support.
"""
+
import os
from datetime import datetime, timedelta
diff --git a/auto_round/eval/eval_cli.py b/auto_round/eval/eval_cli.py
index d8435c490..76811ec3f 100644
--- a/auto_round/eval/eval_cli.py
+++ b/auto_round/eval/eval_cli.py
@@ -502,7 +502,7 @@ def _evaluate_tasks_with_retry(tasks, hflm, device_str, batch_size, limit, retry
except Exception as e:
cuda_error_msg = traceback.format_exc()
try:
- ori_batch_sizes = hflm.batch_sizes if hflm.batch_sizes else {"0": 64}
+ ori_batch_sizes = hflm.batch_sizes or {"0": 64}
if not hflm.batch_sizes:
hflm.batch_sizes = ori_batch_sizes.copy()
try:
diff --git a/auto_round/experimental/transform/utils/hadamard.py b/auto_round/experimental/transform/utils/hadamard.py
index f1bbec2dd..5ec6bccbd 100644
--- a/auto_round/experimental/transform/utils/hadamard.py
+++ b/auto_round/experimental/transform/utils/hadamard.py
@@ -137,7 +137,7 @@ def _matmul_hadU(X: torch.Tensor) -> torch.Tensor:
output[:, :, 0, :] = input[:, :, 0, :] + input[:, :, 1, :]
output[:, :, 1, :] = input[:, :, 0, :] - input[:, :, 1, :]
output = output.view(input.shape[0], input.shape[1], -1)
- (input, output) = (output, input)
+ input, output = (output, input)
assert input.shape[1] == K
del output
diff --git a/auto_round/modeling/fused_moe/moe_experts_interface.py b/auto_round/modeling/fused_moe/moe_experts_interface.py
index e63f85c08..d8fc9ab46 100644
--- a/auto_round/modeling/fused_moe/moe_experts_interface.py
+++ b/auto_round/modeling/fused_moe/moe_experts_interface.py
@@ -31,7 +31,6 @@ Usage:
# Now the model uses linear_loop forward which supports quantized nn.Linear layers
"""
-
import torch
from torch import nn
@@ -645,7 +644,7 @@ def prepare_model_for_moe_quantization(model: nn.Module, implementation: str = L
# Set config for linear_loop forward
if hasattr(model, "config"):
saved_impl = getattr(model.config, "experts_implementation", None)
- impl_to_set = saved_impl if saved_impl else implementation
+ impl_to_set = saved_impl or implementation
model.config._experts_implementation = impl_to_set
logger.debug(f"Set model.config._experts_implementation = '{impl_to_set}'")
diff --git a/pyproject.toml b/pyproject.toml
index 99ffdaa8c..c275a8b98 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -79,6 +79,7 @@ ignore = [
"F401", # {name} imported but unused
"F403", # from {name} import * used; unable to detect undefined names
"F841", # Local variable is assigned to but never used{name}
+ "FURB171", # Membership test against single-item container
]
# Allow fix for all enabled rules (when `--fix`) is provided.