diff --git a/.azure-pipelines/scripts/fwk_version.sh b/.azure-pipelines/scripts/fwk_version.sh index 82845e8982e..3e9037783e4 100644 --- a/.azure-pipelines/scripts/fwk_version.sh +++ b/.azure-pipelines/scripts/fwk_version.sh @@ -2,9 +2,9 @@ echo "export FWs version..." export tensorflow_version='2.15.0-official' -export pytorch_version='2.3.0+cpu' -export torchvision_version='0.18.0+cpu' -export ipex_version='2.3.0+cpu' +export pytorch_version='2.4.0+cpu' +export torchvision_version='0.19.0' +export ipex_version='2.4.0+cpu' export onnx_version='1.16.0' export onnxruntime_version='1.18.0' export mxnet_version='1.9.1' diff --git a/.azure-pipelines/scripts/install_nc.sh b/.azure-pipelines/scripts/install_nc.sh index 6a80419259f..7a525236686 100644 --- a/.azure-pipelines/scripts/install_nc.sh +++ b/.azure-pipelines/scripts/install_nc.sh @@ -5,14 +5,16 @@ cd /neural-compressor if [[ $1 = *"3x_pt"* ]]; then if [[ $1 != *"3x_pt_fp8"* ]]; then echo -e "\n Install torch CPU ... " - pip install torch==2.3.0 --index-url https://download.pytorch.org/whl/cpu + pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cpu fi python -m pip install --no-cache-dir -r requirements_pt.txt - python setup.py pt bdist_wheel + # python setup.py pt bdist_wheel + python setup.py bdist_wheel pip install --no-deps dist/neural_compressor*.whl --force-reinstall elif [[ $1 = *"3x_tf"* ]]; then python -m pip install --no-cache-dir -r requirements_tf.txt - python setup.py tf bdist_wheel + # python setup.py tf bdist_wheel + python setup.py bdist_wheel pip install dist/neural_compressor*.whl --force-reinstall else python -m pip install --no-cache-dir -r requirements.txt diff --git a/.azure-pipelines/scripts/models/env_setup.sh b/.azure-pipelines/scripts/models/env_setup.sh index adf4f01df67..5b31b59f515 100644 --- a/.azure-pipelines/scripts/models/env_setup.sh +++ b/.azure-pipelines/scripts/models/env_setup.sh @@ -51,6 +51,10 @@ SCRIPTS_PATH="/neural-compressor/.azure-pipelines/scripts/models" log_dir="/neural-compressor/.azure-pipelines/scripts/models" if [[ "${inc_new_api}" == "3x"* ]]; then WORK_SOURCE_DIR="/neural-compressor/examples/3.x_api/${framework}" + git clone https://github.com/intel/intel-extension-for-transformers.git /itrex + cd /itrex + pip install -r requirements.txt + pip install -v . else WORK_SOURCE_DIR="/neural-compressor/examples/${framework}" fi @@ -95,8 +99,8 @@ if [[ "${fwk_ver}" != "latest" ]]; then pip install intel-tensorflow==${fwk_ver} fi elif [[ "${framework}" == "pytorch" ]]; then - pip install torch==${fwk_ver} -f https://download.pytorch.org/whl/torch_stable.html - pip install torchvision==${torch_vision_ver} -f https://download.pytorch.org/whl/torch_stable.html + pip install torch==${fwk_ver} --index-url https://download.pytorch.org/whl/cpu + pip install torchvision==${torch_vision_ver} --index-url https://download.pytorch.org/whl/cpu elif [[ "${framework}" == "onnxrt" ]]; then pip install onnx==1.15.0 pip install onnxruntime==${fwk_ver} diff --git a/.azure-pipelines/scripts/ut/run_basic_pt_pruning.sh b/.azure-pipelines/scripts/ut/run_basic_pt_pruning.sh index d34705b89f3..a99251bbf3b 100644 --- a/.azure-pipelines/scripts/ut/run_basic_pt_pruning.sh +++ b/.azure-pipelines/scripts/ut/run_basic_pt_pruning.sh @@ -4,9 +4,9 @@ test_case="run basic pt pruning" echo "${test_case}" echo "specify fwk version..." -export pytorch_version='2.3.0+cpu' +export pytorch_version='2.4.0+cpu' export torchvision_version='0.18.0+cpu' -export ipex_version='2.3.0+cpu' +export ipex_version='2.4.0+cpu' echo "set up UT env..." bash /neural-compressor/.azure-pipelines/scripts/ut/env_setup.sh "${test_case}" diff --git a/.azure-pipelines/template/docker-template.yml b/.azure-pipelines/template/docker-template.yml index 51103c39e21..1a1a488ca1f 100644 --- a/.azure-pipelines/template/docker-template.yml +++ b/.azure-pipelines/template/docker-template.yml @@ -42,6 +42,7 @@ steps: - checkout: self clean: true displayName: "Checkout out Repo" + fetchDepth: 0 - ${{ if eq(parameters.dockerConfigName, 'gitCloneDockerConfig') }}: - script: | diff --git a/examples/3.x_api/pytorch/nlp/huggingface_models/language-modeling/quantization/weight_only/requirements.txt b/examples/3.x_api/pytorch/nlp/huggingface_models/language-modeling/quantization/weight_only/requirements.txt index 9688a4f6cb3..63c4d6e10b1 100644 --- a/examples/3.x_api/pytorch/nlp/huggingface_models/language-modeling/quantization/weight_only/requirements.txt +++ b/examples/3.x_api/pytorch/nlp/huggingface_models/language-modeling/quantization/weight_only/requirements.txt @@ -9,7 +9,7 @@ wandb einops neural-compressor intel-extension-for-transformers -lm_eval==0.4.2 +lm_eval==0.4.3 peft auto_round intel_extension_for_pytorch diff --git a/neural_compressor/torch/algorithms/pt2e_quant/utility.py b/neural_compressor/torch/algorithms/pt2e_quant/utility.py index ecf14ec02a7..966baf0e53a 100644 --- a/neural_compressor/torch/algorithms/pt2e_quant/utility.py +++ b/neural_compressor/torch/algorithms/pt2e_quant/utility.py @@ -21,7 +21,7 @@ from torch.ao.quantization.quantizer import QuantizationSpec from torch.ao.quantization.quantizer.x86_inductor_quantizer import QuantizationConfig, X86InductorQuantizer -from neural_compressor.torch.utils import GT_TORCH_VERSION_2_3_2 +from neural_compressor.torch.utils import GT_OR_EQUAL_TORCH_VERSION_2_5 def create_quant_spec_from_config(dtype, sym, granularity, algo, is_dynamic=False) -> QuantizationSpec: @@ -102,8 +102,8 @@ def create_xiq_quantizer_from_pt2e_config(config, is_dynamic=False) -> X86Induct # set global global_config = _map_inc_config_to_torch_quant_config(config, is_dynamic) quantizer.set_global(global_config) - # need torch >= 2.3.2 - if GT_TORCH_VERSION_2_3_2: # pragma: no cover + # need torch >= 2.5 + if GT_OR_EQUAL_TORCH_VERSION_2_5: # pragma: no cover op_type_config_dict, op_name_config_dict = config._get_op_name_op_type_config() if op_type_config_dict: for op_type, config in op_type_config_dict.items(): diff --git a/neural_compressor/torch/utils/environ.py b/neural_compressor/torch/utils/environ.py index aa6b9affba0..444aaa95f3d 100644 --- a/neural_compressor/torch/utils/environ.py +++ b/neural_compressor/torch/utils/environ.py @@ -104,7 +104,7 @@ def get_torch_version(): return version -GT_TORCH_VERSION_2_3_2 = get_torch_version() > Version("2.3.2") +GT_OR_EQUAL_TORCH_VERSION_2_5 = get_torch_version() >= Version("2.5") def get_accelerator(device_name="auto"): diff --git a/test/3x/torch/quantization/test_pt2e_quant.py b/test/3x/torch/quantization/test_pt2e_quant.py index d55e9004a3a..ab80e991203 100644 --- a/test/3x/torch/quantization/test_pt2e_quant.py +++ b/test/3x/torch/quantization/test_pt2e_quant.py @@ -15,7 +15,7 @@ prepare, quantize, ) -from neural_compressor.torch.utils import GT_TORCH_VERSION_2_3_2, TORCH_VERSION_2_2_2, get_torch_version +from neural_compressor.torch.utils import GT_OR_EQUAL_TORCH_VERSION_2_5, TORCH_VERSION_2_2_2, get_torch_version torch.manual_seed(0) @@ -131,7 +131,7 @@ def calib_fn(model): logger.warning("out shape is %s", out.shape) assert out is not None - @pytest.mark.skipif(not GT_TORCH_VERSION_2_3_2, reason="Requires torch>=2.3.2") + @pytest.mark.skipif(not GT_OR_EQUAL_TORCH_VERSION_2_5, reason="Requires torch>=2.5") def test_quantize_simple_model_with_set_local(self, force_not_import_ipex): model, example_inputs = self.build_simple_torch_model_and_example_inputs() float_model_output = model(*example_inputs) @@ -243,7 +243,7 @@ def get_node_in_graph(graph_module): nodes_in_graph[n] = 1 return nodes_in_graph - @pytest.mark.skipif(not GT_TORCH_VERSION_2_3_2, reason="Requires torch>=2.3.0") + @pytest.mark.skipif(not GT_OR_EQUAL_TORCH_VERSION_2_5, reason="Requires torch>=2.5") def test_mixed_fp16_and_int8(self, force_not_import_ipex): model, example_inputs = self.build_model_include_conv_and_linear() model = export(model, example_inputs=example_inputs)