PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
adjust lrx2 logic to fix its issue in mixed bits scenarios and add more woq support in llmc (#2164)
Wenhua Cheng7e35bd636a29
diff --git a/auto_round/algorithms/quantization/sign_round/config.py b/auto_round/algorithms/quantization/sign_round/config.pyindex c3fb94e4e..ba293857f 100644--- a/auto_round/algorithms/quantization/sign_round/config.py+++ b/auto_round/algorithms/quantization/sign_round/config.py@@ -84,6 +84,10 @@ class SignRoundConfig(QuantizationConfig):# (e.g. only `scheme=` was given) -- finalize_scheme() fills them in.self.lr = lrself.minmax_lr = minmax_lr+ # Whether lr/minmax_lr are auto-derived; set properly in finalize_scheme().+ # Used to enable per-layer (mixed-bit) lr selection during tuning.+ self.lr_is_auto = lr is None+ self.minmax_lr_is_auto = minmax_lr is Noneself.lr_scheduler = lr_schedulerself.nblocks = nblocks@@ -103,15 +107,51 @@ class SignRoundConfig(QuantizationConfig):if self.enable_lfq:logger.warning("the `enable_lfq` feature is experimental and currently has limited model support.")+ def _lr_for_bits(self, bits: int | None) -> float | None:+ """Return the auto lr heuristic for a given bit-width.++ Low-bit schemes (<=3 bits) use a higher lr for better accuracy.+ Returns None when lr cannot be derived (e.g. ``iters == 0``).+ """+ if self.iters <= 0:+ return None+ # TODO need to check 4 bits lr setting for auto-round-best, 3bits only validate on small models+ if self.iters >= 1000 and bits is not None and bits <= 3:+ return 2.0 / self.iters+ return 1.0 / self.iters++ def compute_lr(self, bits: int | None) -> float | None:+ """Resolve the rounding lr for a specific layer bit-width.++ When the user supplied an explicit ``lr`` it is used for every layer;+ otherwise the auto heuristic is applied per-layer so that mixed-bit+ configs (e.g. a 4-bit model with a few 2-bit layers) get an+ appropriate lr for each layer.+ """+ if not self.lr_is_auto:+ return self.lr+ return self._lr_for_bits(bits)++ def compute_minmax_lr(self, bits: int | None) -> float | None:+ """Resolve the min-max tuning lr for a specific layer bit-width."""+ if not self.minmax_lr_is_auto:+ return self.minmax_lr+ # minmax_lr falls back to lr when not explicitly set+ return self.compute_lr(bits)+def finalize_scheme(self) -> None:- """Resolve lr/minmax_lr once `bits` is known (low-bit schemes use a higher lr)."""- if self.lr is None and self.iters > 0:- # TODO need to check 4 bits lr setting for auto-round-best, 3bits only validate on small models- if self.iters >= 1000 and self.bits is not None and self.bits <= 3:- self.lr = 2.0 / self.iters- logger.info("set the lr to 2.0/iters for better accuracy")- else:- self.lr = 1.0 / self.iters+ """Resolve lr/minmax_lr once `bits` is known (low-bit schemes use a higher lr).++ The scalar ``lr``/``minmax_lr`` values resolved here are derived from the+ global ``bits`` and serve as defaults/fallbacks. For mixed-bit configs the+ per-layer values are computed later via ``compute_lr``/``compute_minmax_lr``.+ """+ # Track whether the values are auto-derived so per-layer bit widths can+ # be honored during optimization (see compute_lr/compute_minmax_lr).+ self.lr_is_auto = self.lr is None and self.iters > 0+ self.minmax_lr_is_auto = self.minmax_lr is None+ if self.lr_is_auto:+ self.lr = self._lr_for_bits(self.bits)self.minmax_lr = self.minmax_lr or self.lrdef check_configs(self) -> None:diff --git a/auto_round/algorithms/quantization/sign_round/quantizer.py b/auto_round/algorithms/quantization/sign_round/quantizer.pyindex 0de9fffcb..4e4aeed57 100644--- a/auto_round/algorithms/quantization/sign_round/quantizer.py+++ b/auto_round/algorithms/quantization/sign_round/quantizer.py@@ -64,6 +64,20 @@ class SignRoundQuantizer(BaseQuantizer):self.optimizer = self._get_optimizer(optimizer=config.optimizer)self.wrapper_block = wrapper_block+ # Kept for per-layer (mixed-bit) lr resolution during tuning.+ self._config = config+ self.lr_is_auto = getattr(config, "lr_is_auto", False)+ self.minmax_lr_is_auto = getattr(config, "minmax_lr_is_auto", False)+ # Emit the low-bit lr notice at most once across all blocks/layers.+ self._logged_low_bit_lr = False++ def _maybe_log_low_bit_lr(self, bits) -> None:+ """Log once when low-bit (<=3) layers get the higher 2.0/iters lr."""+ if self._logged_low_bit_lr or not self.lr_is_auto:+ return+ if self.iters >= 1000 and bits is not None and bits <= 3:+ logger.info("using higher lr (2.0/iters) for <=3 bit layers to improve accuracy")+ self._logged_low_bit_lr = Truedef dispatch_block(self, block, input_ids, input_others):"""Multi-GPU aware block dispatch for SignRound tuning.@@ -359,34 +373,34 @@ class SignRoundQuantizer(BaseQuantizer):round_params = []minmax_params = []+ # Group parameters by their effective lr so that mixed-bit configs+ # (e.g. a 4-bit model with a few 2-bit layers) use a per-layer lr+ # derived from each layer's own bit-width.+ round_lr_groups: dict[float, list] = {}+ minmax_lr_groups: dict[float, list] = {}for n, m in block.named_modules():if hasattr(m, "orig_layer"):+ layer_bits = getattr(m.orig_layer, "bits", None)+ layer_lr = self._config.compute_lr(layer_bits)+ if layer_lr is None:+ layer_lr = self.lr+ self._maybe_log_low_bit_lr(layer_bits)+ layer_minmax_lr = self._config.compute_minmax_lr(layer_bits)+ if layer_minmax_lr is None:+ layer_minmax_lr = self.minmax_lrfor key in m.params.keys():if "min" in key or "max" in key:minmax_params.append(m.params[key])+ minmax_lr_groups.setdefault(float(layer_minmax_lr), []).append(m.params[key])else:round_params.append(m.params[key])+ round_lr_groups.setdefault(float(layer_lr), []).append(m.params[key])lr = torch.tensor(self.lr)minmax_lr = torch.tensor(self.minmax_lr)extra_kwargs = {} if self.momentum is None else {"momentum": self.momentum}- if self.enable_minmax_tuning:- params = [- {"params": round_params},- {"params": minmax_params, "lr": minmax_lr},- ]- else:- params = round_params-- optimizer = self.optimizer(- params,- lr=lr,- weight_decay=0,- **extra_kwargs,- )-if len(round_params) + len(minmax_params) <= 0:dump_info = (f"quantized {len(quantized_layer_names)}/{(len(quantized_layer_names) + len(unquantized_layer_names))} "@@ -396,6 +410,19 @@ class SignRoundQuantizer(BaseQuantizer):unwrapper_block(block, {})return {}+ # Build optimizer param groups with a per-layer lr for the rounding+ # parameters (and min-max parameters when enabled).+ params = [{"params": ps, "lr": torch.tensor(group_lr)} for group_lr, ps in round_lr_groups.items()]+ if self.enable_minmax_tuning:+ params += [{"params": ps, "lr": torch.tensor(group_lr)} for group_lr, ps in minmax_lr_groups.items()]++ optimizer = self.optimizer(+ params,+ lr=lr,+ weight_decay=0,+ **extra_kwargs,+ )+if self.lr_scheduler is None:lr_schedule = torch.optim.lr_scheduler.LinearLR(optimizer, start_factor=1.0, end_factor=0.0, total_iters=self.iters@@ -603,6 +630,16 @@ class SignRoundQuantizer(BaseQuantizer):lr = torch.tensor(self.lr)minmax_lr = torch.tensor(self.minmax_lr)+ # Use a lr derived from this layer's own bit-width so mixed-bit configs+ # (e.g. a 4-bit model with a few 2-bit layers) tune each layer correctly.+ layer_bits = getattr(layer, "bits", None)+ layer_lr = self._config.compute_lr(layer_bits)+ if layer_lr is not None:+ lr = torch.tensor(layer_lr)+ self._maybe_log_low_bit_lr(layer_bits)+ layer_minmax_lr = self._config.compute_minmax_lr(layer_bits)+ if layer_minmax_lr is not None:+ minmax_lr = torch.tensor(layer_minmax_lr)if self.enable_minmax_tuning:optimizer = self.optimizer([{"params": round_params}, {"params": minmax_params, "lr": minmax_lr}], lr=lr, weight_decay=0diff --git a/auto_round/auto_scheme/delta_loss.py b/auto_round/auto_scheme/delta_loss.pyindex 035d9122b..3f405fb3e 100644--- a/auto_round/auto_scheme/delta_loss.py+++ b/auto_round/auto_scheme/delta_loss.py@@ -2181,12 +2181,42 @@ def _gen_layer_config(else:nsamples = 16- # seqlen: API explicit setting takes priority; otherwise use MoE-aware default- if auto_scheme.seqlen is not None:+ # seqlen: env > API explicit setting > MoE-aware default+ _env_seqlen = _envs.AR_AUTO_SCHEME_SEQLEN+ if _env_seqlen is not None:+ seqlen = _env_seqlen+ elif auto_scheme.seqlen is not None:seqlen = auto_scheme.seqlenelse:seqlen = 128 if is_moe_model else 256+ # 2-bit options benefit from more/longer calibration data. Warn when 2-bit+ # (non-GGUF) schemes are present but nsamples/seqlen are below the recommended settings.+ def _scheme_has_2bit(scheme):+ if isinstance(scheme, str):+ try:+ scheme = asdict(preset_name_to_scheme(scheme))+ except Exception:+ return False+ if isinstance(scheme, QuantizationScheme):+ scheme = asdict(scheme)+ if isinstance(scheme, dict):+ # GGUF (super_bits set) uses its own (double) quantization and does+ # not follow this nsamples/seqlen recommendation, so skip it.+ if scheme.get("super_bits") is not None:+ return False+ return scheme.get("bits", 16) == 2+ return False++ if any(_scheme_has_2bit(s) for s in schemes) and (nsamples < 128 or seqlen < 1024):+ logger.warning(+ "AutoScheme: 2-bit scheme(s) detected. For better results, consider nsamples>=128 and "+ "seqlen>=1024 (current: nsamples=%d, seqlen=%d). "+ "Override via env vars AR_AUTO_SCHEME_NSAMPLES / AR_AUTO_SCHEME_SEQLEN.",+ nsamples,+ seqlen,+ )+if auto_scheme.batch_size is not None:batch_size = auto_scheme.batch_sizeelse:diff --git a/auto_round/auto_scheme/utils.py b/auto_round/auto_scheme/utils.pyindex 7b5d869a1..b987a263d 100644--- a/auto_round/auto_scheme/utils.py+++ b/auto_round/auto_scheme/utils.py@@ -570,8 +570,6 @@ def _log_score_summary_by_block_and_nonblock(non_block_items.sort(key=lambda x: x[0])for layer_name, layer_loss in non_block_items:logger.info("AutoScheme non_block=%s loss=%.6f", layer_name, layer_loss)- else:- logger.info("AutoScheme non_block loss: none")def _collect_current_scores(model):diff --git a/auto_round/compressors/base.py b/auto_round/compressors/base.pyindex d264ddbbe..8183dd0e9 100644--- a/auto_round/compressors/base.py+++ b/auto_round/compressors/base.py@@ -987,18 +987,102 @@ class BaseOrchestrator(object):self.has_qlayer_outside_block = self.compression_plan.has_qlayer_outside_blockapply_plan_to_model(self.model_context.model, self.compression_plan)if self.is_auto_scheme:- from auto_round.auto_scheme.utils import compute_avg_bits_for_model+ self._log_auto_scheme_avg_bits()- ignore_scale_zp_bits = getattr(self.orig_scheme, "ignore_scale_zp_bits", False)- avg_bits, total_bits = compute_avg_bits_for_model(- self.model_context.model,- ignore_scale_zp_bits=ignore_scale_zp_bits,+ def _log_auto_scheme_avg_bits(self) -> None:+ """Report AutoScheme bit usage under two denominators.++ ``avg_bits`` targets **only** the layers AutoScheme quantizes -- the set it was+ given as ``quant_layer_names``, which is exactly what the bit-allocation DP+ budgets. Layers outside that set (most notably a VLM's vision/audio tower, which+ is peeled off and kept at 16 bit, or layers pinned via ``layer_config`` /+ ``ignore_layers``) are not part of the target and are never compensated by the DP.++ Two numbers are therefore reported:++ * ``quant layers``: average over the quantized (budgeted) layers. This is the+ metric the target constrains and it must be <= target.+ * ``whole model``: average over every layer carrying quantization metadata, i.e.+ the end-to-end footprint. Informational only -- it can legitimately sit above+ the target when non-quantized towers are kept at high precision.+ """+ from auto_round.auto_scheme.utils import compute_layer_bits++ model = self.model_context.model+ ignore_scale_zp_bits = getattr(self.orig_scheme, "ignore_scale_zp_bits", False)+ target_avg_bits = getattr(self.orig_scheme, "avg_bits", None)++ scheme_generator = getattr(self, "scheme_generator", None)+ quant_layer_names = set(getattr(scheme_generator, "quant_layer_names", None) or [])++ quant_params = quant_bits = quant_count = 0+ model_params = model_bits = model_count = 0+ outside = []+ for name, module in model.named_modules():+ if not hasattr(module, "bits") or not hasattr(module, "weight"):+ continue+ n_param = module.weight.numel()+ if n_param == 0 and hasattr(module, "_cached_weight_numel"):+ n_param = module._cached_weight_numel+ if n_param == 0:+ continue+ layer_bits, _ = compute_layer_bits(module, ignore_scale_zp_bits)++ model_params += n_param+ model_bits += layer_bits+ model_count += 1++ # Without a scheme generator (e.g. a reloaded plan) fall back to+ # "actually quantized" as the definition of the quantized set.+ in_quant_set = name in quant_layer_names if quant_layer_names else getattr(module, "bits", 16) < 16+ if in_quant_set:+ quant_params += n_param+ quant_bits += layer_bits+ quant_count += 1+ else:+ outside.append((name, getattr(module, "bits", 16), n_param, layer_bits))++ quant_avg = quant_bits / quant_params if quant_params else float("nan")+ model_avg = model_bits / model_params if model_params else float("nan")+ has_target = isinstance(target_avg_bits, (int, float))++ logger.info(+ "AutoScheme final avg_bits: quant layers=%.4f (target=%.4f, %d layers, %d params, total_bits=%d); "+ "whole model=%.4f (%d layers, %d params, total_bits=%d, informational only)",+ quant_avg,+ float(target_avg_bits) if has_target else float("nan"),+ quant_count,+ quant_params,+ quant_bits,+ model_avg,+ model_count,+ model_params,+ model_bits,+ )++ # Only the quantized-layer average is bound by the target.+ if has_target and quant_avg > float(target_avg_bits) + 1e-3:+ logger.warning(+ "AutoScheme quantized-layer avg_bits=%.4f exceeds target avg_bits=%.4f. "+ "The bit-allocation budget was not met; please report this together with the "+ "AutoScheme option/range logs above.",+ quant_avg,+ float(target_avg_bits),)++ if outside:+ outside_params = sum(item[2] for item in outside)+ outside_bits = sum(item[3] for item in outside)logger.info(- "AutoScheme final effective avg_bits=%.4f, target avg_bits=%.4f, total_bits=%d",- avg_bits,- self.orig_scheme.avg_bits,- total_bits,+ "AutoScheme: %d layer(s) (%d params, %d bits, avg=%.4f) are not AutoScheme quantization targets, "+ "so they are excluded from the avg_bits target and only affect the whole-model number "+ "(typically a VLM vision/audio tower kept at 16 bit, or layers pinned via "+ "`layer_config`/`ignore_layers`): %s",+ len(outside),+ outside_params,+ outside_bits,+ outside_bits / outside_params if outside_params else float("nan"),+ ", ".join(f"{n}(bits={b})" for n, b, _, _ in outside[:8]) + (" ..." if len(outside) > 8 else ""),)# ─────────────────────────────────────────────────────────────────────────diff --git a/auto_round/envs.py b/auto_round/envs.pyindex b72b14ae3..97cda8a6b 100644--- a/auto_round/envs.py+++ b/auto_round/envs.py@@ -94,6 +94,10 @@ environment_variables: dict[str, Callable[[], Any]] = {# when ``AutoScheme.batch_size`` is not explicitly set.# When unset, AutoScheme uses its built-in heuristic (8 for low GPU memory mode, 1 for normal mode)."AR_AUTO_SCHEME_BATCH_SIZE": lambda: _get_optional_positive_int_env("AR_AUTO_SCHEME_BATCH_SIZE"),+ # Controls the default calibration sequence length used by AutoScheme scoring+ # when ``AutoScheme.seqlen`` is not explicitly set.+ # When unset, AutoScheme uses its built-in heuristic (128 for MoE models, 256 otherwise).+ "AR_AUTO_SCHEME_SEQLEN": lambda: _get_optional_positive_int_env("AR_AUTO_SCHEME_SEQLEN"),# Stores persistent AutoScheme scoring results independently from AR_WORK_SPACE,# whose contents are temporary working data and may be cleaned after a run."AR_AUTO_SCHEME_CACHE": lambda: os.getenv("AR_AUTO_SCHEME_CACHE", None),diff --git a/auto_round/export/formats/backends/llm_compressor.py b/auto_round/export/formats/backends/llm_compressor.pyindex 52d18037b..e856a4947 100644--- a/auto_round/export/formats/backends/llm_compressor.py+++ b/auto_round/export/formats/backends/llm_compressor.py@@ -36,6 +36,10 @@ class LLMCompressorFormat(OutputFormat):"FP8_BLOCK","W4A16","W8A16",+ "W2A16G32",+ "W2A16G64",+ "W2A16",+ "W3A16",]format_name = "llm_compressor"@@ -89,13 +93,13 @@ class LLMCompressorFormat(OutputFormat):@classmethoddef check_scheme_args(cls: OutputFormat, scheme: QuantizationScheme) -> bool:error_logs = []- if scheme.bits not in [4, 8, 16]:+ if scheme.bits not in [2, 3, 4, 8, 16]:error_logs.append(f"bits={scheme.bits}")if not re.search("mxfp|fp|nvfp|int", scheme.data_type):error_logs.append(f"data_type={scheme.data_type}")if scheme.data_type == "fp" and scheme.bits != 8:error_logs.append(f"data_type={scheme.data_type}, bits={scheme.bits}")- if scheme.data_type == "int" and scheme.bits not in [4, 8]:+ if scheme.data_type == "int" and scheme.bits not in [2, 3, 4, 8]:error_logs.append(f"data_type={scheme.data_type}, bits={scheme.bits}")if scheme.super_bits:error_logs.append(f"super_bits={scheme.super_bits}")diff --git a/docs/environments.md b/docs/environments.mdindex a61492314..4e77d2ce0 100644--- a/docs/environments.md+++ b/docs/environments.md@@ -141,6 +141,16 @@ export AR_AUTO_SCHEME_NSAMPLES=1 # set 1 for quick executionexport AR_AUTO_SCHEME_BATCH_SIZE=1```+### AR_AUTO_SCHEME_SEQLEN+- **Description**: Controls the default calibration sequence length used by AutoScheme scoring when `AutoScheme.seqlen` is not explicitly set.+- **Default**: unset → built-in heuristic applies (128 for MoE models, 256 otherwise)+- **Valid Values**: any positive integer, e.g. `256`, `512`, `1024`+- **Usage**: Set this to override the default sequence length for AutoScheme (2-bit schemes usually benefit from `1024`)++```bash+export AR_AUTO_SCHEME_SEQLEN=1024+```+### AR_AUTO_SCHEME_CACHE- **Description**: Stores persistent per-scheme AutoScheme scoring JSON files. This directory is independent of `AR_WORK_SPACE`, which is reserved for temporary working data.- **Default**: `~/.cache/auto_round`diff --git a/docs/environments_CN.md b/docs/environments_CN.mdindex 0272dbd1f..8684ccdcf 100644--- a/docs/environments_CN.md+++ b/docs/environments_CN.md@@ -141,6 +141,16 @@ export AR_AUTO_SCHEME_NSAMPLES=1export AR_AUTO_SCHEME_BATCH_SIZE=1```+### AR_AUTO_SCHEME_SEQLEN+- **描述**:控制 AutoScheme 评分时使用的校准序列长度默认值,仅在 `AutoScheme.seqlen` 未显式设置时生效。+- **默认值**:未设置 → 走内置启发式规则(MoE 模型为 128,其他为 256)+- **有效值**:任意正整数,如 `256`、`512`、`1024`+- **用途**:覆盖 AutoScheme 的默认序列长度(2-bit 方案通常在 `1024` 时效果更好)++```bash+export AR_AUTO_SCHEME_SEQLEN=1024+```+### AR_AUTO_SCHEME_CACHE- **描述**:存放可持久复用的 AutoScheme 单方案评分 JSON 文件。该目录独立于用于临时工作数据的 `AR_WORK_SPACE`。- **默认值**:`~/.cache/auto_round`diff --git a/docs/step_by_step.md b/docs/step_by_step.mdindex 5dc2f3719..be535ef99 100755--- a/docs/step_by_step.md+++ b/docs/step_by_step.md@@ -166,15 +166,14 @@ adopted within the community, **only 4-bits quantization is supported**. Please#### Format and scheme support matrix> Gray indicates the absence of a kernel or the presence of only an inefficient/reference kernel. BF16 is mainly for AutoScheme-| Format | Supported Schemes ||:-----------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-| **auto_round** | W4A16, W2A16, W3A16, W8A16, W2A16G64, W2A16G32, `MXFP4`, `MXFP8`, `MXFP4_RCEIL`, `MXFP8_RCEIL`, `NVFP4`, `FPW8A16`, `FP8_STATIC`, `FP8_BLOCK`, `BF16`, `MXINT4` |+| **auto_round** | W4A16, W2A16, W3A16, W8A16, W2A16G64, W2A16G32, `MXFP4`, `MXFP8`, `MXFP4_RCEIL`, `MXFP8_RCEIL`, `NVFP4`, `FPW8A16`, `FP8_STATIC`, `FP8_BLOCK`, `BF16`, `MXINT4` |+| **llm_compressor** | NVFP4, `MXFP4`, `MXFP8`, `FPW8A16`, `FP8_STATIC`, FP8_BLOCK, W4A16, W2A16, W8A16, W2A16G64, W2A16G32, W3A16 |+| **gguf** | GGUF:Q4_K_M, GGUF:Q2_K_S, GGUF:Q3_K_S, GGUF:Q3_K_M, GGUF:Q3_K_L, GGUF:Q4_K_S, GGUF:Q5_K_S, GGUF:Q5_K_M, GGUF:Q6_K, GGUF:Q4_0, GGUF:Q4_1, GGUF:Q5_0, GGUF:Q5_1,GGUF:Q8_0 |+| **mlx** / **auto_round:mlx** | W2A16, W3A16, W4A16, W5A16, W6A16, W8A16, BF16, mixed-bit / mixed-group_size (Apple Silicon only) || **auto_awq** | W4A16, BF16 || **auto_gptq** | W4A16, W2A16, W3A16, W8A16,W2A16G64, W2A16G32, BF16 |-| **llm_compressor** | NVFP4, `MXFP4`, `MXFP8`, `FPW8A16`, `FP8_STATIC`, FP8_BLOCK |-| **mlx** / **auto_round:mlx** | W2A16, W3A16, W4A16, W5A16, W6A16, W8A16, BF16, mixed-bit / mixed-group_size (Apple Silicon only) |-| **gguf** | GGUF:Q4_K_M, GGUF:Q2_K_S, GGUF:Q3_K_S, GGUF:Q3_K_M, GGUF:Q3_K_L, GGUF:Q4_K_S, GGUF:Q5_K_S, GGUF:Q5_K_M, GGUF:Q6_K, GGUF:Q4_0, GGUF:Q4_1, GGUF:Q5_0, GGUF:Q5_1,GGUF:Q8_0 || **fp8** | FP8_BLOCK || **fake** | `all schemes (only for research)` |@@ -463,6 +462,8 @@ See [SVDQuant Details](./svdquant_details.md) for smooth search, residual iteratAutoScheme automatically generates adaptive mixed-bit and mixed-data-type quantization recipes. For accuracy results, see [AutoScheme Accuracy Report](./auto_scheme_acc.md).+We recommend exporting to the llm_compressor format for now, as it can be easily deployed with vLLM.+**Note:** Mixed-data-types are supported during tuning, but cannot be exported to real models at this time.#### CLI Usage@@ -540,7 +541,7 @@ ar.quantize_and_save()We tested it on Nvidia A100 80G using torch v2.8.-We will try to optimize the RAM usage in the future. The RAM usage is about 1.1-1.5x of the model's BF16 size+RAM usage has been optimized since v0.14.2.| Models | Scheme | VRAM Cost | Time Cost || ------------- | --------------------- | --------- | --------------------- |diff --git a/docs/step_by_step_CN.md b/docs/step_by_step_CN.mdindex 3c4421ae0..d099d66b5 100755--- a/docs/step_by_step_CN.md+++ b/docs/step_by_step_CN.md@@ -158,16 +158,16 @@ AutoRound 支持多种量化配置:> 灰色背景的 schemes 表示它没有专门优化的内核,或只有效率极低的参考内核。-| 格式 | 支持的量化方案 |-|:--------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| **auto_round** | W4A16、W2A16、W3A16、W8A16、W2A16G64、W2A16G32、`MXFP4`、`MXFP8`、`MXFP4_RCEIL`、`MXFP8_RCEIL`、`NVFP4`、`FPW8A16`、`FP8_STATIC`、`FP8_BLOCK`、`BF16`, `MXINT4` |-| **auto_awq** | W4A16、BF16 |-| **auto_gptq** | W4A16、W2A16、W3A16、W8A16、W2A16G64、W2A16G32、BF16 |-| **llm_compressor** | NVFP4、`MXFP4`、`MXFP8`、`FPW8A16`、`FP8_STATIC`、FP8_BLOCK |-| **mlx** / **auto_round:mlx** (实验性功能) | W2A16、W3A16、W4A16、W5A16、W6A16、W8A16、BF16、混合 bit / 混合 group_size(仅 Apple Silicon) |-| **gguf** | GGUF:Q4_K_M、GGUF:Q2_K_S、GGUF:Q3_K_S、GGUF:Q3_K_M、GGUF:Q3_K_L、GGUF:Q4_K_S、GGUF:Q5_K_S、GGUF:Q5_K_M、GGUF:Q6_K、GGUF:Q4_0、GGUF:Q4_1、GGUF:Q5_0、GGUF:Q5_1、GGUF:Q8_0 |-| **fp8** | FP8_BLOCK |-| **fake** | `所有方案(仅用于研究场景)` |+| 格式 | 支持的量化方案 |+|:-------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------|+| **auto_round** | W4A16、W2A16、W3A16、W8A16、W2A16G64、W2A16G32、`MXFP4`、`MXFP8`、`MXFP4_RCEIL`、`MXFP8_RCEIL`、`NVFP4`、`FPW8A16`、`FP8_STATIC`、`FP8_BLOCK`、`BF16`, `MXINT4` |+| **gguf** | GGUF:Q4_K_M、GGUF:Q2_K_S、GGUF:Q3_K_S、GGUF:Q3_K_M、GGUF:Q3_K_L、GGUF:Q4_K_S、GGUF:Q5_K_S、GGUF:Q5_K_M、GGUF:Q6_K、GGUF:Q4_0、GGUF:Q4_1、GGUF:Q5_0、GGUF:Q5_1、GGUF:Q8_0 |+| **llm_compressor** | NVFP4、W4A16、W2A16、W3A16、W8A16、W2A16G64、W2A16G32、FP8_BLOCK 、 `MXFP4`、`MXFP8`、`FPW8A16`、`FP8_STATIC` |+| **auto_awq** | W4A16、BF16 |+| **auto_gptq** | W4A16、W2A16、W3A16、W8A16、W2A16G64、W2A16G32、BF16 |+| **mlx** / **auto_round:mlx** (实验性功能) | W2A16、W3A16、W4A16、W5A16、W6A16、W8A16、BF16、混合 bit / 混合 group_size(仅 Apple Silicon) |+| **fp8** | FP8_BLOCK |+| **fake** | `所有方案(仅用于研究场景)` |### 硬件兼容性@@ -457,7 +457,9 @@ Smooth 搜索、residual iterations、导出和推理说明请参阅 [SVDQuantAutoScheme 自动生成自适应的混合比特/混合数据类型量化方案。精度测试结果请参考 [AutoScheme 精度报告](./auto_scheme_acc.md)。-**说明:** 混合数据类型支持调优,但目前无法将其导出到实际模型中。+为了更好地在 vLLM 中部署,目前推荐导出到 llm_compressor 格式。++**说明:** 混合数据类型支持调优,但目前无法将其导出成实际模型。#### 命令行用法@@ -534,8 +536,7 @@ ar.quantize_and_save()#### AutoScheme 耗时与显存成本测试基于 Nvidia A100 80G、PyTorch 2.8。-后续我们会进一步优化显存占用。当前该方案的显存占用约为模型以 BF16 精度加载时的 1.1~1.5 倍。-+从 v0.14.2 起,RAM 占用已得到优化。| 模型 | 量化方案 | 显存占用 | 耗时 ||---------------| ----------------------- | -------- | --------------------- || Qwen3-8B | W2A16 / W4A16 / W8A16 | 14G | 60秒 × 可选方案数量 |diff --git a/test/unit/test_cpu/export/test_export.py b/test/unit/test_cpu/export/test_export.pyindex 48c8c7a7b..0822782b9 100644--- a/test/unit/test_cpu/export/test_export.py+++ b/test/unit/test_cpu/export/test_export.py@@ -564,14 +564,6 @@ class TestAutoRound:scale_dtype=ar.scale_dtype,)- with pytest.raises(ValueError, match="but got bits=2, data_type=int"):- resolve_formats(- ResolvedScheme.from_scheme(ar.scheme_context),- format="auto_round:llm_compressor",- model=ar.model_context.model,- scale_dtype=ar.scale_dtype,- )-ar = AutoRound(model=tiny_qwen_model_path,scheme="FP8_STATIC",