PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
[CI] Update python to 3.12 and torch to 2.8.0 (#741)
Sun, Xuehao268f7dda2d7c
diff --git a/.azure-pipelines/code-scan.yml b/.azure-pipelines/code-scan.ymlindex 43dac1db6..7e2f24002 100644--- a/.azure-pipelines/code-scan.yml+++ b/.azure-pipelines/code-scan.yml@@ -9,8 +9,11 @@ pr:paths:include:- auto_round+ - auto_round_extension- setup.py- requirements.txt+ - requirements-cpu.txt+ - requirements-lib.txt- .azure-pipelines/code-scan.yml- .azure-pipelines/scripts/codeScandiff --git a/.azure-pipelines/docker/Dockerfile.devel b/.azure-pipelines/docker/Dockerfile.develindex 397dfeeab..d0ecbfb8c 100644--- a/.azure-pipelines/docker/Dockerfile.devel+++ b/.azure-pipelines/docker/Dockerfile.devel@@ -12,8 +12,8 @@# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.-ARG UBUNTU_VER=22.04-FROM ubuntu:${UBUNTU_VER} as devel+ARG UBUNTU_VER=24.04+FROM ubuntu:${UBUNTU_VER}# See http://bugs.python.org/issue19846ENV LANG C.UTF-8@@ -21,13 +21,11 @@ ENV LANG C.UTF-8RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \python3 \python3-pip \- python3-dev \- python3-distutils \+ python3.12-dev \autoconf \build-essential \git \- libgl1-mesa-glx \- libglib2.0-0 \+ libomp-dev \numactl \time \wget \@@ -45,10 +43,9 @@ RUN groupadd -g ${GROUP_ID} hostgroup && \USER hostuser-ENV PATH="/home/hostuser/.local/bin:${PATH}"-RUN python -m pip install --no-cache-dir --upgrade pip-RUN python -m pip install --no-cache-dir setuptools-+ENV PATH="/home/hostuser/.local/bin:$PATH"+RUN pip config set global.break-system-packages true+RUN python -m pip install --no-cache-dir --upgrade pip setuptoolsRUN pip listWORKDIR /diff --git a/.azure-pipelines/docker/DockerfileCodeScan.devel b/.azure-pipelines/docker/DockerfileCodeScan.develindex 7944cea1d..acf0cad76 100644--- a/.azure-pipelines/docker/DockerfileCodeScan.devel+++ b/.azure-pipelines/docker/DockerfileCodeScan.devel@@ -13,7 +13,7 @@# See the License for the specific language governing permissions and# limitations under the License.-ARG UBUNTU_VER=22.04+ARG UBUNTU_VER=24.04FROM ubuntu:${UBUNTU_VER} as devel# See http://bugs.python.org/issue19846@@ -24,8 +24,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \aspell-en \python3 \python3-pip \- python3-dev \- python3-distutils \autoconf \build-essential \wget@@ -40,9 +38,8 @@ RUN groupadd -g ${GROUP_ID} hostgroup && \USER hostuser-ENV PATH="/home/hostuser/.local/bin:${PATH}"-RUN python -m pip install --no-cache-dir --upgrade pip-RUN python -m pip install --no-cache-dir pylint==2.12.1\- bandit+ENV PATH="/home/hostuser/.local/bin:$PATH"+RUN pip config set global.break-system-packages true+RUN python -m pip install --no-cache-dir pylint banditWORKDIR /diff --git a/.azure-pipelines/scripts/codeScan/pylint/pylint.sh b/.azure-pipelines/scripts/codeScan/pylint/pylint.shindex 7fb4d813d..21a1a052d 100644--- a/.azure-pipelines/scripts/codeScan/pylint/pylint.sh+++ b/.azure-pipelines/scripts/codeScan/pylint/pylint.sh@@ -23,7 +23,7 @@ echo "[DEBUG] list pipdeptree..."pip install pipdeptreepipdeptree-python -m pylint -f json --disable=R,C,W,E1129 --enable=line-too-long --max-line-length=120 --extension-pkg-whitelist=numpy --ignored-classes=TensorProto,NodeProto \+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 \--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.jsondiff --git a/.azure-pipelines/scripts/ut/run_ut_cuda.sh b/.azure-pipelines/scripts/ut/run_ut_cuda.shindex a7b6eddd7..28f71782e 100644--- a/.azure-pipelines/scripts/ut/run_ut_cuda.sh+++ b/.azure-pipelines/scripts/ut/run_ut_cuda.sh@@ -36,6 +36,7 @@ function create_conda_env() {fiuv pip install -v --no-build-isolation .uv pip install pytest-cov pytest-html cmake==4.0.2+ uv pip install torch==2.8.0 torchvision}function print_test_results_table() {@@ -107,7 +108,7 @@ function run_unit_test() {local auto_round_path=$(python -c 'import auto_round; print(auto_round.__path__[0])')# run unit tests individually with separate logs- for test_file in $(find . -name "test_*.py"); do+ for test_file in $(find . -name "test_*.py" ! -name "test_*vlms.py" | sort); dolocal test_basename=$(basename ${test_file} .py)local ut_log_name=${LOG_DIR}/unittest_cuda_${test_basename}.logecho "Running ${test_file}..."diff --git a/.azure-pipelines/template/docker-template.yml b/.azure-pipelines/template/docker-template.ymlindex 32bda3d59..f210de691 100644--- a/.azure-pipelines/template/docker-template.yml+++ b/.azure-pipelines/template/docker-template.yml@@ -74,7 +74,7 @@ steps:- ${{ if eq(parameters.imageSource, 'pull') }}:- script: |- docker pull vault.habana.ai/gaudi-docker/1.21.0/ubuntu22.04/habanalabs/pytorch-installer-2.6.0:latest+ docker pull vault.habana.ai/gaudi-docker/1.22.1/ubuntu24.04/habanalabs/pytorch-installer-2.7.1:latestdisplayName: "Pull habana docker image"- script: |@@ -95,7 +95,7 @@ steps:elsedocker 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.21.0/ubuntu22.04/habanalabs/pytorch-installer-2.6.0:latest+ -v ${BUILD_SOURCESDIRECTORY}:/auto-round vault.habana.ai/gaudi-docker/1.22.1/ubuntu24.04/habanalabs/pytorch-installer-2.7.1:latestdocker exec ${{ parameters.containerName }} bash -c "ln -sf \$(which python3) /usr/bin/python"fiecho "Show the container list after docker run ... "diff --git a/.azure-pipelines/template/ut-template.yml b/.azure-pipelines/template/ut-template.ymlindex e5a081b0a..107a38988 100644--- a/.azure-pipelines/template/ut-template.yml+++ b/.azure-pipelines/template/ut-template.yml@@ -26,7 +26,7 @@ steps:parameters:dockerConfigName: ${{ parameters.dockerConfigName }}repoName: "auto-round"- repoTag: "py310"+ repoTag: "py312"dockerFileName: "Dockerfile"containerName: ${{ parameters.utContainerName }}repo: ${{ parameters.repo }}@@ -35,9 +35,10 @@ steps:- ${{ if eq(parameters.imageSource, 'build') }}:- script: |docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \- && pip install torch==2.7.1 torchvision --index-url https://download.pytorch.org/whl/cpu \- && pip install intel-extension-for-pytorch==2.7.0 \- && pip install .[cpu] \+ && pip install torch==2.8.0 torchvision --index-url https://download.pytorch.org/whl/cpu \+ && pip install intel-extension-for-pytorch==2.8.0 \+ && pip install -r requirements-cpu.txt \+ && pip install . \&& pip list"displayName: "Env Setup"diff --git a/.azure-pipelines/unit-test-hpu.yml b/.azure-pipelines/unit-test-hpu.ymlindex da1e2a6ff..1704b1ac7 100644--- a/.azure-pipelines/unit-test-hpu.yml+++ b/.azure-pipelines/unit-test-hpu.yml@@ -9,6 +9,7 @@ pr:paths:include:- auto_round+ - auto_round_extension- test/test*hpu*'- setup.py- requirements-lib.txtdiff --git a/.azure-pipelines/unit-test.yml b/.azure-pipelines/unit-test.ymlindex 6a3d1338a..c05514f71 100644--- a/.azure-pipelines/unit-test.yml+++ b/.azure-pipelines/unit-test.yml@@ -92,8 +92,7 @@ stages:echo "--- collect logs ---"docker exec collectLogs bash -c "cd /auto-round \&& pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu \- && pip install -r requirements-cpu.txt \- && pip install --no-build-isolation . \+ && pip install . \&& pip list"docker exec collectLogs /bin/bash +x -c "cd /auto-round/.azure-pipelines/scripts \&& bash ut/collect_log.sh"diff --git a/auto_round/compressors/base.py b/auto_round/compressors/base.pyindex fa0c4c7e0..a5e4df776 100644--- a/auto_round/compressors/base.py+++ b/auto_round/compressors/base.py@@ -595,7 +595,7 @@ class BaseCompressor(object):):logger.info("'enable_torch_compile' is set to `False` by default. "- "Enabling it can reduce tuning cost by 20%, but it might throw an exception."+ "Enabling it can reduce tuning cost by 20%%, but it might throw an exception.")if (self.data_type.startswith("fp") or self.act_data_type.startswith("fp")) and self.enable_torch_compile:diff --git a/auto_round/export/export_to_itrex/model_wrapper.py b/auto_round/export/export_to_itrex/model_wrapper.pyindex 0d736b0b1..d6120cd72 100644--- a/auto_round/export/export_to_itrex/model_wrapper.py+++ b/auto_round/export/export_to_itrex/model_wrapper.py@@ -349,10 +349,10 @@ class WeightOnlyLinear(torch.nn.Module):self.weight = weightinput = input.type(self.weight.dtype)logger.debug(f"Calculating {self}")- return F.linear(input, self.weight, self.bias)+ return F.linear(input, self.weight, self.bias) # pylint: disable=E1102else:input = input.type(weight.dtype)- return F.linear(input, weight, self.bias)+ return F.linear(input, weight, self.bias) # pylint: disable=E1102def extra_repr(self) -> str:tmp_str = "in_features={}, out_features={}, bits={}, group_size={}, bias={}".format(diff --git a/auto_round/wrapper.py b/auto_round/wrapper.pyindex 67072d762..f8b42ec7a 100644--- a/auto_round/wrapper.py+++ b/auto_round/wrapper.py@@ -425,7 +425,7 @@ class WrapperLinear(torch.nn.Module):Returns:torch.Tensor: Output tensor after applying the linear layer."""- return F.linear(x, weight, bias)+ return F.linear(x, weight, bias) # pylint: disable=E1102def all_reduce_linear_forward(self, x, weight, bias):"""Performs the forward pass for a linear layer.diff --git a/test/test_cuda/requirements.txt b/test/test_cuda/requirements.txtindex 37b596c47..a60096f8c 100644--- a/test/test_cuda/requirements.txt+++ b/test/test_cuda/requirements.txt@@ -11,6 +11,7 @@ lm-eval>=0.4.9.1numpy < 2.0optimumpandas+parameterizedpillowpy-cpuinfotorch@@ -20,5 +21,3 @@ numbatransformersvllm>=0.8.5.post1compressed-tensors--diff --git a/test/test_cuda/requirements_vlm.txt b/test/test_cuda/requirements_vlm.txtindex b1b06b14c..0eb55ac45 100644--- a/test/test_cuda/requirements_vlm.txt+++ b/test/test_cuda/requirements_vlm.txt@@ -15,6 +15,7 @@ pandasprotobufpillowpy-cpuinfo+tiktokentorchtorchvisiontriton