PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
modify setup.py (#206)
n1ck-guo8610b888e72f
diff --git a/README.md b/README.mdindex b9f614aba..ab03a9ee1 100644--- a/README.md+++ b/README.md@@ -137,13 +137,13 @@ Please run the quantization code first### Setup env for AutoRound format-2 Set up the environment-**cuda**: git clone https://github.com/intel/auto-round.git && cd auto-round && pip install -vvv --no-build-isolation -e .-cpu: pip install intel-extension-for-transformers+**cpu**:+* option 1: pip install auto-round && pip install intel-extension-for-transformers+* option 2: git clone https://github.com/intel/auto-round.git && cd auto-round && pip install -vvv --no-build-isolation -e .-hpu: docker image with Gaudi Software Stack is recommended, please refer to following script for environment setup. More details can be found in Gaudi Guide.+**hpu**: docker image with Gaudi Software Stack is recommended. More details can be found in [Gaudi Guide](https://docs.habana.ai/en/latest/).### Gaudi2/ CPU/ GPU@@ -206,7 +206,7 @@ average accuracies of 11 zero-shot tasks.## Reference-If you find SignRound useful for your research, please cite our paper:+If you find AutoRound useful for your research, please cite our paper:```bash@article{cheng2023optimize,diff --git a/setup.py b/setup.pyindex 55cf381ab..04a0284f4 100644--- a/setup.py+++ b/setup.py@@ -19,13 +19,28 @@ version = __version__BUILD_CUDA_EXT = int(os.environ.get('BUILD_CUDA_EXT', '1')) == 1PYPI_RELEASE = os.environ.get('PYPI_RELEASE', None)+def is_cpu_env():+ try:+ import torch+ except Exception as e:+ print(+ f"Building extension requires PyTorch being installed, please install PyTorch first: {e}.\n NOTE: This issue may be raised due to pip build isolation system (ignoring local packages). Please use `--no-build-isolation` when installing with pip, and refer to https://github.com/intel/auto-round for more details.")+ sys.exit(1)+ if torch.cuda.is_available():+ return False+ try:+ import habana_frameworks.torch.core as htcore+ return False+ except:+ return True+def fetch_requirements(path):requirements = []with open(path, "r") as fd:requirements = [r.strip() for r in fd.readlines()]- if not BUILD_CUDA_EXT:- requirements.append("intel-extension-for-transformers") # for leverage QBits woq_linear capability.+ if is_cpu_env():+ requirements.append("intel-extension-for-transformers")return requirementsdef detect_local_sm_architectures():@@ -62,7 +77,7 @@ if BUILD_CUDA_EXT:import torchexcept Exception as e:print(- f"Building PyTorch CUDA extension requires PyTorch being installed, please install PyTorch first: {e}.\n NOTE: This issue may be raised due to pip build isolation system (ignoring local packages). Please use `--no-build-isolation` when installing with pip, and refer to https://github.com/AutoRound/AutoRound/pull/620 for more details.")+ f"Building PyTorch CUDA extension requires PyTorch being installed, please install PyTorch first: {e}.\n NOTE: This issue may be raised due to pip build isolation system (ignoring local packages). Please use `--no-build-isolation` when installing with pip, and refer to https://github.com/intel/auto-round for more details.")sys.exit(1)if not torch.cuda.is_available():print(