Skip to content

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

Update CI workflow Infra (#2255)

chen, suyue99d18e78c970
diff --git a/.azure-pipelines/code-scan.yml b/.azure-pipelines/code-scan.yml
deleted file mode 100644
index cb97a6e7b..000000000
--- a/.azure-pipelines/code-scan.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-trigger: none
-
-pr:
- autoCancel: true
- drafts: false
- branches:
- include:
- - main
- paths:
- include:
- - auto_round
- - auto_round_extension
- - setup.py
- - requirements.txt
- - requirements-cpu.txt
- - requirements-hpu.txt
- - .azure-pipelines/code-scan.yml
- - .azure-pipelines/scripts/codeScan
-
-pool:
- vmImage: "ubuntu-latest"
-
-variables:
- CODE_SCAN_LOG_PATH: ".azure-pipelines/scripts/codeScan/scanLog"
-
-stages:
- - stage: PylintCodeScan
- displayName: Pylint Code Scan
- dependsOn: []
- jobs:
- - job: Pylint
- displayName: Pylint
- steps:
- - template: template/code-scan-template.yml
- parameters:
- codeScanFileName: "pylint"
- uploadPath: "pylint.json"
diff --git a/.azure-pipelines/nightly-test-cpu.yml b/.azure-pipelines/nightly-test-cpu.yml
index 466e6f874..2669b80c3 100644
--- a/.azure-pipelines/nightly-test-cpu.yml
+++ b/.azure-pipelines/nightly-test-cpu.yml
@@ -22,8 +22,6 @@ parameters:
- 0
- 1
- 2
- - 3
- - 4
- inc
- llmc
@@ -74,7 +72,6 @@ stages:
steps:
- template: template/ut-template.yml
parameters:
- dockerConfigName: "commonDockerConfig"
utScriptFileName: "run_ut"
uploadPath: $(UPLOAD_PATH)
utArtifact: "ut-$(PART)"
diff --git a/.azure-pipelines/nightly-test-xpu.yml b/.azure-pipelines/nightly-test-xpu.yml
index a8c848041..f03ce2225 100644
--- a/.azure-pipelines/nightly-test-xpu.yml
+++ b/.azure-pipelines/nightly-test-xpu.yml
@@ -72,14 +72,13 @@ stages:
steps:
- template: template/ut-template.yml
parameters:
- dockerConfigName: "commonDockerConfig"
utScriptFileName: "run_ut_xpu"
utTestMode: $(PART)
uploadPath: $(UPLOAD_PATH)
utArtifact: "$(PART)-xpu"
imageTag: $(IMAGE_TAG)
dockerFileName: $(DOCKERFILE_NAME)
- utContainerName: "AutoRoundNightlyXPU$(NODE_LABEL)"
+ utContainerName: "AutoRoundNightly$(NODE_LABEL)"
buildARKWheel: "false"
filterChangedTests: true
diff --git a/.azure-pipelines/performance-test.yaml b/.azure-pipelines/performance-test.yaml
index d4fa3a100..0167820ee 100644
--- a/.azure-pipelines/performance-test.yaml
+++ b/.azure-pipelines/performance-test.yaml
@@ -39,10 +39,36 @@ stages:
scheme: 'FP8_STATIC'
steps:
- - template: template/docker-template.yml
- parameters:
- containerName: $(CONTAINER_NAME)
- imageSource: pull
+ - script: |
+ rm -fr ${BUILD_SOURCESDIRECTORY} || sudo rm -fr ${BUILD_SOURCESDIRECTORY} || true
+ displayName: "Clean workspace"
+
+ - checkout: self
+ clean: true
+ fetchTags: true
+ displayName: "Checkout out Repo"
+
+ - script: |
+ docker pull vault.habana.ai/gaudi-docker/1.24.0/ubuntu24.04/habanalabs/pytorch-installer-2.10.0:latest
+ displayName: "Pull habana docker image"
+
+ - script: |
+ docker stop $(CONTAINER_NAME)
+ docker rm -vf $(CONTAINER_NAME) || true
+ env | sort
+ displayName: "Clean docker container"
+
+ - task: Bash@3
+ inputs:
+ targetType: "inline"
+ script: |
+ docker run -dit --disable-content-trust --privileged --name=$(CONTAINER_NAME) --shm-size="2g" \
+ --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host \
+ -v ${BUILD_SOURCESDIRECTORY}:/auto-round vault.habana.ai/gaudi-docker/1.24.0/ubuntu24.04/habanalabs/pytorch-installer-2.10.0:latest
+ docker exec $(CONTAINER_NAME) bash -c "ln -sf \$(which python3) /usr/bin/python"
+ echo "Show the container list after docker run ... "
+ docker ps -a
+ displayName: "Docker run - $(CONTAINER_NAME) Container"
- script: |
docker exec $(CONTAINER_NAME) bash -c "cd /auto-round \
diff --git a/.azure-pipelines/scripts/codeScan/pylint/pylint.sh b/.azure-pipelines/scripts/codeScan/pylint/pylint.sh
deleted file mode 100644
index 3f3ef3319..000000000
--- a/.azure-pipelines/scripts/codeScan/pylint/pylint.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-
-for var in "$@"
-do
- case $var in
- --scan_module=*)
- scan_module=$(echo $var |cut -f2 -d=)
- ;;
- esac
-done
-
-source /auto-round/.azure-pipelines/scripts/change_color.sh
-RESET="echo -en \\E[0m \\n" # close color
-
-log_dir="/auto-round/.azure-pipelines/scripts/codeScan/scanLog"
-mkdir -p $log_dir
-
-pip install torch --index-url https://download.pytorch.org/whl/cpu
-pip install -r /auto-round/requirements.txt
-pip install -r /auto-round/requirements-cpu.txt
-
-echo "[DEBUG] list pipdeptree..."
-pip install pipdeptree
-pipdeptree
-
-python -m pylint -f json --disable=R,C,W,E0606,E1129 --enable=line-too-long --max-line-length=120 --extension-pkg-whitelist=numpy --ignored-classes=TensorProto,NodeProto \
---ignore-paths='/auto-round/auto_round/export/export_to_gguf/conversion/.*' \
---ignored-modules=tensorflow,keras,torch,torch.quantization,torch.tensor,torchvision,fairseq,mxnet,onnx,onnxruntime,intel_extension_for_pytorch,intel_extension_for_tensorflow,torchinfo,horovod,transformers,deepspeed,deepspeed.module_inject \
-/auto-round/${scan_module} > $log_dir/pylint.json
-
-exit_code=$?
-
-$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------" && $RESET
-cat $log_dir/pylint.json
-$BOLD_YELLOW && echo " ----------------- Current log file output end --------------------------" && $RESET
-
-if [ ${exit_code} -ne 0 ]; then
- $BOLD_RED && echo "Error!! Please Click on the artifact button to download and view Pylint error details." && $RESET
- exit 1
-fi
-$BOLD_PURPLE && echo "Congratulations, Pylint check passed!" && $LIGHT_PURPLE && echo " You can click on the artifact button to see the log details." && $RESET
-exit 0
diff --git a/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.sh b/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.sh
index 2e08c6a9e..16919c629 100644
--- a/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.sh
+++ b/.azure-pipelines/scripts/cuda_unit_test/run_cuda_ut.sh
@@ -75,6 +75,16 @@ function setup_basic_test_env() {
cd "${BUILD_SOURCESDIRECTORY}/test" || exit 1
}
+function run_pytest() {
+ local test_case=$1
+ local ut_log_name=$2
+
+ echo "##[group]Running ${test_case}..."
+ pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
+ --junitxml="${ut_log_name%.log}.xml" ${test_case} 2>&1 | tee ${ut_log_name}
+ echo "##[endgroup]"
+}
+
function run_common_group() {
# Run a group of common test files together in a single pytest invocation.
# $1: group name (used for log file), remaining args: test files
@@ -84,13 +94,8 @@ function run_common_group() {
group_tests=$(filter_changed_tests "test" "$*")
if [ -n "${group_tests}" ]; then
- echo "##[group]Running common tests (${group_name})..."
local ut_log_name="${LOG_DIR}/unittest_cuda_common_${group_name}.log"
- pytest -m "not skip_ci" \
- --cov=auto_round --cov-report= --cov-append \
- -vs --junitxml="${ut_log_name%.log}.xml" \
- ${group_tests} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${group_tests}" "${ut_log_name}"
fi
}
@@ -134,14 +139,9 @@ function run_unit_test() {
fi
for test_file in ${selected_files}; do
- echo "##[group]Running ${test_file}..."
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= -vs --junitxml="${ut_log_name%.log}.xml" \
- ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -163,14 +163,9 @@ function run_unit_test_llmc() {
cd "${BUILD_SOURCESDIRECTORY}/test" || exit 1
for test_file in $(find ./integration/test_cuda -name "test_llmc*.py" | sort); do
- 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 \
- --junitxml="${ut_log_name%.log}.xml" \
- ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -193,14 +188,9 @@ function run_unit_test_sglang() {
cd "${BUILD_SOURCESDIRECTORY}/test" || exit 1
for test_file in $(find ./integration/test_cuda ./e2e/test_cuda -name "test_sglang*.py" | sort); do
- 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 \
- --junitxml="${ut_log_name%.log}.xml" \
- ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -223,14 +213,9 @@ function run_unit_test_vllm() {
cd "${BUILD_SOURCESDIRECTORY}/test" || exit 1
for test_file in $(find ./integration/test_cuda ./e2e/test_cuda -name "test_vllm*.py" | sort); do
- 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 \
- --junitxml="${ut_log_name%.log}.xml" \
- ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
diff --git a/.azure-pipelines/scripts/ut/run_ut.sh b/.azure-pipelines/scripts/ut/run_ut.sh
index 40b39869a..a4fb47eed 100644
--- a/.azure-pipelines/scripts/ut/run_ut.sh
+++ b/.azure-pipelines/scripts/ut/run_ut.sh
@@ -56,6 +56,17 @@ function check_storage_usage() {
echo "##[endgroup]"
}
+function run_pytest() {
+ local test_case=$1
+ local ut_log_name=$2
+
+ echo "##[group]Running ${test_case}..."
+ numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" \
+ pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
+ --junitxml="${ut_log_name%.log}.xml" ${test_case} 2>&1 | tee ${ut_log_name}
+ echo "##[endgroup]"
+}
+
function run_common_group() {
# Run a group of common test files together in a single pytest invocation.
# $1: group name (used for log file), remaining args: test files
@@ -65,12 +76,8 @@ function run_common_group() {
group_tests=$(filter_changed_tests "test" "$*")
if [ -n "${group_tests}" ]; then
- echo "##[group]Running common tests (${group_name})..."
local ut_log_name="${LOG_DIR}/unittest_test_common_${group_name}.log"
- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \
- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
- --junitxml="${ut_log_name%.log}.xml" ${group_tests} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${group_tests}" "${ut_log_name}"
fi
}
@@ -99,7 +106,7 @@ function run_unit_test() {
# run in the nightly pipelines (see nightly-test.yml).
find ./unit/test_cpu -name "test*.py" | sort > all_tests.txt
total_lines=$(wc -l < all_tests.txt)
- NUM_CHUNKS=4
+ NUM_CHUNKS=2
q=$(( total_lines / NUM_CHUNKS ))
r=$(( total_lines % NUM_CHUNKS ))
if [ "$test_part" -le "$r" ]; then
@@ -119,15 +126,9 @@ function run_unit_test() {
fi
for test_file in ${selected_files}; do
- echo "##[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 -m "not skip_ci" \
- --cov=auto_round --cov-report= --cov-append \
- -vs --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -147,14 +148,9 @@ function run_inc_unit_test() {
cd /auto-round/test/integration || exit 1
for test_file in ${selected_files}; do
- echo "##[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 \
- -vs --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -176,14 +172,9 @@ function run_llmc_unit_test() {
cd /auto-round/test/integration || exit 1
for test_file in ${selected_files}; do
- echo "##[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 \
- -vs --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
diff --git a/.azure-pipelines/scripts/ut/run_ut_xpu.sh b/.azure-pipelines/scripts/ut/run_ut_xpu.sh
index 72ec2149a..bb378955d 100644
--- a/.azure-pipelines/scripts/ut/run_ut_xpu.sh
+++ b/.azure-pipelines/scripts/ut/run_ut_xpu.sh
@@ -1,6 +1,8 @@
#!/bin/bash
set -e
+test_part=${UT_MODE}
+
source /auto-round/.azure-pipelines/scripts/change_color.sh
source /auto-round/.azure-pipelines/scripts/ut/detect_changed_tests.sh
@@ -42,6 +44,17 @@ function setup_environment() {
SUMMARY_LOG="${LOG_DIR}/results_summary.log"
}
+function run_pytest() {
+ local test_case=$1
+ local ut_log_name=$2
+
+ echo "##[group]Running ${test_case}..."
+ numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \
+ pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
+ --junitxml="${ut_log_name%.log}.xml" ${test_case} 2>&1 | tee ${ut_log_name}
+ echo "##[endgroup]"
+}
+
function run_common_group() {
# Run a group of common test files together in a single pytest invocation.
# $1: group name (used for log file), remaining args: test files
@@ -51,12 +64,8 @@ function run_common_group() {
group_tests=$(filter_changed_tests "test" "$*")
if [ -n "${group_tests}" ]; then
- echo "##[group]Running common tests (${group_name})..."
local ut_log_name="${LOG_DIR}/unittest_common_${group_name}.log"
- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \
- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
- --junitxml="${ut_log_name%.log}.xml" ${group_tests} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${group_tests}" "${ut_log_name}"
fi
}
@@ -81,13 +90,8 @@ function run_unit_test() {
for test_file in ${xpu_tests}; do
local test_basename=$(basename ${test_file} .py)
-
- echo "##[group]Running xpu ${test_file}..."
local ut_log_name="${LOG_DIR}/unittest_${test_basename}.log"
- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \
- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
- --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -97,13 +101,8 @@ function run_unit_test_ark() {
for test_file in ${ark_tests}; do
local test_basename=$(basename ${test_file} .py)
-
- echo "##[group]Running ark ${test_file}..."
local ut_log_name="${LOG_DIR}/unittest_${test_basename}.log"
- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \
- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
- --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -122,13 +121,8 @@ function run_unit_test_llmc() {
for test_file in ${llmc_tests}; do
local test_basename=$(basename ${test_file} .py)
-
- echo "##[group]Running xpu llmc ${test_file}..."
local ut_log_name="${LOG_DIR}/unittest_${test_basename}.log"
- numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" \
- pytest -m "not skip_ci" --cov=auto_round --cov-report= --cov-append -vs \
- --junitxml="${ut_log_name%.log}.xml" ${test_file} 2>&1 | tee ${ut_log_name}
- echo "##[endgroup]"
+ run_pytest "${test_file}" "${ut_log_name}"
done
}
@@ -142,12 +136,8 @@ function collect_log() {
python /auto-round/.azure-pipelines/scripts/ut/collect_result.py \
--test-type "Unit Tests" --log-pattern "unittest_*.log" --log-dir ${LOG_DIR} --summary-log ${SUMMARY_LOG}
if [ -f .coverage ]; then
- cp .coverage "${LOG_DIR}/.coverage"
- python -m coverage xml -o "${LOG_DIR}/coverage.xml"
- python -m coverage html -d "${LOG_DIR}/htmlcov"
- else
- echo "No coverage data (no test selected), skip coverage report."
- echo "##vso[task.setvariable variable=HAS_COVERAGE]false"
+ # Use a per-part name so the Coverage stage's `ut-*/.coverage.*` pattern matches.
+ cp .coverage "${LOG_DIR}/.coverage.part${test_part}"
fi
}
@@ -161,12 +151,13 @@ function main() {
setup_environment
init_changed_tests
scope_changed_tests "$(cd /auto-round && find test/unit/common test/unit/test_ark test/unit/test_xpu test/integration/test_xpu -name "test_*.py" 2>/dev/null)"
- if [[ "${UT_MODE}" == "llmc" ]]; then
+ if [[ "$test_part" == "llmc" ]]; then
run_unit_test_llmc
- elif [[ "${UT_MODE}" == "ark" ]]; then
+ elif [[ "$test_part" == "ark" ]]; then
run_unit_test_ark
- else
+ elif [[ "$test_part" == "0" ]]; then
run_common_unit_test
+ else
run_unit_test
fi
collect_log
diff --git a/.azure-pipelines/template/code-scan-template.yml b/.azure-pipelines/template/code-scan-template.yml
deleted file mode 100644
index 724454df6..000000000
--- a/.azure-pipelines/template/code-scan-template.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-parameters:
- - name: codeScanFileName
- type: string
- - name: uploadPath
- type: string
-
- - name: codeScanContainerName
- type: string
- default: "codeScan"
- - name: scanModule
- type: string
- default: "auto_round"
-
-steps:
- - template: docker-template.yml
- parameters:
- dockerConfigName: "commonDockerConfig"
- repoName: "code-scan"
- repoTag: "1.0"
- dockerFileName: "DockerfileCodeScan"
- containerName: ${{ parameters.codeScanContainerName }}
-
- - script: |
- docker exec ${{ parameters.codeScanContainerName }} bash -c "bash /auto-round/.azure-pipelines/scripts/codeScan/${{ parameters.codeScanFileName }}/${{ parameters.codeScanFileName }}.sh \
- --scan_module=${{ parameters.scanModule }}"
- displayName: "${{ parameters.codeScanFileName }} Check"
-
- - task: PublishPipelineArtifact@1
- condition: succeededOrFailed()
- inputs:
- targetPath: .azure-pipelines/scripts/codeScan/scanLog/${{ parameters.uploadPath }}
- artifact: ${{ parameters.codeScanFileName }}
- publishLocation: "pipeline"
- displayName: "PublishPipelineArtifact"
-
- - task: Bash@3
- condition: always()
- inputs:
- targetType: "inline"
- script: |
- docker exec ${{ parameters.codeScanContainerName }} bash -c "rm -fr /auto-round/* && rm -fr /auto-round/.* || true"
- displayName: "Docker clean up"
diff --git a/.azure-pipelines/template/docker-template.yml b/.azure-pipelines/template/docker-template.yml
index db6003c87..fba6d19f9 100644
--- a/.azure-pipelines/template/docker-template.yml
+++ b/.azure-pipelines/template/docker-template.yml
@@ -1,7 +1,4 @@
parameters:
- - name: dockerConfigName
- type: string
- default: "commonDockerConfig"
- name: repoName
type: string
default: "auto-round"
@@ -16,79 +13,41 @@ parameters:
- name: repo
type: string
default: "https://github.com/intel/auto-round"
- - name: imageSource
- type: string
- default: "build"
steps:
- - task: Bash@3
- inputs:
- targetType: "inline"
- script: |
- docker ps -a
- if [[ $(docker ps -a | grep -i '${{ parameters.containerName }}'$) ]]; then
- docker start ${{ parameters.containerName }}
- echo "remove left files through container ..."
- docker exec ${{ parameters.containerName }} bash -c "ls -a /auto-round && rm -fr /auto-round/* && rm -fr /auto-round/.* && ls -a /auto-round || true"
- fi
- displayName: "Docker clean up"
-
- - ${{ if eq(parameters.dockerConfigName, 'commonDockerConfig') }}:
- - script: |
- rm -fr ${BUILD_SOURCESDIRECTORY} || sudo rm -fr ${BUILD_SOURCESDIRECTORY} || true
- displayName: "Clean workspace"
-
- - checkout: self
- clean: true
- fetchTags: true
- displayName: "Checkout out Repo"
-
- - ${{ if eq(parameters.dockerConfigName, 'gitCloneDockerConfig') }}:
- - script: |
- rm -fr ${BUILD_SOURCESDIRECTORY} || sudo rm -fr ${BUILD_SOURCESDIRECTORY} || true
- mkdir ${BUILD_SOURCESDIRECTORY}
- chmod 777 ${BUILD_SOURCESDIRECTORY}
- displayName: "Clean workspace"
-
- - checkout: none
-
- - script: |
- git clone ${{ parameters.repo }} ${BUILD_SOURCESDIRECTORY}
- git config --global --add safe.directory ${BUILD_SOURCESDIRECTORY}
- cd ${BUILD_SOURCESDIRECTORY}
- git checkout main
- displayName: "Checkout out main"
+ - script: |
+ rm -fr ${BUILD_SOURCESDIRECTORY} || sudo rm -fr ${BUILD_SOURCESDIRECTORY} || true
+ displayName: "Clean workspace"
- - ${{ if eq(parameters.imageSource, 'build') }}:
- - script: |
- set -eo pipefail
-
- docker image prune -f || true
- IMAGE="${{ parameters.repoName }}:${{ parameters.repoTag }}"
- DOCKERFILE="${BUILD_SOURCESDIRECTORY}/.azure-pipelines/docker/${{parameters.dockerFileName}}.devel"
- CURRENT_HASH=$(md5sum "$DOCKERFILE" | awk '{print $1}')
- NEED_BUILD=false
- if [[ ! $(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -Fx "$IMAGE") ]]; then
- NEED_BUILD=true
- else
- EXISTING_HASH=$(docker inspect --format='{{index .Config.Labels "dockerfile.hash"}}' "$IMAGE" 2>/dev/null || echo "")
- if [[ "$CURRENT_HASH" != "$EXISTING_HASH" ]]; then
- echo "Dockerfile changed (old=$EXISTING_HASH, new=$CURRENT_HASH), rebuilding image..."
- NEED_BUILD=true
- fi
- fi
- if [[ "$NEED_BUILD" == "true" ]]; then
- docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) \
- --label "dockerfile.hash=$CURRENT_HASH" \
- -f "$DOCKERFILE" -t $IMAGE .
- fi
- docker images | grep -i ${{ parameters.repoName }}
- displayName: "Build develop docker image"
+ - checkout: self
+ clean: true
+ fetchTags: true
+ displayName: "Checkout out Repo"
- - ${{ if eq(parameters.imageSource, 'pull') }}:
- - script: |
- docker pull vault.habana.ai/gaudi-docker/1.24.0/ubuntu24.04/habanalabs/pytorch-installer-2.10.0:latest
- displayName: "Pull habana docker image"
+ - script: |
+ set -eo pipefail
+
+ docker image prune -f || true
+ IMAGE="${{ parameters.repoName }}:${{ parameters.repoTag }}"
+ DOCKERFILE="${BUILD_SOURCESDIRECTORY}/.azure-pipelines/docker/${{parameters.dockerFileName}}.devel"
+ CURRENT_HASH=$(md5sum "$DOCKERFILE" | awk '{print $1}')
+ NEED_BUILD=false
+ if [[ ! $(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -Fx "$IMAGE") ]]; then
+ NEED_BUILD=true
+ else
+ EXISTING_HASH=$(docker inspect --format='{{index .Config.Labels "dockerfile.hash"}}' "$IMAGE" 2>/dev/null || echo "")
+ if [[ "$CURRENT_HASH" != "$EXISTING_HASH" ]]; then
+ echo "Dockerfile changed (old=$EXISTING_HASH, new=$CURRENT_HASH), rebuilding image..."
+ NEED_BUILD=true
+ fi
+ fi
+ if [[ "$NEED_BUILD" == "true" ]]; then
+ docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) \
+ --label "dockerfile.hash=$CURRENT_HASH" \
+ -f "$DOCKERFILE" -t $IMAGE .
+ fi
+ docker images | grep -i ${{ parameters.repoName }}
+ displayName: "Build develop docker image"
- script: |
docker stop ${{ parameters.containerName }}
@@ -101,16 +60,9 @@ steps:
inputs:
targetType: "inline"
script: |
- if [[ "${{ parameters.imageSource }}" == "build" ]]; then
- docker run -dit --disable-content-trust --privileged --name=${{ parameters.containerName }} --shm-size="2g" \
- -v ${BUILD_SOURCESDIRECTORY}:/auto-round -v /tf_dataset:/tf_dataset -v /tf_dataset2:/tf_dataset2 \
- ${{ parameters.repoName }}:${{ parameters.repoTag }}
- else
- docker run -dit --disable-content-trust --privileged --name=${{ parameters.containerName }} --shm-size="2g" \
- --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host \
- -v ${BUILD_SOURCESDIRECTORY}:/auto-round vault.habana.ai/gaudi-docker/1.24.0/ubuntu24.04/habanalabs/pytorch-installer-2.10.0:latest
- docker exec ${{ parameters.containerName }} bash -c "ln -sf \$(which python3) /usr/bin/python"
- fi
+ docker run -dit --disable-content-trust --privileged --name=${{ parameters.containerName }} --shm-size="2g" \
+ -v ${BUILD_SOURCESDIRECTORY}:/auto-round -v /tf_dataset:/tf_dataset -v /tf_dataset2:/tf_dataset2 \
+ ${{ parameters.repoName }}:${{ parameters.repoTag }}
echo "Show the container list after docker run ... "
docker ps -a
displayName: "Docker run - ${{ parameters.containerName }} Container"
diff --git a/.azure-pipelines/template/ut-template.yml b/.azure-pipelines/template/ut-template.yml
index 0c87ce50b..abb98884d 100644
--- a/.azure-pipelines/template/ut-template.yml
+++ b/.azure-pipelines/template/ut-template.yml
@@ -1,7 +1,4 @@
parameters:
- - name: dockerConfigName
- type: string
- default: "commonDockerConfig"
- name: repo
type: string
default: "https://github.com/intel/auto-round"
@@ -17,9 +14,6 @@ parameters:
- name: utContainerName
type: string
default: "AutoRoundUnitTest"
- - name: imageSource
- type: string
- default: "build"
- name: imageName
type: string
default: "auto-round"
@@ -42,13 +36,11 @@ parameters:
steps:
- template: docker-template.yml
parameters:
- dockerConfigName: ${{ parameters.dockerConfigName }}
repoName: ${{ parameters.imageName }}
repoTag: ${{ parameters.imageTag }}
dockerFileName: ${{ parameters.dockerFileName }}
containerName: ${{ parameters.utContainerName }}
repo: ${{ parameters.repo }}
- imageSource: ${{ parameters.imageSource }}
- task: DownloadPipelineArtifact@2
condition: and(succeeded(), eq(variables['BUILD_ARK_WHEEL'], 'true'))
@@ -58,49 +50,36 @@ steps:
path: $(Build.SourcesDirectory)/ark_wheel
displayName: "Download ark wheel"
- - ${{ if eq(parameters.imageSource, 'build') }}:
- - script: |
- set -eo pipefail
-
- if [ "${{ parameters.buildARKWheel }}" == "true" ]; then
- ARK_WHEEL_INSTALL="uv pip install /auto-round/ark_wheel/*.whl --no-deps"
- else
- ARK_WHEEL_INSTALL="uv pip install --index-url https://test.pypi.org/simple/ auto-round-lib --pre --no-deps"
- fi
-
- if [ "${{ parameters.utScriptFileName }}" == "run_ut_xpu" ];then
- docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \
- && uv pip install -r .azure-pipelines/scripts/ut/constraints.txt --extra-index-url https://download.pytorch.org/whl/xpu \
- && uv pip install -r auto_round_extension/ark/requirements.txt \
- && ${ARK_WHEEL_INSTALL} \
- && uv pip install -r requirements.txt \
- && uv pip install -r test/unit/test_ark/requirements.txt \
- && uv pip install -r test/unit/test_xpu/requirements.txt --extra-index-url https://download.pytorch.org/whl/xpu \
- && cd /auto-round && uv pip install . \
- && uv pip list"
- else
- docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \
- && uv pip install -r .azure-pipelines/scripts/ut/constraints.txt --extra-index-url https://download.pytorch.org/whl/cpu \
- && uv pip install -r auto_round_extension/ark/requirements.txt \
- && ${ARK_WHEEL_INSTALL} \
- && uv pip install -r requirements.txt \
- && uv pip install -r requirements-cpu.txt \
- && uv pip install -r test/unit/test_cpu/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu \
- && uv pip list"
- fi
- displayName: "Env Setup"
+ - script: |
+ set -eo pipefail
- - ${{ if eq(parameters.imageSource, 'pull') }}:
- - script: |
- set -eo pipefail
+ if [ "${{ parameters.buildARKWheel }}" == "true" ]; then
+ ARK_WHEEL_INSTALL="uv pip install /auto-round/ark_wheel/*.whl --no-deps"
+ else
+ ARK_WHEEL_INSTALL="uv pip install --index-url https://test.pypi.org/simple/ auto-round-lib --pre --no-deps"
+ fi
+ if [ "${{ parameters.utScriptFileName }}" == "run_ut_xpu" ];then
+ docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \
+ && uv pip install -r .azure-pipelines/scripts/ut/constraints.txt --extra-index-url https://download.pytorch.org/whl/xpu \
+ && uv pip install -r auto_round_extension/ark/requirements.txt \
+ && ${ARK_WHEEL_INSTALL} \
+ && uv pip install -r requirements.txt \
+ && uv pip install -r test/unit/test_ark/requirements.txt \
+ && uv pip install -r test/unit/test_xpu/requirements.txt --extra-index-url https://download.pytorch.org/whl/xpu \
+ && cd /auto-round && uv pip install . \
+ && uv pip list"
+ else
docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \
- && pip install build \
- && BUILD_HPU_ONLY=1 python -m build \
- && pip install dist/*.whl \
- && pip install -r test/unit/test_hpu/requirements.txt \
- && pip list"
- displayName: "HPU Env Setup"
+ && uv pip install -r .azure-pipelines/scripts/ut/constraints.txt --extra-index-url https://download.pytorch.org/whl/cpu \
+ && uv pip install -r auto_round_extension/ark/requirements.txt \
+ && ${ARK_WHEEL_INSTALL} \
+ && uv pip install -r requirements.txt \
+ && uv pip install -r requirements-cpu.txt \
+ && uv pip install -r test/unit/test_cpu/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu \
+ && uv pip list"
+ fi
+ displayName: "Env Setup"
- script: |
set -eo pipefail
diff --git a/.azure-pipelines/unit-test-hpu.yml b/.azure-pipelines/unit-test-hpu.yml
index dd07f78dc..d658cbfe3 100644
--- a/.azure-pipelines/unit-test-hpu.yml
+++ b/.azure-pipelines/unit-test-hpu.yml
@@ -15,8 +15,7 @@ pr:
- requirements-hpu.txt
- .azure-pipelines/scripts/ut/run_ut_hpu.sh
- .azure-pipelines/scripts/ut/detect_changed_tests.sh
- - .azure-pipelines/template/docker-template.yml
- - .azure-pipelines/template/ut-template.yml
+ - .azure-pipelines/unit-test-hpu.yml
exclude:
- auto_round/export/export_to_autogptq
- auto_round/export/export_to_awq
@@ -40,14 +39,86 @@ stages:
- job:
displayName: Unit Test
steps:
- - template: template/ut-template.yml
- parameters:
- imageSource: "pull"
- dockerConfigName: "commonDockerConfig"
- utScriptFileName: "run_ut_hpu"
- uploadPath: $(UPLOAD_PATH)
- utArtifact: "ut"
- filterChangedTests: true
+ - script: |
+ rm -fr ${BUILD_SOURCESDIRECTORY} || sudo rm -fr ${BUILD_SOURCESDIRECTORY} || true
+ displayName: "Clean workspace"
+
+ - checkout: self
+ clean: true
+ fetchTags: true
+ displayName: "Checkout out Repo"
+
+ - script: |
+ docker pull vault.habana.ai/gaudi-docker/1.24.0/ubuntu24.04/habanalabs/pytorch-installer-2.10.0:latest
+ displayName: "Pull habana docker image"
+
+ - script: |
+ docker stop AutoRoundUnitTest
+ docker rm -vf AutoRoundUnitTest || true
+ env | sort
+ displayName: "Clean docker container"
+
+ - task: Bash@3
+ inputs:
+ targetType: "inline"
+ script: |
+ docker run -dit --disable-content-trust --privileged --name=AutoRoundUnitTest --shm-size="2g" \
+ --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host \
+ -v ${BUILD_SOURCESDIRECTORY}:/auto-round vault.habana.ai/gaudi-docker/1.24.0/ubuntu24.04/habanalabs/pytorch-installer-2.10.0:latest
+ docker exec AutoRoundUnitTest bash -c "ln -sf \$(which python3) /usr/bin/python"
+ echo "Show the container list after docker run ... "
+ docker ps -a
+ displayName: "Docker run - AutoRoundUnitTest Container"
+
+ - script: |
+ set -eo pipefail
+
+ docker exec AutoRoundUnitTest bash -c "cd /auto-round \
+ && pip install build \
+ && BUILD_HPU_ONLY=1 python -m build \
+ && pip install dist/*.whl \
+ && pip install -r test/unit/test_hpu/requirements.txt \
+ && pip list"
+ displayName: "HPU Env Setup"
+
+ - script: |
+ set -eo pipefail
+
+ docker exec -e NUMA_NODE=${NUMA_NODE} \
+ -e NUMA_CPUSET=${NUMA_CPUSET} \
+ -e ZE_AFFINITY_MASK=${ZE_AFFINITY_MASK} \
+ -e UT_MODE=coverage \
+ -e BUILD_REASON=${BUILD_REASON} \
+ -e SYSTEM_PULLREQUEST_TARGETBRANCH=${SYSTEM_PULLREQUEST_TARGETBRANCH} \
+ -e FILTER_CHANGED_TESTS=true \
+ AutoRoundUnitTest \
+ bash -c "cd /auto-round/.azure-pipelines/scripts && bash ut/run_ut_hpu.sh"
+ displayName: "Run UT"
+
+ - task: PublishPipelineArtifact@1
+ condition: succeeded()
+ inputs:
+ targetPath: $(UPLOAD_PATH)
+ artifact: ut_coverage
+ publishLocation: "pipeline"
+ displayName: "Publish UT coverage artifact"
+
+ - task: PublishPipelineArtifact@1
+ condition: failed()
+ inputs:
+ targetPath: $(UPLOAD_PATH)
+ artifact: "ut-$(System.JobAttempt)"
+ publishLocation: "pipeline"
+ displayName: "Publish UT logs for debugging"
+
+ - task: Bash@3
+ condition: always()
+ inputs:
+ targetType: "inline"
+ script: |
+ docker stop AutoRoundUnitTest
+ docker rm -vf AutoRoundUnitTest || true
+ displayName: "Docker clean up"
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 7.0.x'
diff --git a/.azure-pipelines/unit-test-xpu.yml b/.azure-pipelines/unit-test-xpu.yml
index 29acaf623..62a8f315d 100644
--- a/.azure-pipelines/unit-test-xpu.yml
+++ b/.azure-pipelines/unit-test-xpu.yml
@@ -12,6 +12,7 @@ pr:
- auto_round_extension
- test/unit/test_ark
- test/unit/test_xpu
+ - test/unit/common
- setup.py
- .azure-pipelines/template/ut-template.yml
- .azure-pipelines/unit-test-xpu.yml
@@ -36,6 +37,13 @@ variables:
ARTIFACT_NAME: "UT_coverage_report"
REPO: $(Build.Repository.Uri)
+parameters:
+ - name: unitTestParts
+ type: object
+ default:
+ - 0
+ - 1
+
stages:
- template: template/lib-build-template.yml
parameters:
@@ -50,26 +58,66 @@ stages:
BUILD_ARK_WHEEL: $[ stageDependencies.DetectArkChanges.Detect.outputs['SetArkWheelFlag.BUILD_ARK_WHEEL'] ]
jobs:
- job:
- displayName: Unit Test
+ timeoutInMinutes: 60
+ strategy:
+ matrix:
+ ${{ each part in parameters.unitTestParts }}:
+ part_${{ part }}:
+ PART: ${{ part }}
steps:
- template: template/ut-template.yml
parameters:
- dockerConfigName: "commonDockerConfig"
utScriptFileName: "run_ut_xpu"
uploadPath: $(UPLOAD_PATH)
- utArtifact: "ut"
+ utArtifact: "ut-$(PART)"
+ utTestMode: $(PART)
imageTag: $(IMAGE_TAG)
dockerFileName: $(DOCKERFILE_NAME)
utContainerName: "AutoRoundUnitTest$(NODE_LABEL)"
buildARKWheel: $(BUILD_ARK_WHEEL)
filterChangedTests: true
- - task: UseDotNet@2
- displayName: 'Use .NET Core sdk 7.0.x'
+ - stage: Coverage
+ displayName: "Collect Coverage"
+ pool:
+ vmImage: "ubuntu-latest"
+ dependsOn: [Unit_test]
+ jobs:
+ - job: CollectDatafiles
+ steps:
+ - task: DownloadPipelineArtifact@2
+ inputs:
+ artifact:
+ patterns: '*_coverage/.coverage.*'
+ path: $(DOWNLOAD_PATH)
+
+ - task: UsePythonVersion@0
+ inputs:
+ versionSpec: '3.12'
+ displayName: 'Use Python 3.12'
+
+ - script: |
+ cd ${BUILD_SOURCESDIRECTORY}
+ pip install -U pip setuptools uv
+ uv pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/xpu
+ uv pip install .
+ pip list
+ cd ${BUILD_SOURCESDIRECTORY}/.azure-pipelines/scripts
+ bash ut/collect_log.sh
+ env:
+ PYTHONUNBUFFERED: '1'
+ UV_NO_PROGRESS: '1'
+ UV_SYSTEM_PYTHON: '1'
+ displayName: "Collect UT Coverage"
+
+ - task: PublishPipelineArtifact@1
+ condition: succeededOrFailed()
inputs:
- version: 7.0.x
+ targetPath: $(UPLOAD_PATH)/coverage_PR
+ artifact: $(ARTIFACT_NAME)
+ publishLocation: "pipeline"
- task: PublishCodeCoverageResults@2
- condition: ne(variables['HAS_COVERAGE'], 'false')
inputs:
- summaryFileLocation: $(UPLOAD_PATH)/coverage.xml
+ summaryFileLocation: $(Build.SourcesDirectory)/log_dir/coverage_PR/coverage.xml
+
diff --git a/.azure-pipelines/unit-test.yml b/.azure-pipelines/unit-test.yml
index fe3645954..f4ba71487 100644
--- a/.azure-pipelines/unit-test.yml
+++ b/.azure-pipelines/unit-test.yml
@@ -52,8 +52,6 @@ parameters:
- 0
- 1
- 2
- - 3
- - 4
stages:
- template: template/lib-build-template.yml
@@ -77,7 +75,6 @@ stages:
steps:
- template: template/ut-template.yml
parameters:
- dockerConfigName: "commonDockerConfig"
utScriptFileName: "run_ut"
uploadPath: $(UPLOAD_PATH)
utArtifact: "ut-$(PART)"