PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
Enhance unit tests with timeout handling and stability improvements (#2135)
Sun, Xuehaoe4a02ccd171e
diff --git a/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.sh b/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.shindex b8137f84b..80fa680db 100644--- a/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.sh+++ b/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.sh@@ -68,7 +68,7 @@ function run_unit_test() {uv pip install -r test/unit/test_cuda/requirements.txtuv pip install -r test/unit/test_cuda/requirements_diffusion.txtuv pip install -U transformers chardet- uv pip install -U pytest-cov+ uv pip install -U pytest-cov pytest-timeoutuv pip install kernels==0.15.2 # For sm120: https://github.com/huggingface/transformers/blob/v5.13.1/setup.py#L93uv pip uninstall torch torchvisionuv pip install torch==2.13.0 torchvision torchao --index-url https://download.pytorch.org/whl/cu130@@ -100,7 +100,10 @@ function run_unit_test() {local test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_cuda_${test_basename}.log- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs --disable-warnings --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest -m "not skip_ci" \+ --cov=auto_round --cov-report= --cov-append --timeout=60 --session-timeout=720 \+ -vs --disable-warnings --durations=0 --durations-min=1 --junitxml="${ut_log_name%.log}.xml" \+ ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done[ -f .coverage ] && cp .coverage "${LOG_DIR}/.coverage.part${test_part}"@@ -113,7 +116,7 @@ function run_unit_test_llmc() {cd "${BUILD_SOURCESDIRECTORY}" || exit 1rm -rf /root/.venvuv venv --python=3.12 /root/.venv- uv pip install -U pytest-cov+ uv pip install -U pytest-cov pytest-timeoutBUILD_TYPE="nightly" uv pip install \-r test/integration/test_cuda/requirements_llmc.txt \--extra-index-url https://download.pytorch.org/whl/cu130 \@@ -131,7 +134,10 @@ function run_unit_test_llmc() {echo "##[group]Running ${test_file}..."local test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_cuda_llmc_${test_basename}.log- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs --disable-warnings --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest -m "not skip_ci" \+ --cov=auto_round --cov-report= --cov-append -vs --disable-warnings \+ --durations=0 --durations-min=1 --junitxml="${ut_log_name%.log}.xml" \+ ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done[ -f .coverage ] && cp .coverage "${LOG_DIR}/.coverage.llmc"@@ -144,7 +150,7 @@ function run_unit_test_sglang() {cd "${BUILD_SOURCESDIRECTORY}" || exit 1rm -rf /root/.venvuv venv --python=3.12 /root/.venv- uv pip install -U pytest-cov+ uv pip install -U pytest-cov pytest-timeoutuv pip install -r test/integration/test_cuda/requirements_sglang.txt \--prerelease=allow \--extra-index-url https://download.pytorch.org/whl/cu130 \@@ -162,7 +168,10 @@ function run_unit_test_sglang() {echo "##[group]Running ${test_file}..."local test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_cuda_sglang_${test_basename}.log- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs --disable-warnings --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest -m "not skip_ci" \+ --cov=auto_round --cov-report= --cov-append -vs --disable-warnings \+ --durations=0 --durations-min=1 --junitxml="${ut_log_name%.log}.xml" \+ ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done[ -f .coverage ] && cp .coverage "${LOG_DIR}/.coverage.sglang"@@ -175,7 +184,7 @@ function run_unit_test_vllm() {cd "${BUILD_SOURCESDIRECTORY}" || exit 1rm -rf /root/.venvuv venv --python=3.12 /root/.venv- uv pip install -U pytest-cov+ uv pip install -U pytest-cov pytest-timeoutuv pip install -r test/integration/test_cuda/requirements_vllm.txt \--extra-index-url https://download.pytorch.org/whl/cu130 \--index-strategy unsafe-best-match@@ -193,7 +202,10 @@ function run_unit_test_vllm() {echo "##[group]Running ${test_file}..."local test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_cuda_vllm_${test_basename}.log- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs --disable-warnings --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest -m "not skip_ci" \+ --cov=auto_round --cov-report= --cov-append -vs --disable-warnings \+ --durations=0 --durations-min=1 --junitxml="${ut_log_name%.log}.xml" \+ ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done[ -f .coverage ] && cp .coverage "${LOG_DIR}/.coverage.vllm"diff --git a/.azure-pipelines/scripts/ut/run_ark_ut.sh b/.azure-pipelines/scripts/ut/run_ark_ut.shindex e99e2c883..b59accd5c 100644--- a/.azure-pipelines/scripts/ut/run_ark_ut.sh+++ b/.azure-pipelines/scripts/ut/run_ark_ut.sh@@ -25,7 +25,7 @@ function run_unit_test() {echo "##[group]Running ark ${test_file}..."local ut_log_name="${LOG_DIR}/unittest_ark_${test_basename}.log"- pytest -v ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest -v ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done}diff --git a/.azure-pipelines/scripts/ut/run_ut.sh b/.azure-pipelines/scripts/ut/run_ut.shindex 8b2947826..67aaec68d 100644--- a/.azure-pipelines/scripts/ut/run_ut.sh+++ b/.azure-pipelines/scripts/ut/run_ut.sh@@ -22,7 +22,7 @@ function setup_environment() {git clone -b master --quiet --single-branch https://github.com/ggml-org/llama.cpp.git && cd llama.cpp/gguf-py && uv pip install .# install unit report dependencies- uv pip install pytest-cov+ uv pip install pytest-cov pytest-timeoutuv pip install -U chardetuv pip list@@ -90,8 +90,9 @@ function run_unit_test() {local test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_${test_basename}.log- numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" \- pytest --cov=auto_round --cov-report= --cov-append \+ COVERAGE_CORE=sysmon numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" \+ pytest -m "not skip_ci" --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \+ --cov=auto_round --cov-report= --cov-append \-vs --disable-warnings --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done@@ -102,15 +103,16 @@ function run_inc_unit_test() {INC_PT_ONLY=1 uv pip install -r /auto-round/test/integration/test_cpu/requirements_inc.txt --extra-index-url https://download.pytorch.org/whl/cpuecho "##[endgroup]"- cd /auto-round/test || exit 1+ cd /auto-round/test/integration || exit 1for test_file in $(find ./test_cpu -name "test_inc*.py" | sort); doecho "##[group]Running ${test_file}..."local test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_${test_basename}.log- numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" \- pytest --cov=auto_round --cov-report= --cov-append \+ COVERAGE_CORE=sysmon numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" \+ pytest --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \+ --cov=auto_round --cov-report= --cov-append \-vs --disable-warnings --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done@@ -123,15 +125,16 @@ function run_llmc_unit_test() {cd /auto-round && uv pip install .echo "##[endgroup]"- cd /auto-round/test || exit 1+ cd /auto-round/test/integration || exit 1for test_file in $(find ./test_cpu -name "test_llmc*.py" | sort); doecho "##[group]Running ${test_file}..."local test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_${test_basename}.log- numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" \- pytest --cov=auto_round --cov-report= --cov-append \+ COVERAGE_CORE=sysmon numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" \+ pytest --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \+ --cov=auto_round --cov-report= --cov-append \-vs --disable-warnings --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done@@ -147,6 +150,10 @@ function collect_log() {function main() {setup_environmentrun_unit_test+ if [ "$test_part" -eq 5 ] && [ "$NIGHTLY_TEST" = 1 ]; then+ run_inc_unit_test+ run_llmc_unit_test+ ficollect_logcheck_storage_usageprint_summarydiff --git a/.azure-pipelines/scripts/ut/run_ut_cuda.sh b/.azure-pipelines/scripts/ut/run_ut_cuda.shindex d37f804c1..e9941c933 100644--- a/.azure-pipelines/scripts/ut/run_ut_cuda.sh+++ b/.azure-pipelines/scripts/ut/run_ut_cuda.sh@@ -31,7 +31,7 @@ function create_conda_env() {export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}export LD_LIBRARY_PATH=$(python -c "import site; print(site.getsitepackages()[0])")/nvidia/nvjitlink/lib:$LD_LIBRARY_PATHfi- uv pip install pytest-cov cmake requests ninja psutil+ uv pip install pytest-cov pytest-timeout cmake requests ninja psutiluv cache prune}@@ -111,7 +111,8 @@ function run_unit_test() {local ut_log_name=${LOG_DIR}/unittest_cuda_${test_basename}.logecho "Running ${test_file}..."- pytest --cov=auto_round --cov-report= --cov-append -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest --cov=auto_round --cov-report= --cov-append \+ --durations=0 --durations-min=1 -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}done[ -f .coverage ] && cp .coverage ${LOG_DIR}/.coverage.unit@@ -145,7 +146,8 @@ function run_unit_test_vlm() {local ut_log_name=${LOG_DIR}/unittest_cuda_vlm_${test_basename}.logecho "Running ${test_file}..."- pytest --cov=auto_round --cov-report= --cov-append -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest --cov=auto_round --cov-report= --cov-append \+ --durations=0 --durations-min=1 -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}done[ -f .coverage ] && cp .coverage ${LOG_DIR}/.coverage.vlm@@ -174,7 +176,8 @@ function run_unit_test_llmc() {local ut_log_name=${LOG_DIR}/unittest_cuda_llmc_${test_basename}.logecho "Running ${test_file}..."- pytest --cov=auto_round --cov-report= --cov-append -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest --cov=auto_round --cov-report= --cov-append \+ --durations=0 --durations-min=1 -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}done[ -f .coverage ] && cp .coverage ${LOG_DIR}/.coverage.llmc@@ -207,7 +210,8 @@ function run_unit_test_sglang() {local ut_log_name=${LOG_DIR}/unittest_cuda_sglang_${test_basename}.logecho "Running ${test_file}..."- pytest --cov=auto_round --cov-report= --cov-append -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest --cov=auto_round --cov-report= --cov-append \+ --durations=0 --durations-min=1 -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}done[ -f .coverage ] && cp .coverage ${LOG_DIR}/.coverage.sglang@@ -241,7 +245,8 @@ function run_unit_test_vllm() {local ut_log_name=${LOG_DIR}/unittest_cuda_vllm_${test_basename}.logecho "Running ${test_file}..."- pytest --cov=auto_round --cov-report= --cov-append -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon pytest --cov=auto_round --cov-report= --cov-append \+ --durations=0 --durations-min=1 -vs --disable-warnings ${test_file} 2>&1 | tee ${ut_log_name}done[ -f .coverage ] && cp .coverage ${LOG_DIR}/.coverage.vllmdiff --git a/.azure-pipelines/scripts/ut/run_ut_hpu.sh b/.azure-pipelines/scripts/ut/run_ut_hpu.shindex 70399b1ae..67e5b9149 100644--- a/.azure-pipelines/scripts/ut/run_ut_hpu.sh+++ b/.azure-pipelines/scripts/ut/run_ut_hpu.sh@@ -8,7 +8,7 @@ function setup_environment() {export TZ='Asia/Shanghai'export TQDM_MININTERVAL=60export HF_HUB_DISABLE_PROGRESS_BARS=1- pip install pytest-cov+ pip install pytest-cov pytest-timeoutpip listecho "##[endgroup]"@@ -33,14 +33,16 @@ function run_unit_test() {echo "##[group]Running ${test_file} in HPU lazy mode..."local ut_log_name="${LOG_DIR}/unittest_lazy_${test_basename}.log"- PT_HPU_LAZY_MODE=1 pytest --cov="${auto_round_path}" \+ COVERAGE_CORE=sysmon PT_HPU_LAZY_MODE=1 pytest --cov="${auto_round_path}" \+ --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \--cov-report= --cov-append -vs --disable-warnings \--junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"echo "##[group]Running ${test_file} in HPU compile mode..."local ut_log_name="${LOG_DIR}/unittest_compile_${test_basename}.log"- PT_HPU_LAZY_MODE=0 pytest --mode compile --cov="${auto_round_path}" \+ COVERAGE_CORE=sysmon PT_HPU_LAZY_MODE=0 pytest --mode compile --cov="${auto_round_path}" \+ --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \--cov-report= --cov-append -vs --disable-warnings \--junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"diff --git a/.azure-pipelines/scripts/ut/run_ut_xpu.sh b/.azure-pipelines/scripts/ut/run_ut_xpu.shindex ff3899d6e..d69e6f563 100644--- a/.azure-pipelines/scripts/ut/run_ut_xpu.sh+++ b/.azure-pipelines/scripts/ut/run_ut_xpu.sh@@ -5,7 +5,7 @@ source /auto-round/.azure-pipelines/scripts/change_color.shfunction setup_environment() {echo "##[group]set up UT env..."- uv pip install pytest-cov+ uv pip install pytest-cov pytest-timeoutuv pip listecho "##[endgroup]"@@ -38,9 +38,10 @@ function run_unit_test() {echo "##[group]Running ark ${test_file}..."local ut_log_name="${LOG_DIR}/unittest_ark_${test_basename}.log"- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \- pytest --cov="${auto_round_path}" --cov-report= --cov-append -vs --disable-warnings \- --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \+ pytest --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \+ --cov="${auto_round_path}" --cov-report= --cov-append -vs --disable-warnings \+ --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done@@ -49,9 +50,10 @@ function run_unit_test() {echo "##[group]Running xpu ${test_file}..."local ut_log_name="${LOG_DIR}/unittest_xpu_${test_basename}.log"- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \- pytest --cov="${auto_round_path}" --cov-report= --cov-append -vs --disable-warnings \- --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \+ pytest --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \+ --cov="${auto_round_path}" --cov-report= --cov-append -vs --disable-warnings \+ --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done}@@ -69,9 +71,10 @@ function run_unit_test_llmc() {echo "##[group]Running xpu llmc ${test_file}..."local ut_log_name="${LOG_DIR}/unittest_xpu_${test_basename}.log"- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \- pytest --cov="${auto_round_path}" --cov-report= --cov-append -vs --disable-warnings \- --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}+ COVERAGE_CORE=sysmon numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \+ pytest --timeout=30 --session-timeout=600 --durations=0 --durations-min=1 \+ --cov="${auto_round_path}" --cov-report= --cov-append -vs --disable-warnings \+ --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}echo "##[endgroup]"done}diff --git a/test/README.md b/test/README.mdindex 61583a51a..28947fb10 100644--- a/test/README.md+++ b/test/README.md@@ -140,6 +140,25 @@ def test_model_inference(tiny_opt_model_path):- **CPU-specific** → `*/test_cpu/`, **CUDA-specific** → `*/test_cuda/`- Import from parent: `from test.helpers import ...`+### CI Markers and Timeouts++- For long-running or non-critical tests under `test_cuda/`, use+ `@pytest.mark.skip_ci(reason="...")` and provide a clear reason why the test should not run in CI.+- In CI, each test function has a default timeout of **30 seconds**, while each test file has a timeout of+ **10 minutes**.+- Prefer simplifying a test so that it completes within the default timeout. If the test cannot be reduced further,+ extend its timeout with `@pytest.mark.timeout(seconds)`. If a test file exceeds the 10-minute limit, split its tests+ into smaller files whenever possible.++```python[email protected](120)+def test_long_running_case(): ...++[email protected]_ci(reason="Time-consuming accuracy evaluation; covered by nightly tests")+def test_optional_accuracy_evaluation(): ...+```+## 5. Running Tests```shdiff --git a/test/integration/test_xpu/test_llmc_integration.py b/test/integration/test_xpu/test_llmc_integration.pyindex 3e68bd144..4920338c6 100644--- a/test/integration/test_xpu/test_llmc_integration.py+++ b/test/integration/test_xpu/test_llmc_integration.py@@ -75,6 +75,7 @@ w8a8_static_recipe_modifier = AutoRoundModifier(@pytest.mark.skipif(torch.xpu.device_count() < 1, reason="test requires at least 1 XPU")@pytest.mark.parametrize("recipe",[diff --git a/test/unit/test_ark/test_model.py b/test/unit/test_ark/test_model.pyindex 823da1e61..6c35da38b 100644--- a/test/unit/test_ark/test_model.py+++ b/test/unit/test_ark/test_model.py@@ -58,6 +58,7 @@ class TestAutoRoundARKBackend:evaluate_accuracy(model, tokenizer, threshold=tar_acc, batch_size=32, limit=limit)torch.xpu.empty_cache()+ @pytest.mark.timeout(60)@pytest.mark.parametrize("format", ["auto_round", "auto_round:gptqmodel"])@pytest.mark.parametrize("bits, group_size, sym", [(4, 128, True), (8, 128, True)])@pytest.mark.parametrize("dtype", [torch.bfloat16])@@ -65,6 +66,7 @@ class TestAutoRoundARKBackend:def test_formats(self, format, bits, group_size, sym, dtype, device):self.main_op(format, bits, group_size, sym, dtype, device)+ @pytest.mark.timeout(60)@pytest.mark.parametrize("format", ["auto_round:auto_awq"])@pytest.mark.parametrize("bits, group_size, sym", [(4, 32, True)])@pytest.mark.parametrize("dtype", [torch.float16])@@ -72,6 +74,7 @@ class TestAutoRoundARKBackend:def test_awq_fp16(self, format, bits, group_size, sym, dtype, device):self.main_op(format, bits, group_size, sym, dtype, device)+ @pytest.mark.timeout(300)@pytest.mark.parametrize("format", ["auto_round"])@pytest.mark.parametrize("bits, group_size, sym", [(2, 32, False)])@pytest.mark.parametrize("dtype", [torch.bfloat16])diff --git a/test/unit/test_cpu/advanced/test_low_precision_input_model.py b/test/unit/test_cpu/advanced/test_low_precision_input_model.pyindex aadfcd6f8..2a8fbdd4f 100644--- a/test/unit/test_cpu/advanced/test_low_precision_input_model.py+++ b/test/unit/test_cpu/advanced/test_low_precision_input_model.py@@ -86,6 +86,7 @@ class TestCompressedTensor:model.model.layers[0].mlp.up_proj.weight.dtype == torch.bfloat16), "CompressedLinear layer was not converted to Linear"+ @pytest.mark.timeout(60)def test_w4a16_to_mxfp4(self, tmp_path):model = get_tiny_model(get_model_path(self.w4a16_model_path))model.config.name_or_path = None # Clear the name_or_path to avoid MTP copying issuesdiff --git a/test/unit/test_cpu/algorithms/test_awq.py b/test/unit/test_cpu/algorithms/test_awq.pyindex 100e0547b..4b5569d0f 100644--- a/test/unit/test_cpu/algorithms/test_awq.py+++ b/test/unit/test_cpu/algorithms/test_awq.py@@ -44,6 +44,7 @@ class TestAWQNormalLLM:yieldshutil.rmtree(self.save_dir, ignore_errors=True)+ @pytest.mark.timeout(60)def test_awq_w4a16_quantize_and_inference(self, tiny_opt_model_path):"""W4A16 AWQ quantization produces valid layer_config and model can generate."""ar = AutoRound(@@ -68,6 +69,7 @@ class TestAWQNormalLLM:output = generate_prompt(model, tokenizer, device="cpu")assert len(output) > 0, "Model should produce non-empty output"+ @pytest.mark.timeout(60)def test_awq_w4a16_export_auto_round_format(self, tiny_opt_model_path):"""AWQ W4A16 export to auto_round format: verify quantization_config in saved config."""ar = AutoRound(@@ -120,6 +122,7 @@ class TestAWQNonIntegerSchemes:under an MXFP/NVFP scheme."""+ @pytest.mark.timeout(60)@pytest.mark.parametrize("scheme", ["MXFP4", "NVFP4"])def test_awq_non_integer_scheme_smoke(self, tiny_opt_model_path, scheme):ar = AutoRound(@@ -241,6 +244,7 @@ class TestAWQMoE:del model+ @pytest.mark.timeout(420)def test_awq_moe_quantized_layers_check(self, tiny_qwen_moe_model_path):"""AWQ on MoE: expert layers should be quantized, gates/routers stay FP."""ar = AutoRound(@@ -275,6 +279,7 @@ class TestAWQMoE:for name in fp_layers:assert name.endswith("gate"), f"Unexpected FP layer: {name}"+ @pytest.mark.timeout(300)def test_awq_moe_save_quant_config(self, tiny_qwen_moe_model_path):"""AWQ MoE: saved quantization_config should be consistent and loadable."""ar = AutoRound(diff --git a/test/unit/test_cpu/backends/test_torch_backend.py b/test/unit/test_cpu/backends/test_torch_backend.pyindex bedc850c0..fe3576bb8 100644--- a/test/unit/test_cpu/backends/test_torch_backend.py+++ b/test/unit/test_cpu/backends/test_torch_backend.py@@ -26,6 +26,7 @@ class TestAutoRoundTorchBackend:def teardown_class(self):shutil.rmtree("runs", ignore_errors=True)+ @pytest.mark.timeout(60)def test_torch_4bits_asym(self, dataloader):model = AutoModelForCausalLM.from_pretrained(self.model_name, dtype="auto", trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained(self.model_name, trust_remote_code=True)@@ -64,6 +65,7 @@ class TestAutoRoundTorchBackend:evaluate_accuracy(model, tokenizer, threshold=0.35, batch_size=16, limit=10)torch.cuda.empty_cache()+ @pytest.mark.timeout(60)def test_torch_4bits_sym(self, dataloader):model = AutoModelForCausalLM.from_pretrained(self.model_name, dtype="auto", trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained(self.model_name, trust_remote_code=True)diff --git a/test/unit/test_cpu/core/test_autoround.py b/test/unit/test_cpu/core/test_autoround.pyindex 70bc9c6d9..9eb4be7df 100644--- a/test/unit/test_cpu/core/test_autoround.py+++ b/test/unit/test_cpu/core/test_autoround.py@@ -36,6 +36,7 @@ class TestAutoRound:def teardown_class(self):shutil.rmtree("runs", ignore_errors=True)+ @pytest.mark.timeout(90)def test_bits_setting(self, tiny_opt_model_path):layer_config = {"model.decoder.layers.0.self_attn.k_proj": {"data_type": "mx_fp8", "group_size": 32}}autoround = AutoRound(tiny_opt_model_path, iters=2, seqlen=2, nsamples=1, layer_config=layer_config)@@ -44,6 +45,7 @@ class TestAutoRound:if module.bits != 8:raise ValueError(f"Expected bits to be 8, but got {module.bits}")+ @pytest.mark.timeout(90)def test_layer_config(self, tiny_opt_model_path, dataloader):model_name = tiny_opt_model_pathlayer_config = {"self_attn": {"bits": 4, "data_type": "nv_fp", "act_bits": 16, "group_size": 16}}@@ -106,6 +108,7 @@ class TestAutoRound:)autoround.quantize()+ @pytest.mark.timeout(120)def test_mx_fp4(self, dataloader):model_name = opt_name_or_pathbits, group_size, sym = 4, 32, False@@ -154,6 +157,7 @@ class TestAutoRound:)autoround.quantize()+ @pytest.mark.timeout(60)@pytest.mark.parametrize("bits", [2, 3, 4])def test_g128(self, bits, dataloader):model_name = opt_name_or_path@@ -366,6 +370,7 @@ class TestAutoRound:)autoround.quantize()+ @pytest.mark.timeout(60)def test_rtn(self, tiny_opt_model_path):model_name = tiny_opt_model_pathmodel = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True)diff --git a/test/unit/test_cpu/core/test_resume_integration.py b/test/unit/test_cpu/core/test_resume_integration.pyindex 6396a65aa..8bcedbb29 100644--- a/test/unit/test_cpu/core/test_resume_integration.py+++ b/test/unit/test_cpu/core/test_resume_integration.py@@ -41,6 +41,7 @@ def _clean_resume_env():class TestResumeIntegration:+ @pytest.mark.timeout(60)def test_resume_skips_already_completed_blocks(self, tiny_opt_model_path, tmp_path):resume_dir = str(tmp_path / "resume")# AR_DISK_STREAM_MODEL keeps low_cpu_mem_usage active for this plaindiff --git a/test/unit/test_cpu/export/test_export.py b/test/unit/test_cpu/export/test_export.pyindex 7b7ac3b3e..805e68675 100644--- a/test/unit/test_cpu/export/test_export.py+++ b/test/unit/test_cpu/export/test_export.py@@ -202,6 +202,7 @@ class TestAutoRound:inputs = tokenizer(text, return_tensors="pt").to(model.device)print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))+ @pytest.mark.timeout(120)@pytest.mark.parametrize("static_kv_dtype", ["fp8", "float16"])def test_static_afp8_export(self, static_kv_dtype):import os@@ -321,6 +322,7 @@ class TestAutoRound:assert f.get_tensor(weight_name).dtype == torch.float32 or f.get_tensor(weight_name).dtype == torch.bfloat16assert "model.decoder.layers.8.self_attn.q_max" not in f.keys()+ @pytest.mark.timeout(120)def test_awq_lmhead_export(self, dataloader):bits, sym, group_size = 4, False, 128model_name = get_model_path("microsoft/phi-4")@@ -355,6 +357,7 @@ class TestAutoRound:assert isinstance(lm_head, WQLinear_GEMM), "Illegal AWQ quantization for lm_head layer"+ @pytest.mark.timeout(120)def test_gptq_lmhead_export(self, dataloader):bits, sym, group_size = 4, True, 128# Note that, to save UT tuning time, the local model is intentionally kept lightweight, using only 2 hidden layers.@@ -527,6 +530,7 @@ class TestAutoRound:scale_dtype=ar.scale_dtype,)+ @pytest.mark.timeout(480)def test_autoawq_qwen3_vl_infer(self, dataloader):model_path = get_model_path("Qwen/Qwen3-VL-2B-Instruct")autoround = AutoRound(diff --git a/test/unit/test_cpu/export/test_gguf_format.py b/test/unit/test_cpu/export/test_gguf_format.pyindex 81ffdc3cf..1f9b3956e 100644--- a/test/unit/test_cpu/export/test_gguf_format.py+++ b/test/unit/test_cpu/export/test_gguf_format.py@@ -11,8 +11,21 @@ from transformers import AutoModelForCausalLM, AutoTokenizerfrom auto_round import AutoRoundfrom auto_round.algorithms.quantization.rtn.config import OptimizedRTNConfig-AUTO_ROUND_PATH = __file__.split("/")-AUTO_ROUND_PATH = "/".join(AUTO_ROUND_PATH[: AUTO_ROUND_PATH.index("test")])++def _run_auto_round_cli(monkeypatch, cmd):+ """Run the auto_round CLI in-process by patching ``sys.argv``.++ ``cmd`` contains only the CLI arguments (everything after ``-m auto_round``).+ This replaces the previous ``os.system('python -m auto_round ...')`` calls so+ the code runs in the test process and is measured by coverage.+ """+ from auto_round.cli.main import run++ monkeypatch.setattr(sys, "argv", ["auto_round", *cmd.split()])+ try:+ run()+ except SystemExit as exc: # argparse help/errors exit; only 0/None is success+ assert exc.code in (0, None), f"cmd line test fail, exit code {exc.code}"def test_update_module_applies_replacements_for_gguf(monkeypatch):@@ -56,6 +69,7 @@ class TestGGUF:yieldshutil.rmtree(self.save_dir, ignore_errors=True)+ @pytest.mark.timeout(60)def test_q4_0(self, tiny_qwen_model_path):bits, group_size, sym = 4, 32, Trueautoround = AutoRound(@@ -89,6 +103,7 @@ class TestGGUF:assert type(autoround).__name__ == "CompressionOrchestrator"assert isinstance(autoround.quantize_config, OptimizedRTNConfig)+ @pytest.mark.timeout(60)def test_func(self):bits, group_size, sym = 4, 128, Trueautoround = AutoRound(@@ -106,6 +121,7 @@ class TestGGUF:model = AutoModelForCausalLM.from_pretrained(quantized_model_path, gguf_file=gguf_file, device_map="auto")eval_generated_prompt(model, self.tokenizer)+ @pytest.mark.timeout(120)def test_q4_k_m(self, dataloader, tiny_qwen_model_path):model_name = tiny_qwen_model_pathlayer_config = {@@ -145,45 +161,38 @@ class TestGGUF:assert autoround.model.model.layers[0].mlp.gate_proj.bits == 8assert autoround.layer_config["model.layers.0.mlp.gate_proj"]["mostly"] == "gguf:q8_0"- def test_all_format(self, tiny_qwen_model_path):+ @pytest.mark.timeout(360)+ def test_all_format(self, monkeypatch, tiny_qwen_model_path):model_name = tiny_qwen_model_path- python_path = sys.executable# for gguf_format in ["gguf:q4_0", "gguf:q4_1", "gguf:q4_k_m", "gguf:q6_k"]:for gguf_format in ["gguf:q4_k_m"]:- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --model {model_name} "- f" --bs 16 --iters 1 --nsamples 1 --seqlen 16 --format {gguf_format}"+ _run_auto_round_cli(+ monkeypatch,+ f"--model {model_name} --bs 16 --iters 1 --nsamples 1 --seqlen 16 --format {gguf_format}",)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"shutil.rmtree("../../tmp_autoround", ignore_errors=True)- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --model {model_name}"- f" --bs 16 --iters 0 --nsamples 1 --seqlen 16 --format fake,{gguf_format}"+ _run_auto_round_cli(+ monkeypatch,+ f"--model {model_name} --bs 16 --iters 0 --nsamples 1 --seqlen 16 --format fake,{gguf_format}",)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"shutil.rmtree("../../tmp_autoround", ignore_errors=True)# test q2_k_mixed with iters=0 (RTN) on non-MoE model — should still work- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --model {model_name}"- f" --bs 16 --iters 0 --disable_opt_rtn --nsamples 1 --seqlen 16 --scheme GGUF:Q2_K_MIXED"+ _run_auto_round_cli(+ monkeypatch,+ f"--model {model_name} --bs 16 --iters 0 --disable_opt_rtn --nsamples 1 --seqlen 16 --scheme GGUF:Q2_K_MIXED",)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"shutil.rmtree("../../tmp_autoround", ignore_errors=True)# test q2_k_mixed with iters=1 on non-MoE model — should fallback to q4_k_m- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --model {model_name}"- f" --bs 16 --iters 1 --nsamples 1 --seqlen 16 --format gguf:q2_k_mixed"+ _run_auto_round_cli(+ monkeypatch,+ f"--model {model_name} --bs 16 --iters 1 --nsamples 1 --seqlen 16 --format gguf:q2_k_mixed",)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"shutil.rmtree("../../tmp_autoround", ignore_errors=True)+ @pytest.mark.timeout(90)def test_vlm_gguf(self, tiny_qwen_vl_model_path):from auto_round import AutoRound@@ -204,6 +213,7 @@ class TestGGUF:else:assert file_size < 270, f"file size {file_size} MB is too large for non-quantized mmproj-model.gguf"+ @pytest.mark.timeout(60)def test_vlm_gguf_wo_quant_nontext_module(self, tiny_qwen_vl_model_path):from auto_round import AutoRound@@ -462,6 +472,7 @@ class TestGGUF:assert ar.layer_config["model.language_model.embed_tokens"]["bits"] == 6assert ar.layer_config["model.language_model.embed_tokens"]["super_bits"] == 8+ @pytest.mark.timeout(60)def test_q2k_mixed(self, tiny_qwen_moe_model_path):model_name = tiny_qwen_moe_model_pathautoround = AutoRound(@@ -484,6 +495,7 @@ class TestGGUF:tensor_types = {tensor.name: tensor.tensor_type.name for tensor in gguf_model.tensors}assert tensor_types["blk.0.ffn_up_exps.weight"] == "Q2_K"+ @pytest.mark.timeout(60)def test_q2k_mixed_keeps_only_three_dim_expert_weights_at_q2k(self, tiny_qwen_moe_model_path):model_name = tiny_qwen_moe_model_pathautoround = AutoRound(diff --git a/test/unit/test_cpu/export/test_llmc_format.py b/test/unit/test_cpu/export/test_llmc_format.pyindex bc815408d..cf83d8b9f 100644--- a/test/unit/test_cpu/export/test_llmc_format.py+++ b/test/unit/test_cpu/export/test_llmc_format.py@@ -47,6 +47,7 @@ class TestLLMC:# autoround.quantize()# autoround.save_quantized("./saved", format="llm_compressor", inplace=True)+ @pytest.mark.timeout(120)def test_llmcompressor_fp8(self, tmp_path):## quantize the modelmodel_name = opt_name_or_path@@ -129,6 +130,7 @@ class TestLLMC:and quantization_config["ignore"] == ["lm_head"]), f"Invalid MXFP8 quantization configuration: {quantization_config}"+ @pytest.mark.timeout(60)def test_mxfp8_llmcompressor_kv_config(self, tiny_opt_model_path, tmp_path):ar = AutoRound(model=tiny_opt_model_path,@@ -192,6 +194,7 @@ class TestLLMC:assert any(key.endswith(".self_attn.q_scale") for key in keys), "q_scale not found in checkpoint"assert not any(key.endswith(".q_max") for key in keys), "q_max should not be exported"+ @pytest.mark.timeout(60)def test_mixed_precision_llmcompressor_format(self, tiny_opt_model_path, tmp_path):scheme = AutoScheme(avg_bits=7,diff --git a/test/unit/test_cpu/models/test_audio_model.py b/test/unit/test_cpu/models/test_audio_model.pyindex 656ba5848..98ffbb933 100644--- a/test/unit/test_cpu/models/test_audio_model.py+++ b/test/unit/test_cpu/models/test_audio_model.py@@ -162,6 +162,7 @@ class TestMiMoAudioQuantization:has_quantlinear = any(m.__class__.__name__ == "QuantLinear" for m in quantized_model.modules())assert has_quantlinear, "Quantized model should contain QuantLinear layers"+ @pytest.mark.timeout(60)def test_quantize_with_tuning(self, tiny_mimo_audio_model_path, tmp_path):import transformersdiff --git a/test/unit/test_cpu/models/test_diffusion.py b/test/unit/test_cpu/models/test_diffusion.pyindex d6b45df26..d61100f97 100644--- a/test/unit/test_cpu/models/test_diffusion.py+++ b/test/unit/test_cpu/models/test_diffusion.py@@ -23,6 +23,7 @@ def setup_flux():return pipe, output_dir[email protected](120)def test_flux_saving(setup_flux):pipe, output_dir = setup_fluxautoround = AutoRound(@@ -39,6 +40,7 @@ def test_flux_saving(setup_flux):shutil.rmtree(output_dir, ignore_errors=True)[email protected](150)def test_flux(setup_flux):pipe, output_dir = setup_fluxautoround = AutoRound(diff --git a/test/unit/test_cpu/models/test_mllm.py b/test/unit/test_cpu/models/test_mllm.pyindex 3ea8c72d5..4905680f6 100644--- a/test/unit/test_cpu/models/test_mllm.py+++ b/test/unit/test_cpu/models/test_mllm.py@@ -147,6 +147,7 @@ class TestAutoRound:model = AutoModelForCausalLM.from_pretrained(opt_name_or_path, trust_remote_code=True)assert is_pure_text_model(model)+ @pytest.mark.timeout(120)def test_str_input(self):tokenizer = AutoTokenizer.from_pretrained(self.model_name)processor = AutoProcessor.from_pretrained(self.model_name, trust_remote_code=True)diff --git a/test/unit/test_cpu/models/test_moe_alignment.py b/test/unit/test_cpu/models/test_moe_alignment.pyindex e1cacd48e..995461b07 100644--- a/test/unit/test_cpu/models/test_moe_alignment.py+++ b/test/unit/test_cpu/models/test_moe_alignment.py@@ -28,6 +28,7 @@ def setup_deepseek_v2_lite():return model, tokenizer, output_dir, config[email protected](120)def test_moe_scale_alignment_fp8_static(setup_deepseek_v2_lite):"""Test that FP8_STATIC quantization unifies gate/up input scales across experts."""# Enable MoE scale unification explicitlydiff --git a/test/unit/test_cpu/models/test_moe_model.py b/test/unit/test_cpu/models/test_moe_model.pyindex 91fcd7178..e608c8437 100644--- a/test/unit/test_cpu/models/test_moe_model.py+++ b/test/unit/test_cpu/models/test_moe_model.py@@ -41,6 +41,7 @@ def count_modules_by_type(model, target_module_name_or_class):return cnt@pytest.mark.parametrize("scheme", ["MXFP4", "MXFP8"])def test_gptoss(scheme, tiny_gpt_oss_model_path, tmp_path):config = AutoConfig.from_pretrained(tiny_gpt_oss_model_path, trust_remote_code=True)@@ -74,6 +75,7 @@ def test_gptoss(scheme, tiny_gpt_oss_model_path, tmp_path):loaded_out = loaded_model(inp)[email protected](120)def test_llama4(tiny_llama4_model_path):output_dir = "./tmp/test_quantized_llama4"quantized_model, save_folder = quantize_model(diff --git a/test/unit/test_cpu/quantization/test_asym.py b/test/unit/test_cpu/quantization/test_asym.pyindex 3d75ba582..80fc58abf 100644--- a/test/unit/test_cpu/quantization/test_asym.py+++ b/test/unit/test_cpu/quantization/test_asym.py@@ -22,6 +22,7 @@ class TestAutoRoundAsym:shutil.rmtree("runs", ignore_errors=True)# use parameters later+ @pytest.mark.timeout(60)def test_asym_format(self, tiny_opt_model_path):for format in ["auto_round", "auto_round:auto_gptq", "auto_round:gptqmodel"]:bits, group_size, sym = 4, 128, Falsediff --git a/test/unit/test_cpu/quantization/test_block_fp.py b/test/unit/test_cpu/quantization/test_block_fp.pyindex 151d06012..7fb6695c2 100644--- a/test/unit/test_cpu/quantization/test_block_fp.py+++ b/test/unit/test_cpu/quantization/test_block_fp.py@@ -92,6 +92,7 @@ class TestAutoRoundBlockFP:scale_ref[i, j] = data[i * 128 : (i + 1) * 128, j * 128 : (j + 1) * 128].abs().max() / max_valassert (scale == scale_ref).all()+ @pytest.mark.timeout(120)def test_group_size_handler(self, tiny_qwen_model_path):scheme = {"data_type": "int",diff --git a/test/unit/test_cpu/quantization/test_mix_bits.py b/test/unit/test_cpu/quantization/test_mix_bits.pyindex ee3f22700..8ba18fdbd 100644--- a/test/unit/test_cpu/quantization/test_mix_bits.py+++ b/test/unit/test_cpu/quantization/test_mix_bits.py@@ -175,6 +175,7 @@ class TestAutoRound:inputs = tokenizer(text, return_tensors="pt").to(model.device)print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))+ @pytest.mark.timeout(60)def test_mixed_MXFP_autoround_format_loading(self, dataloader):layer_config = {"k_proj": {"bits": 8, "act_bits": 8},diff --git a/test/unit/test_cpu/quantization/test_model_free.py b/test/unit/test_cpu/quantization/test_model_free.pyindex 46ea0d35e..9043a5b95 100644--- a/test/unit/test_cpu/quantization/test_model_free.py+++ b/test/unit/test_cpu/quantization/test_model_free.py@@ -1526,6 +1526,7 @@ class TestModelFreeAutoScheme:assert base_scheme.data_type == "mx_fp"assert base_scheme.bits in (4, 8)+ @pytest.mark.timeout(120)def test_e2e_int_auto_scheme(self, tmp_path, tiny_opt_model_path):from auto_round import AutoSchemediff --git a/test/unit/test_cpu/quantization/test_model_free_parity.py b/test/unit/test_cpu/quantization/test_model_free_parity.pyindex a82ed53c0..9871edf42 100644--- a/test/unit/test_cpu/quantization/test_model_free_parity.py+++ b/test/unit/test_cpu/quantization/test_model_free_parity.py@@ -253,6 +253,7 @@ def test_disable_model_free_opt_out(tiny_opt_model_path):assert ar.model is not Nonedef test_mxfp_auto_scheme_quantization_config_parity(tmp_path, tiny_opt_model_path):"""Mixed MXFP AutoScheme must serialize the same scheme metadata in both paths."""pytest.importorskip("compressed_tensors")diff --git a/test/unit/test_cpu/quantization/test_mxfp_nvfp.py b/test/unit/test_cpu/quantization/test_mxfp_nvfp.pyindex 051b71e26..e701f0c98 100644--- a/test/unit/test_cpu/quantization/test_mxfp_nvfp.py+++ b/test/unit/test_cpu/quantization/test_mxfp_nvfp.py@@ -61,6 +61,7 @@ class TestAutoRoundFP:moe = compressed_model.model.layers[1].mlpassert hasattr(moe.experts[0].gate_proj.orig_layer, "act_max")+ @pytest.mark.timeout(60)def test_nvfp4_moe_actmax_ar(self, tiny_deepseek_v2_model_path, dataloader):model_name = tiny_deepseek_v2_model_pathlayer_config = {@@ -93,6 +94,7 @@ class TestAutoRoundFP:and lm_head.weight_scale.dtype is torch.float8_e4m3fn), "Illegal NVFP4 packing for lm_head layer"+ @pytest.mark.timeout(60)def test_mxfp4_moe_ar(self, tiny_deepseek_v2_model_path, dataloader):model_name = tiny_deepseek_v2_model_pathlayer_config = {diff --git a/test/unit/test_cpu/quantization/test_static_attn.py b/test/unit/test_cpu/quantization/test_static_attn.pyindex 9f99186ec..e6c3f006b 100644--- a/test/unit/test_cpu/quantization/test_static_attn.py+++ b/test/unit/test_cpu/quantization/test_static_attn.py@@ -37,6 +37,7 @@ def setup_deepseekv3():return model, tokenizer, output_dir, config[email protected](120)def test_deepseek_v2(setup_deepseekv2):model, tokenizer, output_dir, config = setup_deepseekv2autoround = AutoRound(@@ -59,6 +60,7 @@ def test_deepseek_v2(setup_deepseekv2):shutil.rmtree(output_dir, ignore_errors=True)def test_deepseek_v3(setup_deepseekv3):model, tokenizer, output_dir, config = setup_deepseekv3autoround = AutoRound(diff --git a/test/unit/test_cpu/schemes/test_auto_scheme.py b/test/unit/test_cpu/schemes/test_auto_scheme.pyindex d71ac0e01..271bfbced 100644--- a/test/unit/test_cpu/schemes/test_auto_scheme.py+++ b/test/unit/test_cpu/schemes/test_auto_scheme.py@@ -305,6 +305,7 @@ class TestAutoScheme:assert mxfp_config["data_type"] == "mx_fp"assert os.path.exists(os.path.join(int_model_path, "config.json"))+ @pytest.mark.timeout(120)def test_gguf_user_fixed_embedding_budget(self, tiny_qwen_model_path):"""Regression test: a user-fixed embedding must be budget-priced at its fixed bits.diff --git a/test/unit/test_cpu/schemes/test_scheme.py b/test/unit/test_cpu/schemes/test_scheme.pyindex 482e30c91..cab978c0b 100644--- a/test/unit/test_cpu/schemes/test_scheme.py+++ b/test/unit/test_cpu/schemes/test_scheme.py@@ -45,6 +45,7 @@ class TestAutoRound:ar.post_init()assert ar.bits == 2+ @pytest.mark.timeout(120)def test_w4a16_mixed(self, tiny_qwen_moe_model_path, dataloader):layer_config = {@@ -178,6 +179,7 @@ class TestAutoRound:device_list = parse_available_devices("0,1")assert len(device_list) == 1 and "cpu" in device_list+ @pytest.mark.timeout(60)def test_set_scheme(self, tiny_qwen_model_path):ar = AutoRound(tiny_qwen_model_path,diff --git a/test/unit/test_cpu/utils/test_alg_ext.py b/test/unit/test_cpu/utils/test_alg_ext.pyindex 60b199f07..4926f69fa 100644--- a/test/unit/test_cpu/utils/test_alg_ext.py+++ b/test/unit/test_cpu/utils/test_alg_ext.py@@ -1,9 +1,12 @@from test.helpers import qwen_name_or_path+import pytest+from auto_round import AutoRoundclass TestAlgExt:+ @pytest.mark.timeout(60)def test_alg_ext(self, tiny_opt_model_path, tiny_qwen_model_path):model_name = tiny_opt_model_pathar = AutoRound(model_name, scheme="W2A16", iters=1, nsamples=1, enable_alg_ext=True)diff --git a/test/unit/test_cpu/utils/test_calib_dataset.py b/test/unit/test_cpu/utils/test_calib_dataset.pyindex bfb401fbe..d707d36df 100644--- a/test/unit/test_cpu/utils/test_calib_dataset.py+++ b/test/unit/test_cpu/utils/test_calib_dataset.py@@ -98,6 +98,7 @@ class TestLocalCalibDataset:)autoround.quantize()+ @pytest.mark.timeout(60)def test_apply_chat_template(self, tiny_qwen_model_path):model_name = tiny_qwen_model_pathmodel = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", trust_remote_code=True)@@ -117,6 +118,7 @@ class TestLocalCalibDataset:)autoround.quantize()+ @pytest.mark.timeout(180)def test_combine_dataset(self, tiny_qwen_model_path):dataset = "NeelNanda/pile-10k" + "," + "madao33/new-title-chinese" + "," + "mbpp" + "," + "opencode-instruct"bits, group_size, sym = 4, 128, True@@ -132,6 +134,7 @@ class TestLocalCalibDataset:)autoround.quantize()+ @pytest.mark.timeout(60)def test_combine_dataset2(self, tiny_opt_model_path):dataset = "NeelNanda/pile-10k:num=256,mbpp:num=256"bits, group_size, sym = 4, 128, Truediff --git a/test/unit/test_cpu/utils/test_cli_usage.py b/test/unit/test_cpu/utils/test_cli_usage.pyindex 27b9749ed..9e251c371 100644--- a/test/unit/test_cpu/utils/test_cli_usage.py+++ b/test/unit/test_cpu/utils/test_cli_usage.py@@ -1,14 +1,26 @@-import osimport shutilimport sysfrom test.helpers import get_model_pathimport pytest+from auto_round.cli.main import run, run_lightfrom auto_round.utils import parse_layer_config_arg-AUTO_ROUND_PATH = __file__.split("/")-AUTO_ROUND_PATH = "/".join(AUTO_ROUND_PATH[: AUTO_ROUND_PATH.index("test")])++def _assert_cli_ok(monkeypatch, argv, entry=run):+ """Run an in-process CLI entry point and assert it succeeds.++ ``argv`` is the full argv (including argv[0]); it replaces ``sys.argv`` so+ the entry point parses it exactly like a real command line invocation.+ Help/eval paths exit via argparse with code 0, while quantization paths+ return normally. Any non-zero ``SystemExit`` indicates a CLI failure.+ """+ monkeypatch.setattr(sys, "argv", list(argv))+ try:+ entry()+ except SystemExit as exc: # argparse help/version exits with code 0+ assert exc.code in (0, None), f"cmd line test fail, exit code {exc.code}"class TestAutoRoundCmd:@@ -24,76 +36,152 @@ class TestAutoRoundCmd:shutil.rmtree("runs", ignore_errors=True)shutil.rmtree("../../tmp_autoround", ignore_errors=True)- def test_auto_round_cmd(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round -h")- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"-- def test_auto_round_cmd2(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --model {tiny_opt_model_path} --seqlen 32 --iter 2 --nsamples 1 --format auto_gptq,auto_round --output_dir {self.save_dir} --tasks piqa --limit 2"+ def test_auto_round_cmd(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(monkeypatch, ["auto_round", "-h"])++ @pytest.mark.timeout(90)+ def test_auto_round_cmd2(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(+ monkeypatch,+ [+ "auto_round",+ "--model",+ tiny_opt_model_path,+ "--seqlen",+ "32",+ "--iter",+ "2",+ "--nsamples",+ "1",+ "--format",+ "auto_gptq,auto_round",+ "--output_dir",+ self.save_dir,+ "--tasks",+ "piqa",+ "--limit",+ "2",+ ],)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"- def test_auto_round_cmd3(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --model {tiny_opt_model_path} --seqlen 8 --iter 1 --nsamples 1 --eval_task_by_task --tasks openbookqa --bs 32 --limit 2"+ @pytest.mark.timeout(90)+ def test_auto_round_cmd3(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(+ monkeypatch,+ [+ "auto_round",+ "--model",+ tiny_opt_model_path,+ "--seqlen",+ "8",+ "--iter",+ "1",+ "--nsamples",+ "1",+ "--eval_task_by_task",+ "--tasks",+ "openbookqa",+ "--bs",+ "32",+ "--limit",+ "2",+ ],)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"- def test_auto_round_cmd4(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -c 'from auto_round.__main__ import run_light; run_light()' --seqlen 8 --iter 2 --nsamples 8 --output_dir {self.save_dir} --tasks lambada_openai --limit 2"+ @pytest.mark.timeout(90)+ def test_auto_round_cmd4(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(+ monkeypatch,+ [+ "auto_round",+ "--seqlen",+ "8",+ "--iter",+ "2",+ "--nsamples",+ "8",+ "--output_dir",+ self.save_dir,+ "--tasks",+ "lambada_openai",+ "--limit",+ "2",+ ],+ entry=run_light,)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"-- def test_auto_round_cmd5(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --eval -h")- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"-- def test_auto_round_cmd6(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --eval --lmms -h")- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"-- def test_auto_round_cmd7(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --mllm --model {tiny_qwen_vl_model_path} --iter 2 --nsamples 2 --seqlen 32 --format auto_round --output_dir {self.save_dir}"++ def test_auto_round_cmd5(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(monkeypatch, ["auto_round", "--eval", "-h"])++ def test_auto_round_cmd6(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(monkeypatch, ["auto_round", "--eval", "--lmms", "-h"])++ @pytest.mark.timeout(90)+ def test_auto_round_cmd7(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(+ monkeypatch,+ [+ "auto_round",+ "--mllm",+ "--model",+ tiny_qwen_vl_model_path,+ "--iter",+ "2",+ "--nsamples",+ "2",+ "--seqlen",+ "32",+ "--format",+ "auto_round",+ "--output_dir",+ self.save_dir,+ ],)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"-- def test_auto_round_cmd8(self, tiny_opt_model_path, tiny_qwen_vl_model_path):- python_path = sys.executable- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round --mllm --iter 2 --nsamples 2 --model {tiny_qwen_vl_model_path} --seqlen 32 --format auto_round"- f" --quant_nontext_module --output_dir {self.save_dir}"++ def test_auto_round_cmd8(self, monkeypatch, tiny_opt_model_path, tiny_qwen_vl_model_path):+ _assert_cli_ok(+ monkeypatch,+ [+ "auto_round",+ "--mllm",+ "--iter",+ "2",+ "--nsamples",+ "2",+ "--model",+ tiny_qwen_vl_model_path,+ "--seqlen",+ "32",+ "--format",+ "auto_round",+ "--quant_nontext_module",+ "--output_dir",+ self.save_dir,+ ],)- if res > 0 or res == -1:- assert False, "cmd line test fail, please have a check"- def test_layer_config(self, tiny_opt_model_path):+ def test_layer_config(self, monkeypatch, tiny_opt_model_path):"""Test --layer_config with unquoted JSON-like syntax."""- python_path = sys.executablelayer_cfg = r"{fc1:{bits:8,data_type:int},fc2:{bits:16,data_type:int}}"- res = os.system(- f"PYTHONPATH='{AUTO_ROUND_PATH}:$PYTHONPATH' {python_path} -m auto_round"- f" --model {tiny_opt_model_path} --seqlen 8 --iter 0 --disable_opt_rtn"- f" --layer_config '{layer_cfg}' --format auto_round --output_dir {self.save_dir}"+ _assert_cli_ok(+ monkeypatch,+ [+ "auto_round",+ "--model",+ tiny_opt_model_path,+ "--seqlen",+ "8",+ "--iter",+ "0",+ "--disable_opt_rtn",+ "--layer_config",+ layer_cfg,+ "--format",+ "auto_round",+ "--output_dir",+ self.save_dir,+ ],)- if res > 0 or res == -1:- assert False, "cmd line test with --layer_config fail, please have a check"def test_parse_layer_config():diff --git a/test/unit/test_cpu/utils/test_model_scope.py b/test/unit/test_cpu/utils/test_model_scope.pyindex b93d9346b..17cfd497b 100644--- a/test/unit/test_cpu/utils/test_model_scope.py+++ b/test/unit/test_cpu/utils/test_model_scope.py@@ -30,11 +30,15 @@ class TestModelScope:if os.path.exists(self.cache_path):shutil.rmtree(self.cache_path, ignore_errors=True)+ @pytest.mark.skip_ci(reason="https://github.com/intel/auto-round/issues/2127")+ @pytest.mark.timeout(120)def test_llm(self, dataloader):model_name = get_model_path("Qwen/Qwen2.5-0.5B-Instruct")autoround = AutoRound(model_name, platform="model_scope", scheme="w4a16", iters=0, seqlen=2, dataset=dataloader)autoround.quantize_and_save()+ @pytest.mark.skip_ci(reason="https://github.com/intel/auto-round/issues/2127")+ @pytest.mark.timeout(360)def test_mllm(self, dataloader):model_name = get_model_path("Qwen/Qwen2-VL-2B-Instruct")autoround = AutoRound(diff --git a/test/unit/test_cuda/advanced/test_evaluation.py b/test/unit/test_cuda/advanced/test_evaluation.pyindex bcac8740c..31a87a84f 100644--- a/test/unit/test_cuda/advanced/test_evaluation.py+++ b/test/unit/test_cuda/advanced/test_evaluation.py@@ -19,40 +19,48 @@ from test.helpers import opt_name_or_pathimport pytest+def _run_auto_round_cli(monkeypatch, cmd):+ """Run the auto_round CLI in-process by patching ``sys.argv``.++ ``cmd`` contains only the CLI arguments (everything after ``-m auto_round``).+ This replaces the previous ``os.system('python -m auto_round ...')`` calls so+ the code runs in the test process and is measured by coverage.+ """+ from auto_round.cli.main import run++ monkeypatch.setattr(sys, "argv", ["auto_round", *cmd.split()])+ try:+ run()+ except SystemExit as exc: # argparse help/errors exit; only 0/None is success+ assert exc.code in (0, None), f"cmd line test fail, exit code {exc.code}"++@pytest.mark.skipif(not os.path.exists("/usr/bin/nvidia-smi") and not os.path.exists("/usr/local/cuda"), reason="CUDA not available")class TestHFEvaluation:"""Test different evaluation modes: --eval and --eval_backend."""- def test_eval_mode_hf_backend(self, tiny_opt_model_path):+ def test_eval_mode_hf_backend(self, monkeypatch, tiny_opt_model_path):"""Test --eval flag: evaluate model without quantization (HF backend default)."""- python_path = sys.executable-- cmd = f"{python_path} -m auto_round --model {tiny_opt_model_path} --eval --tasks lambada_openai --limit 10"-- ret = os.system(cmd)-- assert ret == 0, f"HF backend evaluation failed (rc={ret})"+ _run_auto_round_cli(+ monkeypatch,+ f"--model {tiny_opt_model_path} --eval --tasks lambada_openai --limit 10",+ )@pytest.mark.skip_ci(reason="The evaluation is time-consuming")- def test_iters_0_hf_backend(self, tiny_opt_model_path):+ def test_iters_0_hf_backend(self, monkeypatch, tiny_opt_model_path):"""Test quantization with iters=0 and HF backend evaluation."""- python_path = sys.executable-- cmd = f"{python_path} -m auto_round --model {tiny_opt_model_path} --iters 0 --disable_opt_rtn --tasks lambada_openai --limit 10"-- ret = os.system(cmd)-- assert ret == 0, f"HF backend with iters=0 failed (rc={ret})"+ _run_auto_round_cli(+ monkeypatch,+ f"--model {tiny_opt_model_path} --iters 0 --disable_opt_rtn --tasks lambada_openai --limit 10",+ )@pytest.mark.skip_ci(reason="The evaluation is time-consuming")- def test_iters_0_task_by_task(self, tiny_opt_model_path):+ def test_iters_0_task_by_task(self, monkeypatch, tiny_opt_model_path):"""Test quantization with iters=0 and task-by-task evaluation."""- python_path = sys.executable-- cmd = f"{python_path} -m auto_round --model {tiny_opt_model_path} --iters 0 --disable_opt_rtn --eval_task_by_task --tasks lambada_openai,piqa --limit 10"-- ret = os.system(cmd)-- assert ret == 0, f"Task-by-task with iters=0 failed (rc={ret})"+ _run_auto_round_cli(+ monkeypatch,+ f"--model {tiny_opt_model_path} --iters 0 --disable_opt_rtn "+ f"--eval_task_by_task --tasks lambada_openai,piqa --limit 10",+ )diff --git a/test/unit/test_cuda/algorithms/test_alg_ext.py b/test/unit/test_cuda/algorithms/test_alg_ext.pyindex a97f6efe3..8b61e251a 100644--- a/test/unit/test_cuda/algorithms/test_alg_ext.py+++ b/test/unit/test_cuda/algorithms/test_alg_ext.py@@ -57,6 +57,7 @@ class TestAlgExt:# "overrides were applied (data_type was not yet 'int_asym_dq')."# )+ @pytest.mark.timeout(90)def test_int2_g64_asym_enable_alg_ext_keeps_config(self, tiny_qwen_model_path):"""Regression test: asym int2/g64 keeps the requested tuning config."""@@ -90,6 +91,7 @@ class TestAlgExt:assert quantizer.enable_norm_bias_tuning is Trueassert quantizer.enable_quanted_input is False+ @pytest.mark.timeout(120)@pytest.mark.parametrize("scheme", ["MXFP4", "NVFP4", "W2A16G64", "gguf:q2_k_s,gguf:q4_k_s"])def test_all_support_dtype(self, scheme, tiny_qwen_model_path):from auto_round.auto_scheme import AutoSchemediff --git a/test/unit/test_cuda/algorithms/test_auto_scheme.py b/test/unit/test_cuda/algorithms/test_auto_scheme.pyindex 70b286550..73945bd1e 100644--- a/test/unit/test_cuda/algorithms/test_auto_scheme.py+++ b/test/unit/test_cuda/algorithms/test_auto_scheme.py@@ -28,6 +28,7 @@ class TestAutoScheme:yieldshutil.rmtree("runs", ignore_errors=True)+ @pytest.mark.timeout(60)def test_gguf_k_0(self, tiny_qwen_model_path):target_bits = 5.5scheme = AutoScheme(avg_bits=target_bits, options=("GGUF:Q4_K_M", "GGUF:Q8_0"))@@ -75,6 +76,7 @@ class TestAutoScheme:# Due to the tiny model and embedding, the actual number of bits of gguf format will be larger than the target bits.assert target_bits - 0.1 < avg_bits <= target_bits + 0.3+ @pytest.mark.timeout(150)def test_shared_layers(self, tiny_opt_model_path):model_name = tiny_opt_model_pathfrom transformers import AutoModelForCausalLM, AutoTokenizer@@ -247,6 +249,7 @@ class TestAutoScheme:print(avg_bits)assert target_bits - 0.1 < avg_bits <= target_bits + 1e-3+ @pytest.mark.timeout(150)def test_lm_head_and_mix_dtype(self, tiny_untied_qwen_model_path):target_bits = 5scheme = AutoScheme(avg_bits=target_bits, options=("MXFP4", "MXFP8"))@@ -311,6 +314,7 @@ class TestAutoScheme:_, quantized_model_path = ar.quantize_and_save(output_dir=self.save_dir)evaluate_accuracy(quantized_model_path, threshold=0.10)+ @pytest.mark.skip_ci(reason="Time-consuming: two quantizations plus two lm_eval runs; covered by nightly")def test_mixed_bits_get_scoring(self):"""Verify that AutoScheme scoring produces accuracy above a known reference threshold for mixed-bitquantization.diff --git a/test/unit/test_cuda/algorithms/test_awq.py b/test/unit/test_cuda/algorithms/test_awq.pyindex d5faecb45..15b7f3038 100644--- a/test/unit/test_cuda/algorithms/test_awq.py+++ b/test/unit/test_cuda/algorithms/test_awq.py@@ -46,6 +46,7 @@ class TestAWQLLM:yieldshutil.rmtree(self.save_dir, ignore_errors=True)+ @pytest.mark.timeout(90)def test_awq_w4a16_quantize_and_inference(self, tiny_opt_model_path):"""W4A16 AWQ quantization and CUDA inference smoke test."""ar = AutoRound(@@ -92,6 +93,7 @@ class TestAWQLLM:assert qconfig["sym"] == symassert "auto-round" in qconfig["quant_method"]+ @pytest.mark.timeout(120)def test_awq_w4a16_load_and_generate(self):"""Quantize, save, reload, and generate on CUDA to verify round-trip."""model_name = get_model_path("facebook/opt-125m")@@ -121,6 +123,7 @@ class TestAWQMoE:yieldshutil.rmtree(self.save_dir, ignore_errors=True)+ @pytest.mark.timeout(120)def test_awq_moe_dynamic_smoothing(self, tiny_qwen_moe_model_path):"""AWQ mapping resolution works on MoE model."""from auto_round.algorithms.transforms.awq.mappings import resolve_mappings@@ -153,6 +156,7 @@ class TestAWQMoE:del model+ @pytest.mark.timeout(240)def test_awq_moe_quantized_layers_check(self, tiny_qwen_moe_model_path):"""Expert layers quantized to W4, gates/routers stay fp."""ar = AutoRound(@@ -189,6 +193,7 @@ class TestAWQMoE:for name in fp_layers:assert name.endswith("gate"), f"Unexpected FP layer: {name}"+ @pytest.mark.skip_ci(reason="Redundant MoE quantize only to check file-size ratio; layer check already covers it")def test_awq_moe_save_compressed_size(self, tiny_qwen_moe_model_path):"""AWQ MoE W4: quantized safetensors should be smaller than original."""ar = AutoRound(@@ -233,6 +238,7 @@ class TestAWQEval:def teardown_class(cls):shutil.rmtree("runs", ignore_errors=True)+ @pytest.mark.skip_ci(reason="Time-consuming lm_eval accuracy check; covered by nightly")def test_awq_w4a16_lmeval(self):"""AWQ W4A16 on OPT-125m: lambada_openai accuracy check."""ar = AutoRound(diff --git a/test/unit/test_cuda/backends/test_exllamav2_backend.py b/test/unit/test_cuda/backends/test_exllamav2_backend.pyindex 25be1425a..7ca321b20 100644--- a/test/unit/test_cuda/backends/test_exllamav2_backend.py+++ b/test/unit/test_cuda/backends/test_exllamav2_backend.py@@ -34,6 +34,7 @@ class TestAutoRoundexllamaBackend:# @pytest.mark.skip_ci(reason="Only tiny model is suggested")# @pytest.mark.skip_ci(reason="Time-consuming; Accuracy evaluation")@require_gptqmodel+ @pytest.mark.timeout(240)def test_gptqmodel_exllmav2_4bits_asym(self, dataloader):model_path = get_model_path("facebook/opt-125m")bits, group_size, sym = 4, 128, False@@ -127,6 +128,7 @@ class TestAutoRoundexllamaBackend:torch.cuda.empty_cache()@require_gptqmodel+ @pytest.mark.timeout(90)def test_gptqmodel_awq_exllamav2_4bits_asym(self, dataloader):"""Test AWQ quantization with gptqmodel:awq_exllamav2 backend (bfloat16 inference)."""model_path = get_model_path("facebook/opt-125m")diff --git a/test/unit/test_cuda/backends/test_marlin_backend.py b/test/unit/test_cuda/backends/test_marlin_backend.pyindex d13507be4..a00350eea 100644--- a/test/unit/test_cuda/backends/test_marlin_backend.py+++ b/test/unit/test_cuda/backends/test_marlin_backend.py@@ -34,6 +34,7 @@ class TestAutoRoundMarlinBackend:# Keep one CI test for marlin backend and skip others to save time.# @pytest.mark.skip_ci(reason="Only tiny model is suggested")# @pytest.mark.skip_ci(reason="Time-consuming; Accuracy evaluation")+ @pytest.mark.timeout(240)def test_marlin_4bits_sym_with_zp_m_1(self, dataloader):model = AutoModelForCausalLM.from_pretrained(self.model_name, torch_dtype="auto", trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained(self.model_name, trust_remote_code=True)@@ -172,6 +173,7 @@ class TestAutoRoundMarlinBackend:# shutil.rmtree("./saved", ignore_errors=True)@require_gptqmodel+ @pytest.mark.timeout(90)def test_gptqmodel_awq_marlin_4bits_sym(self):"""Test AWQ quantization with gptqmodel:awq_marlin backend (sym-only, float16)."""model_path = get_model_path("facebook/opt-125m")diff --git a/test/unit/test_cuda/backends/test_torch_backend.py b/test/unit/test_cuda/backends/test_torch_backend.pyindex f4127fb2c..dd03cd87b 100644--- a/test/unit/test_cuda/backends/test_torch_backend.py+++ b/test/unit/test_cuda/backends/test_torch_backend.py@@ -33,6 +33,7 @@ class TestAutoRoundTorchBackend:# Keep one CI test for torch backend and skip others to save time.# @pytest.mark.skip_ci(reason="Only tiny model is suggested")# @pytest.mark.skip_ci(reason="Time-consuming; Accuracy evaluation")+ @pytest.mark.timeout(90)def test_torch_4bits_asym(self, dataloader):model_path = get_model_path("facebook/opt-125m")model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype="auto", trust_remote_code=True)diff --git a/test/unit/test_cuda/backends/test_triton_backend.py b/test/unit/test_cuda/backends/test_triton_backend.pyindex 159e06f8d..95d57937c 100644--- a/test/unit/test_cuda/backends/test_triton_backend.py+++ b/test/unit/test_cuda/backends/test_triton_backend.py@@ -29,6 +29,7 @@ class TestAutoRoundTritonBackend:# @pytest.mark.skip_ci(reason="Only tiny model is suggested")# @pytest.mark.skip_ci(reason="Time-consuming; Accuracy evaluation")@require_greater_than_050+ @pytest.mark.timeout(300)def test_tritonv2_2bits_asym(self):model = AutoModelForCausalLM.from_pretrained(self.model_name, torch_dtype="auto", trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained(self.model_name, trust_remote_code=True)diff --git a/test/unit/test_cuda/calibration/test_calib_dataset.py b/test/unit/test_cuda/calibration/test_calib_dataset.pyindex bdee2ebeb..fd90cdfec 100644--- a/test/unit/test_cuda/calibration/test_calib_dataset.py+++ b/test/unit/test_cuda/calibration/test_calib_dataset.py@@ -10,6 +10,7 @@ from auto_round import AutoRoundclass TestLocalCalibDataset:+ @pytest.mark.timeout(150)def test_combine_dataset(self, tiny_opt_model_path):dataset = "NeelNanda/pile-10k" + ",BAAI/CCI3-HQ" + ",madao33/new-title-chinese"bits, group_size, sym = 4, 128, Truediff --git a/test/unit/test_cuda/export/test_auto_round_format.py b/test/unit/test_cuda/export/test_auto_round_format.pyindex d3c729ffa..0f8427e32 100644--- a/test/unit/test_cuda/export/test_auto_round_format.py+++ b/test/unit/test_cuda/export/test_auto_round_format.py@@ -153,6 +153,7 @@ class TestAutoRound:eval_generated_prompt(model, tokenizer)torch.cuda.empty_cache()+ @pytest.mark.timeout(120)def test_fp8_block_fp8_format(self):model_name = "Qwen/Qwen3-0.6B"diff --git a/test/unit/test_cuda/export/test_fp8_format.py b/test/unit/test_cuda/export/test_fp8_format.pyindex 8d2cec59c..7b7618885 100644--- a/test/unit/test_cuda/export/test_fp8_format.py+++ b/test/unit/test_cuda/export/test_fp8_format.py@@ -22,6 +22,7 @@ class TestAutoRoundBlockFP:yieldshutil.rmtree(self.save_dir, ignore_errors=True)+ @pytest.mark.timeout(90)def test_fp8_block_fp8_format(self):model_name = self.model_namediff --git a/test/unit/test_cuda/export/test_gguf_format.py b/test/unit/test_cuda/export/test_gguf_format.pyindex 0435a61c8..5c929db14 100644--- a/test/unit/test_cuda/export/test_gguf_format.py+++ b/test/unit/test_cuda/export/test_gguf_format.py@@ -102,6 +102,7 @@ class TestAutoRound:@pytest.mark.skipif(not check_version("transformers>=5.2.0"), reason="requires transformers >= 5.2.0")@pytest.mark.skipif(not torch.cuda.is_available(), reason="requires CUDA")@require_gguf+ @pytest.mark.timeout(240)def test_qwen35_moe_gguf(self, tiny_qwen35_moe_model_path):self._export_qwen35_moe_gguf(tiny_qwen35_moe_model_path)@@ -137,6 +138,7 @@ class TestAutoRound:quantized_model_path = self.save_dirautoround.save_quantized(output_dir=quantized_model_path, format="gguf:q4_1")+ @pytest.mark.skip_ci(reason="Time-consuming accuracy evaluation; covered by nightly")@require_ggufdef test_q4_0_accuracy(self):model_name = get_model_path("Qwen/Qwen2.5-0.5B-Instruct")@@ -222,6 +224,7 @@ class TestAutoRound:shutil.rmtree(tiny_model_path, ignore_errors=True)@require_gguf+ @pytest.mark.timeout(120)def test_vlm_gguf(self):from test.helpers import save_tiny_model@@ -296,6 +299,7 @@ class TestAutoRound:shutil.rmtree(saved_tiny_model_path, ignore_errors=True)@require_gguf+ @pytest.mark.timeout(90)def test_q2_k_s_ffn_down_q4k(self):"""Verify blk.0.ffn_down.weight is Q4_K in gguf:q2_k_s format.Blocks where i_layer < n_layer/8 should use Q4_K instead of Q2_K for ffn_down."""diff --git a/test/unit/test_cuda/models/test_audio_model.py b/test/unit/test_cuda/models/test_audio_model.pyindex 929326b31..578f1c8eb 100644--- a/test/unit/test_cuda/models/test_audio_model.py+++ b/test/unit/test_cuda/models/test_audio_model.py@@ -327,6 +327,7 @@ class TestMiMoAudioQuantization:has_quantlinear = any(m.__class__.__name__ == "QuantLinear" for m in quantized_model.modules())assert has_quantlinear, "Quantized model should contain QuantLinear layers"+ @pytest.mark.timeout(90)def test_quantize_with_tuning(self, tiny_mimo_audio_model_path, tmp_path):import transformersdiff --git a/test/unit/test_cuda/models/test_conv1d.py b/test/unit/test_cuda/models/test_conv1d.pyindex bf8ecd8ca..e58a61206 100644--- a/test/unit/test_cuda/models/test_conv1d.py+++ b/test/unit/test_cuda/models/test_conv1d.py@@ -25,6 +25,7 @@ class TestQuantizationConv1d:shutil.rmtree("runs", ignore_errors=True)@require_gptqmodel+ @pytest.mark.timeout(300)def test_quant(self, dataloader):model_name = get_model_path("MBZUAI/LaMini-GPT-124M")model = get_tiny_model(model_name)diff --git a/test/unit/test_cuda/models/test_fp8_model.py b/test/unit/test_cuda/models/test_fp8_model.pyindex f4444ab0a..4c6887fac 100644--- a/test/unit/test_cuda/models/test_fp8_model.py+++ b/test/unit/test_cuda/models/test_fp8_model.py@@ -76,6 +76,7 @@ class TestAutoRound:tokenizer = AutoTokenizer.from_pretrained(quantized_model_path)generate_prompt(model, tokenizer)+ @pytest.mark.timeout(90)def test_gguf_imatrix(self, mock_fp8_capable_device, tiny_fp8_qwen_model_path):ar = AutoRound(tiny_fp8_qwen_model_path, iters=0)_, quantized_model_path = ar.quantize_and_save(format="gguf:q2_k_s", output_dir=self.save_dir)@@ -108,6 +109,7 @@ class TestAutoRound:with patch("torch.cuda.get_device_capability", return_value=DEVICE_CAPABILITY): # revert DEVICE_CAPABILITYevaluate_accuracy(folder, threshold=0.25)+ @pytest.mark.timeout(300)def test_small_model_opt_rtn(self, mock_fp8_capable_device):model_name = get_model_path("Qwen/Qwen3-0.6B-FP8")ar = AutoRound(model=model_name, iters=0)diff --git a/test/unit/test_cuda/models/test_moe_model.py b/test/unit/test_cuda/models/test_moe_model.pyindex 4ccf66256..04c37a319 100644--- a/test/unit/test_cuda/models/test_moe_model.py+++ b/test/unit/test_cuda/models/test_moe_model.py@@ -11,6 +11,7 @@ from auto_round import AutoRound@pytest.mark.skipif(not check_version("transformers>=5.2.0"), reason="requires transformers >= 5.2.0")[email protected](300)def test_qwen3_5_moe(tiny_qwen35_moe_model_path):from transformers import Qwen3_5MoeForConditionalGenerationdiff --git a/test/unit/test_cuda/models/test_omni_model.py b/test/unit/test_cuda/models/test_omni_model.pyindex 04f1cbaf9..85cacee4c 100644--- a/test/unit/test_cuda/models/test_omni_model.py+++ b/test/unit/test_cuda/models/test_omni_model.py@@ -96,6 +96,7 @@ class TestQwen3OmniMoeQuantization:yieldshutil.rmtree(self.save_dir, ignore_errors=True)+ @pytest.mark.timeout(180)def test_quantize_and_reload(self, tiny_qwen3_omni_moe_model_path):"""Quantize, save, reload, verify weights, and run inference."""# Quantizediff --git a/test/unit/test_cuda/quantization/test_asym.py b/test/unit/test_cuda/quantization/test_asym.pyindex 7be120fdd..f305b30ca 100644--- a/test/unit/test_cuda/quantization/test_asym.py+++ b/test/unit/test_cuda/quantization/test_asym.py@@ -24,6 +24,7 @@ class TestAutoRoundAsym:yieldshutil.rmtree("runs", ignore_errors=True)+ @pytest.mark.timeout(120)@pytest.mark.parametrize("group_size", [32, 64, 128])def test_asym_group_size_with_tuning(self, group_size, tiny_opt_model_path):bits, sym = 4, Falsediff --git a/test/unit/test_cuda/quantization/test_mxfp_nvfp.py b/test/unit/test_cuda/quantization/test_mxfp_nvfp.pyindex aade7aa34..dbbcd6300 100644--- a/test/unit/test_cuda/quantization/test_mxfp_nvfp.py+++ b/test/unit/test_cuda/quantization/test_mxfp_nvfp.py@@ -28,6 +28,7 @@ QMODULE_MAPPING = {}[email protected](120)@pytest.mark.parametrize("scheme", testing_schemes)@torch.inference_mode()def test_e2e_quant_and_infer(scheme, tiny_qwen_model_path):diff --git a/test/unit/test_cuda/quantization/test_torch_compile.py b/test/unit/test_cuda/quantization/test_torch_compile.pyindex 0fc4620e9..6c6cd4ecb 100644--- a/test/unit/test_cuda/quantization/test_torch_compile.py+++ b/test/unit/test_cuda/quantization/test_torch_compile.py@@ -27,6 +27,7 @@ class TestTorchCompile:shutil.rmtree("./saved", ignore_errors=True)shutil.rmtree("runs", ignore_errors=True)+ @pytest.mark.skip_ci(reason="torch.compile warmup with iters=2 is slow")@require_ggufdef test_gguf_q2ks_torch_compile(self, dataloader):"""Test GGUF Q2_K_S quantization with torch.compile enabled.@@ -56,6 +57,7 @@ class TestTorchCompile:shutil.rmtree(self.save_dir, ignore_errors=True)@require_gguf+ @pytest.mark.timeout(90)def test_gguf_q2ks_torch_compile_iters0(self, tiny_qwen_model_path):"""Test GGUF Q2_K_S with torch.compile and iters=0 (RTN mode).diff --git a/test/unit/test_cuda/transform/test_mxfp4_transform.py b/test/unit/test_cuda/transform/test_mxfp4_transform.pyindex 631d20c85..0996e2ffa 100644--- a/test/unit/test_cuda/transform/test_mxfp4_transform.py+++ b/test/unit/test_cuda/transform/test_mxfp4_transform.py@@ -26,6 +26,7 @@ class TestAutoRound:shutil.rmtree("./saved", ignore_errors=True)shutil.rmtree("runs", ignore_errors=True)+ @pytest.mark.timeout(120)def test_transform_mxfp4_quant_infer(self):model_name = get_model_path("qwen/Qwen3-0.6B")scheme = "MXFP4"@@ -45,6 +46,7 @@ class TestAutoRound:generate_prompt(model, tokenizer)+ @pytest.mark.timeout(90)def test_transform_mxfp4_tuning_quant_infer(self):model_name = get_model_path("qwen/Qwen3-0.6B")scheme = "MXFP4"@@ -64,6 +66,7 @@ class TestAutoRound:generate_prompt(model, tokenizer)+ @pytest.mark.timeout(90)def test_random_transform_mxfp4_quant_infer(self):model_name = get_model_path("qwen/Qwen3-0.6B")scheme = "MXFP4"diff --git a/test/unit/test_cuda/transform/test_spinquant.py b/test/unit/test_cuda/transform/test_spinquant.pyindex b5d841b6c..2e692c97c 100644--- a/test/unit/test_cuda/transform/test_spinquant.py+++ b/test/unit/test_cuda/transform/test_spinquant.py@@ -303,6 +303,7 @@ class TestPipelineIntegration:yieldshutil.rmtree(self.save_dir, ignore_errors=True)+ @pytest.mark.timeout(180)def test_pipeline_quarot_string(self):"""AutoRound(rotation_config='quarot') should work end-to-end."""model_name = get_model_path("Qwen/Qwen3-0.6B")@@ -319,6 +320,7 @@ class TestPipelineIntegration:tokenizer = AutoTokenizer.from_pretrained(quantized_model_path)generate_prompt(model, tokenizer)+ @pytest.mark.timeout(90)def test_pipeline_spinquant_config(self):"""AutoRound(rotation_config=SpinQuantConfig(...)) should work."""model_name = get_model_path("Qwen/Qwen3-0.6B")@@ -343,6 +345,7 @@ class TestPipelineIntegration:)shutil.rmtree(self.save_dir + "_cfg", ignore_errors=True)+ @pytest.mark.timeout(90)def test_pipeline_dict_config(self):"""AutoRound(rotation_config={...}) should work."""model_name = get_model_path("Qwen/Qwen3-0.6B")diff --git a/test/unit/test_hpu/test_auto_round.py b/test/unit/test_hpu/test_auto_round.pyindex 90850c123..fea794177 100644--- a/test/unit/test_hpu/test_auto_round.py+++ b/test/unit/test_hpu/test_auto_round.py@@ -31,6 +31,7 @@ def run_opt_125m_on_hpu():@pytest.mark.skipif(not is_hpex_available(), reason="HPU is not supported")@pytest.mark.skipif(not is_pytest_mode_lazy(), reason="Only for lazy mode")def test_opt_125m_lazy_mode():run_opt_125m_on_hpu()diff --git a/test/unit/test_hpu/test_quant_fp8.py b/test/unit/test_hpu/test_quant_fp8.pyindex 39f25fa37..274e47905 100644--- a/test/unit/test_hpu/test_quant_fp8.py+++ b/test/unit/test_hpu/test_quant_fp8.py@@ -23,6 +23,7 @@ class TestAutoRound:def check_nan_inf_in_tensor(self, tensor, name=""):return torch.isnan(tensor).any() or torch.isinf(tensor).any()+ @pytest.mark.timeout(120)@pytest.mark.parametrize("model_name", MODEL_LIST)def test_small_model_rtn_generation(self, model_name):ar = AutoRound(model_name, iters=0, scheme="FP8_STATIC", nsamples=16)diff --git a/test/unit/test_hpu/test_static_attn.py b/test/unit/test_hpu/test_static_attn.pyindex 6f2c5cacf..2a06a8a44 100644--- a/test/unit/test_hpu/test_static_attn.py+++ b/test/unit/test_hpu/test_static_attn.py@@ -26,6 +26,7 @@ def setup_deepseekv2():@pytest.mark.skipif(not is_hpex_available(), reason="HPU is not supported")@pytest.mark.skipif(not is_pytest_mode_lazy(), reason="Only for lazy mode")def test_deepseek_v2_on_hpu(setup_deepseekv2):model, tokenizer, output_dir, config = setup_deepseekv2autoround = AutoRound(diff --git a/test/unit/test_xpu/test_autoround.py b/test/unit/test_xpu/test_autoround.pyindex da32e35a6..77f43b127 100644--- a/test/unit/test_xpu/test_autoround.py+++ b/test/unit/test_xpu/test_autoround.py@@ -125,6 +125,7 @@ class TestAutoRoundXPU:shutil.rmtree(quantized_model_path, ignore_errors=True)+ @pytest.mark.timeout(120)def test_vlm_model(self, dataloader):scheme = "W4A16"model_name = get_model_path("Qwen/Qwen2-VL-2B-Instruct")@@ -192,6 +193,7 @@ class TestAutoRoundXPU:)print(output_text[0])+ @pytest.mark.timeout(90)def test_quant_lm_head(self, dataloader):bits, sym, group_size = 4, True, 128# Note that, to save UT tuning time, the local model is intentionally kept lightweight, using only 2 hidden layers.