PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
Fix CPU CI (#1344)
Sun, Xuehao8eec5d8a20f3
diff --git a/.azure-pipelines/scripts/ut/run_ut.sh b/.azure-pipelines/scripts/ut/run_ut.shindex 73ef823b6..974681abd 100644--- a/.azure-pipelines/scripts/ut/run_ut.sh+++ b/.azure-pipelines/scripts/ut/run_ut.sh@@ -9,11 +9,11 @@ export TQDM_MININTERVAL=60uv pip install pytest-cov pytest-htmluv pip install -r /auto-round/test/test_cpu/requirements.txt \--extra-index-url https://download.pytorch.org/whl/cpu+uv pip install torch==2.8.0 torchvision --index-url https://download.pytorch.org/whl/cpu# install latest gguf for ut testcd ~ || exit 1git clone -b master --quiet --single-branch https://github.com/ggml-org/llama.cpp.git && cd llama.cpp/gguf-py && uv pip install . sentencepiece-uv pip install --upgrade transformerscd /auto-round && uv pip install .diff --git a/.azure-pipelines/scripts/ut/run_ut_cuda.sh b/.azure-pipelines/scripts/ut/run_ut_cuda.shindex 5ef83f527..6cc562070 100644--- a/.azure-pipelines/scripts/ut/run_ut_cuda.sh+++ b/.azure-pipelines/scripts/ut/run_ut_cuda.sh@@ -95,7 +95,7 @@ function run_unit_test() {rm -rf .coverage* *.xml *.htmluv pip install -v git+https://github.com/casper-hansen/AutoAWQ.git --no-build-isolation- uv pip install -v git+https://github.com/ModelCloud/[email protected] --no-build-isolation+ uv pip install https://github.com/ModelCloud/GPTQModel/releases/download/v5.6.0/gptqmodel-5.6.0+cu126torch2.9-cp310-cp310-linux_x86_64.whl --no-build-isolationuv pip install -r https://raw.githubusercontent.com/ModelCloud/GPTQModel/refs/heads/main/requirements.txtCMAKE_ARGS="-DGGML_CUDA=on -DLLAVA_BUILD=off" uv pip install llama-cpp-pythonuv pip install 'git+https://github.com/ggml-org/llama.cpp.git#subdirectory=gguf-py'diff --git a/auto_round/calib_dataset.py b/auto_round/calib_dataset.pyindex 5776a1a1d..b4bbf65b5 100644--- a/auto_round/calib_dataset.py+++ b/auto_round/calib_dataset.py@@ -456,8 +456,15 @@ def get_new_chinese_title_dataset(@register_dataset("mbpp")+@register_dataset("google-research-datasets/mbpp")def get_mbpp_dataset(- tokenizer, seqlen, dataset_name="mbpp", split=None, seed=42, apply_chat_template=False, system_prompt=None+ tokenizer,+ seqlen,+ dataset_name="google-research-datasets/mbpp",+ split=None,+ seed=42,+ apply_chat_template=False,+ system_prompt=None,):"""Returns a dataloader for the specified dataset and split.@@ -474,6 +481,8 @@ def get_mbpp_dataset("""from datasets import load_dataset+ dataset_name = "google-research-datasets/mbpp"+tokenizer_function = get_tokenizer_function(tokenizer, seqlen, apply_chat_template=apply_chat_template, system_prompt=system_prompt)diff --git a/auto_round/utils/__init__.py b/auto_round/utils/__init__.pyindex 898946ad3..d005b7d35 100644--- a/auto_round/utils/__init__.py+++ b/auto_round/utils/__init__.py@@ -15,3 +15,28 @@from auto_round.utils.device import *from auto_round.utils.common import *from auto_round.utils.model import *++import transformers+from packaging.version import Version++DATASET_PATCHED = False+# tmp batch for transformers v5.0+if Version(transformers.__version__) >= Version("5.0.0") and not DATASET_PATCHED:+ import datasets++ datasets.original_load_dataset = datasets.load_dataset++ def patch_load_dataset(*args, **kwargs):+ for dataset_name, replace_name in [("openbookqa", "allenai/openbookqa")]:+ if len(args) > 0 and dataset_name in args[0]:+ args = (replace_name,) + args[1:]+ if "path" in kwargs and kwargs["path"] is not None:+ if dataset_name in kwargs["path"] and replace_name not in kwargs["path"]:+ kwargs["path"] = kwargs["path"].replace(dataset_name, replace_name)+ if "name" in kwargs and kwargs["name"] is not None:+ if dataset_name in kwargs["name"] and replace_name not in kwargs["name"]:+ kwargs["name"] = kwargs["name"].replace(dataset_name, replace_name)+ return datasets.original_load_dataset(*args, **kwargs)++ datasets.load_dataset = patch_load_dataset+ DATASET_PATCHED = Truediff --git a/test/fixtures.py b/test/fixtures.pyindex 01ba5cd70..624170710 100644--- a/test/fixtures.py+++ b/test/fixtures.py@@ -1,6 +1,7 @@import osimport shutil+import datasetsimport pytestimport torchimport transformers