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.yamlindex 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.6hooks:- id: insert-licensefiles: |@@ -30,7 +30,7 @@ repos:]- repo: https://github.com/psf/black-pre-commit-mirror- rev: 25.12.0+ rev: 26.3.1hooks:- id: blackfiles: (.*\.py)$@@ -46,10 +46,10 @@ repos:- id: blacken-docsargs: [--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.2hooks:- id: codespellargs: [-w]@@ -57,17 +57,17 @@ repos:- tomli- repo: https://github.com/crate-ci/typos- rev: v1+ rev: v1.45.0hooks:- id: typos- repo: https://github.com/pycqa/isort- rev: 7.0.0+ rev: 8.0.1hooks:- id: isort- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.14.10+ rev: v0.15.9hooks:- id: ruffargs: [--fix, --exit-non-zero-on-fix, --no-cache]diff --git a/auto_round/compressors/base.py b/auto_round/compressors/base.pyindex 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 higherall_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.pyindex 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 osfrom datetime import datetime, timedeltadiff --git a/auto_round/eval/eval_cli.py b/auto_round/eval/eval_cli.pyindex 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, retryexcept 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.pyindex 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] == Kdel outputdiff --git a/auto_round/modeling/fused_moe/moe_experts_interface.py b/auto_round/modeling/fused_moe/moe_experts_interface.pyindex 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 torchfrom torch import nn@@ -645,7 +644,7 @@ def prepare_model_for_moe_quantization(model: nn.Module, implementation: str = L# Set config for linear_loop forwardif 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 implementationmodel.config._experts_implementation = impl_to_setlogger.debug(f"Set model.config._experts_implementation = '{impl_to_set}'")diff --git a/pyproject.toml b/pyproject.tomlindex 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.