Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UT env #1978

Merged
merged 13 commits into from
Aug 16, 2024
6 changes: 3 additions & 3 deletions .azure-pipelines/scripts/fwk_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 5 additions & 3 deletions .azure-pipelines/scripts/install_nc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions .azure-pipelines/scripts/models/env_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions .azure-pipelines/scripts/ut/run_basic_pt_pruning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions .azure-pipelines/template/docker-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ steps:
- checkout: self
clean: true
displayName: "Checkout out Repo"
fetchDepth: 0

- ${{ if eq(parameters.dockerConfigName, 'gitCloneDockerConfig') }}:
- script: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions neural_compressor/torch/algorithms/pt2e_quant/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion neural_compressor/torch/utils/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
6 changes: 3 additions & 3 deletions test/3x/torch/quantization/test_pt2e_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading