PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
Refactor build process to use 'uv build' instead of 'python setup.py' (#1495)
Sun, Xuehao502461148127
diff --git a/.azure-pipelines/compatibility-test.yml b/.azure-pipelines/compatibility-test.ymlindex 754e47198..8809933da 100644--- a/.azure-pipelines/compatibility-test.yml+++ b/.azure-pipelines/compatibility-test.yml@@ -72,7 +72,7 @@ stages:- bash: |python -m pip install --upgrade pip uvuv pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu- python setup.py sdist bdist_wheel+ uv builduv pip install dist/*.tar.gz && uv pip uninstall auto-rounduv pip install dist/*.whluv pip listdiff --git a/.azure-pipelines/template/ut-template.yml b/.azure-pipelines/template/ut-template.ymlindex af22ae6c8..a6b2cabcd 100644--- a/.azure-pipelines/template/ut-template.yml+++ b/.azure-pipelines/template/ut-template.yml@@ -65,7 +65,8 @@ steps:- ${{ if eq(parameters.imageSource, 'pull') }}:- script: |docker exec ${{ parameters.utContainerName }} bash -c "cd /auto-round \- && python setup.py bdist_wheel hpu \+ && pip install build \+ && BUILD_HPU_ONLY=1 python -m build \&& pip install dist/*.whl \&& pip install -r test/test_hpu/requirements.txt \&& pip list"diff --git a/.github/workflows/compatibility-test.yml b/.github/workflows/compatibility-test.ymlindex 64981aa45..749ce0061 100644--- a/.github/workflows/compatibility-test.yml+++ b/.github/workflows/compatibility-test.yml@@ -60,7 +60,7 @@ jobs:python -m pip install --upgrade pip uv setuptoolsuv pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpuuv pip install datasets --upgrade- python setup.py sdist bdist_wheel+ uv builduv pip install dist/*.tar.gz && uv pip uninstall auto-rounduv pip install dist/*.whluv pip list@@ -72,7 +72,7 @@ jobs:- name: Run compatibility testrun: |- set -xe+ set -epython -c "import auto_round; print(auto_round.__version__)"echo "============================================================================"auto-round --model_name Qwen/Qwen3-0.6B --bits 4 --iters 0 --nsamples 8diff --git a/.github/workflows/manual-binary-build-publish.yml b/.github/workflows/manual-binary-build-publish.ymlindex 94c9dac99..651a4b875 100644--- a/.github/workflows/manual-binary-build-publish.yml+++ b/.github/workflows/manual-binary-build-publish.yml@@ -41,16 +41,19 @@ jobs:- name: Install dependenciesrun: |- python -m pip install --upgrade pip setuptools wheel+ python -m pip install --upgrade pip setuptools wheel uv- name: Build the binaryrun: |if [ "${{ matrix.option }}" == "full" ]; thenecho "Building auto-round binary..."- python setup.py sdist bdist_wheel- else+ uv build+ elif [ "${{ matrix.option }}" == "hpu" ]; thenecho "Building auto-round-${{ matrix.option }} binary..."- python setup.py sdist bdist_wheel ${{ matrix.option }}+ BUILD_HPU_ONLY=1 uv build+ else+ echo "Unknown build option: ${{ matrix.option }}"+ exit 1fi- name: Upload the artifactsdiff --git a/.github/workflows/nightly-binary-release.yml b/.github/workflows/nightly-binary-release.ymlindex 4b8a90015..da3362259 100644--- a/.github/workflows/nightly-binary-release.yml+++ b/.github/workflows/nightly-binary-release.yml@@ -32,7 +32,7 @@ jobs:- name: Install dependenciesrun: |- python -m pip install --upgrade pip setuptools wheel twine+ python -m pip install --upgrade pip setuptools wheel twine uv- name: Set nightly versionid: set_version@@ -50,7 +50,7 @@ jobs:- name: Build binaryrun: |- python setup.py sdist bdist_wheel+ uv build- name: Publish to PyPI or TestPyPIenv:diff --git a/pyproject.toml b/pyproject.tomlindex 10e05312b..014a453f6 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,3 +1,7 @@+[build-system]+requires = ["setuptools>=64", "wheel"]+build-backend = "setuptools.build_meta"+[tool.codespell]skip = 'pyproject.toml,.azure-pipelines/scripts/codeScan/codespell/autoround_dict.txt'ignore-words = ".azure-pipelines/scripts/codeScan/codespell/autoround_dict.txt"diff --git a/setup.py b/setup.pyindex 84e7327aa..dff0d7a8f 100644--- a/setup.py+++ b/setup.py@@ -34,6 +34,17 @@ def is_commit_on_tag():def get_build_version():+ # When building a wheel from an extracted sdist (e.g. via `uv build` or+ # `python -m build`), the sdist root contains a PKG-INFO file that already+ # carries the correct version computed during the sdist step. Reading from+ # it avoids the sdist/wheel version mismatch that occurs because git is not+ # available inside the extracted sdist directory.+ if os.path.exists("PKG-INFO"):+ with open("PKG-INFO", encoding="utf-8") as f:+ for line in f:+ if line.startswith("Version:"):+ return line.split(":", 1)[1].strip()+if is_commit_on_tag():return __version__try:@@ -133,14 +144,15 @@ HPU_INSTALL_CFG = {"install_requires": fetch_requirements(HPU_REQUIREMENTS_FILE),}-if __name__ == "__main__":-- package_name = "auto-round"+# Support legacy `python setup.py hpu install` invocation for backward compatibility.+# For python -m build / uv build, use the BUILD_HPU_ONLY=1 environment variable instead.+if __name__ == "__main__":hpu_build = "hpu" in sys.argvif hpu_build:sys.argv.remove("hpu")+ package_name = "auto-round"should_build_hpu = hpu_build or BUILD_HPU_ONLYif should_build_hpu:package_name = "auto-round-hpu"