Skip to content

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

Enable ark CI model test (#1177)

chen, suyue3a55a57a2384
diff --git a/.azure-pipelines/scripts/ut/run_ut_xpu.sh b/.azure-pipelines/scripts/ut/run_ut_xpu.sh
new file mode 100644
index 000000000..2ab0aef64
--- /dev/null
+++ b/.azure-pipelines/scripts/ut/run_ut_xpu.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+set -xe
+
+# install requirements
+echo "##[group]set up UT env..."
+uv pip install pytest-cov pytest-html
+uv pip install -r /auto-round/test/test_ark/requirements.txt \
+ --extra-index-url https://download.pytorch.org/whl/xpu
+
+cd /auto-round && uv pip install .
+echo "##[endgroup]"
+uv pip list
+
+# test ark cpu part only before external xpu available
+cd /auto-round/test/test_ark || exit 1
+find . -type f -exec sed -i '/sys\.path\.insert(0, "\.\.")/d' {} +
+
+export LD_LIBRARY_PATH=${HOME}/.venv/lib/:$LD_LIBRARY_PATH
+export COVERAGE_RCFILE=/auto-round/.azure-pipelines/scripts/ut/.coverage
+auto_round_path=$(python -c 'import auto_round; print(auto_round.__path__[0])')
+
+LOG_DIR=/auto-round/log_dir
+mkdir -p ${LOG_DIR}
+ut_log_name=${LOG_DIR}/ut.log
+
+find . -name "test*.py" | sed "s,\.\/,python -m pytest --cov=\"${auto_round_path}\" --cov-report term --html=report.html --self-contained-html --cov-report xml:coverage.xml --cov-append -vs --disable-warnings ,g" > run.sh
+cat run.sh
+bash run.sh 2>&1 | tee "${ut_log_name}"
+
+if [[ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ]] || [[ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ]] || [[ $(grep -c ' passed' ${ut_log_name}) == 0 ]]; then
+ echo "##[error]Find errors in pytest case, please check the output..."
+ exit 1
+fi
+
+cp .coverage "${LOG_DIR}/.coverage"
+
+echo "UT finished successfully! "
diff --git a/.azure-pipelines/template/ut-template.yml b/.azure-pipelines/template/ut-template.yml
index ba4f21353..7fdb74b45 100644
--- a/.azure-pipelines/template/ut-template.yml
+++ b/.azure-pipelines/template/ut-template.yml
@@ -34,12 +34,19 @@ steps:
- ${{ if eq(parameters.imageSource, 'build') }}:
- script: |
- docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \
- && uv pip install torch==2.8.0 torchvision --index-url https://download.pytorch.org/whl/cpu \
- && uv pip install intel-extension-for-pytorch==2.8.0 \
- && uv pip install -r requirements.txt \
- && uv pip install -r requirements-cpu.txt \
- && uv pip list"
+ if [ "${{ parameters.utScriptFileName }}" == "run_ut_xpu" ];then
+ docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \
+ && uv pip install torch==2.9.0 --index-url https://download.pytorch.org/whl/xpu \
+ && uv pip install -r requirements.txt \
+ && uv pip list"
+ else
+ docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \
+ && uv pip install torch==2.8.0 torchvision --index-url https://download.pytorch.org/whl/cpu \
+ && uv pip install intel-extension-for-pytorch==2.8.0 \
+ && uv pip install -r requirements.txt \
+ && uv pip install -r requirements-cpu.txt \
+ && uv pip list"
+ fi
displayName: "Env Setup"
- ${{ if eq(parameters.imageSource, 'pull') }}:
diff --git a/.azure-pipelines/unit-test-hpu.yml b/.azure-pipelines/unit-test-hpu.yml
index 68fad3fa2..5bc2ab6ae 100644
--- a/.azure-pipelines/unit-test-hpu.yml
+++ b/.azure-pipelines/unit-test-hpu.yml
@@ -10,7 +10,7 @@ pr:
include:
- auto_round
- auto_round_extension
- - test/test*hpu*'
+ - test/test_hpu
- setup.py
- requirements-lib.txt
- .azure-pipelines/scripts/ut
diff --git a/.azure-pipelines/unit-test-xpu.yml b/.azure-pipelines/unit-test-xpu.yml
new file mode 100644
index 000000000..2e7e6c6d4
--- /dev/null
+++ b/.azure-pipelines/unit-test-xpu.yml
@@ -0,0 +1,50 @@
+trigger: none
+
+pr:
+ autoCancel: true
+ drafts: false
+ branches:
+ include:
+ - main
+ paths:
+ include:
+ - auto_round/utils
+ - auto_round_extension/ark
+ - test/test_ark
+ - setup.py
+ - .azure-pipelines/template/ut-template.yml
+ - .azure-pipelines/unit-test-xpu.yml
+ - .azure-pipelines/scripts/ut/run_ut_xpu.sh
+ exclude:
+ - "*.md"
+ - "**/*.md"
+
+# test kernel cpu ut only before public xpu available
+pool: ICX-16C
+
+variables:
+ IMAGE_NAME: "auto-round"
+ IMAGE_TAG: "py312"
+ UPLOAD_PATH: $(Build.SourcesDirectory)/log_dir
+ DOWNLOAD_PATH: $(Build.SourcesDirectory)/log_dir
+ ARTIFACT_NAME: "UT_coverage_report"
+ REPO: $(Build.Repository.Uri)
+
+stages:
+ - stage: Unit_test
+ displayName: Unit Test
+ dependsOn: []
+ jobs:
+ - job:
+ displayName: Unit Test
+ steps:
+ - template: template/ut-template.yml
+ parameters:
+ dockerConfigName: "commonDockerConfig"
+ utScriptFileName: "run_ut_xpu"
+ uploadPath: $(UPLOAD_PATH)
+ utArtifact: "ut"
+
+ - task: PublishCodeCoverageResults@2
+ inputs:
+ summaryFileLocation: $(UPLOAD_PATH)/coverage.xml
diff --git a/.azure-pipelines/unit-test.yml b/.azure-pipelines/unit-test.yml
index d10e47ca7..ff08817e3 100644
--- a/.azure-pipelines/unit-test.yml
+++ b/.azure-pipelines/unit-test.yml
@@ -19,11 +19,15 @@ pr:
- .azure-pipelines/template/ut-template.yml
- .azure-pipelines/template/docker-template.yml
exclude:
- - test/test*hpu*
+ - auto_round_extension/ark
+ - test/test_hpu
+ - test/test_ark
+ - test/test_xpu
- "*.md"
- "**/*.md"
- .azure-pipelines/scripts/ut/run_ut_hpu.sh
- .azure-pipelines/scripts/ut/run_ut_cuda.sh
+ - .azure-pipelines/scripts/ut/run_ut_xpu.sh
pool: ICX-16C
diff --git a/test/test_ark/requirements.txt b/test/test_ark/requirements.txt
new file mode 100644
index 000000000..07605745d
--- /dev/null
+++ b/test/test_ark/requirements.txt
@@ -0,0 +1,2 @@
+auto-round-kernel
+lm-eval
\ No newline at end of file