Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .azure-pipelines/docker/Dockerfile_xpu.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

ARG UBUNTU_VER=24.04
FROM ubuntu:${UBUNTU_VER}

# See http://bugs.python.org/issue19846
ENV LANG C.UTF-8

RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \
build-essential \
ca-certificates \
git \
libomp-dev \
numactl \
time \
wget \
bc \
jq \
vim

RUN apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:kobuk-team/intel-graphics \
&& apt-get install -y libze-intel-gpu1 libze1 intel-metrics-discovery intel-opencl-icd clinfo intel-gsc \
&& apt-get install -y intel-media-va-driver-non-free libmfx-gen1 libvpl2 libvpl-tools libva-glx2 va-driver-all vainfo \
&& apt-get install -y libze-dev intel-ocloc \
&& apt-get install -y libze-intel-gpu-raytracing

COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
RUN echo '#!/bin/sh\nexec /usr/local/bin/uv pip "$@"' > /usr/local/bin/pip && \
chmod +x /usr/local/bin/pip
ARG USER_ID=1000
ARG GROUP_ID=1000

RUN groupadd -g ${GROUP_ID} hostgroup && \
useradd -m -u ${USER_ID} -g ${GROUP_ID} hostuser && \
groupadd -g 991 render && \
usermod -aG render hostuser

USER hostuser

ENV PATH="/home/hostuser/.venv/bin:$PATH"
ENV VIRTUAL_ENV="/home/hostuser/.venv"
ENV UV_NO_PROGRESS=1 \
UV_LINK_MODE=copy

RUN uv venv --python=3.12 /home/hostuser/.venv
RUN which python && python --version

WORKDIR /home/hostuser
20 changes: 12 additions & 8 deletions .azure-pipelines/scripts/install_nc.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
#!/bin/bash

set -x
echo -e "##[group]Install Neural Compressor ... "
cd /neural-compressor

if [[ $1 = *"3x_pt"* ]]; then
python -m pip install --no-cache-dir -r requirements_pt.txt
if [[ $1 = *"3x_pt_fp8"* ]]; then
pip install --no-cache-dir -r requirements_pt.txt
if [[ $1 = *"hpu"* ]]; then
pip uninstall neural_compressor_3x_pt -y || true
python setup.py pt bdist_wheel
elif [[ $1 = *"xpu"* ]]; then
echo -e "\n Install torch XPU ... "
pip install torch==2.9.1 torchvision --index-url https://download.pytorch.org/whl/xpu
pip install auto-round-lib==0.10.2.1 # mapping torch and auto-round version
else
echo -e "\n Install torch CPU ... "
pip install torch==2.9.1 torchvision --index-url https://download.pytorch.org/whl/cpu
pip install auto-round-lib==0.10.2.1 # mapping torch and auto-round version
python -m pip install --no-cache-dir -r requirements.txt
python setup.py bdist_wheel
fi
python setup.py pt bdist_wheel
pip install --no-deps dist/neural_compressor*.whl --force-reinstall
elif [[ $1 = *"3x_tf"* ]]; then
pip install tensorflow==2.19.0
python -m pip install --no-cache-dir -r requirements.txt
python -m pip install --no-cache-dir -r requirements_tf.txt
python setup.py bdist_wheel
python setup.py tf bdist_wheel
pip install dist/neural_compressor*.whl --force-reinstall
else
python -m pip install --no-cache-dir -r requirements.txt
python setup.py bdist_wheel
pip install dist/neural_compressor*.whl --force-reinstall
fi

echo -e "\n pip list after install Neural Compressor ... "
echo "##[endgroup]"

echo -e "\n pip list after install Neural Compressor ... "
pip list
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ else
TORCH_VISION_VERSION=${torchvision_version}
fi


/bin/bash run_model_trigger_common.sh \
numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" bash run_model_trigger_common.sh \
--yaml=${yaml} \
--framework=${FRAMEWORK} \
--fwk_ver=${FRAMEWORK_VERSION} \
Expand Down
139 changes: 0 additions & 139 deletions .azure-pipelines/scripts/ut/collect_log.sh

This file was deleted.

30 changes: 0 additions & 30 deletions .azure-pipelines/scripts/ut/coverage.file

This file was deleted.

6 changes: 5 additions & 1 deletion .azure-pipelines/scripts/ut/run_3x_pt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ cd /neural-compressor/test || exit 1
rm -rf torch/algorithms/fp8_quant
rm -rf torch/quantization/fp8_quant
rm -rf torch/algorithms/fp8_quant_xpu
rm -rf torch/quantization/test_autoround_xpu.py
rm -rf torch/quantization/test_autoround_hpu.py

LOG_DIR=/neural-compressor/log_dir
mkdir -p ${LOG_DIR}
Expand All @@ -37,7 +39,9 @@ numactl --physcpubind="${NUMA_CPUSET:-0-15}" --membind="${NUMA_NODE:-0}" bash ru

cp report.html ${LOG_DIR}/

if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
set -x
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || \
[ $(grep -c 'Killed' ${ut_log_name}) != 0 ] || [ $(grep -c 'core dumped' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
echo "Find errors in pytest case, please check the output..."
echo "Please search for '== FAILURES ==' or '== ERRORS =='"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ pip install beautifulsoup4==4.13.5
echo "##[endgroup]"
pip list

export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/coverage.3x_pt_fp8
export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/coverage.3x_pt_hpu
inc_path=$(python -c 'import neural_compressor; print(neural_compressor.__path__[0])')
cd /neural-compressor/test || exit 1

LOG_DIR=/neural-compressor/log_dir
mkdir -p ${LOG_DIR}
ut_log_name=${LOG_DIR}/ut_3x_pt_fp8.log
ut_log_name=${LOG_DIR}/ut_3x_pt_hpu.log
pytest --cov="${inc_path}" -vs --disable-warnings --html=report_1.html --self-contained-html torch/quantization/weight_only/test_load.py 2>&1 | tee -a ${ut_log_name}
pytest --cov="${inc_path}" -vs --disable-warnings --html=report_2.html --self-contained-html torch/quantization/weight_only/test_rtn.py 2>&1 | tee -a ${ut_log_name}
pytest --cov="${inc_path}" -vs --disable-warnings --html=report_3.html --self-contained-html torch/quantization/test_autoround.py 2>&1 | tee -a ${ut_log_name}
pytest --cov="${inc_path}" -vs --disable-warnings --html=report_3.html --self-contained-html torch/quantization/test_autoround_hpu.py 2>&1 | tee -a ${ut_log_name}

# Below folder contains some special configuration for pytest so we need to enter the path and run it separately
cd /neural-compressor/test/torch/algorithms/fp8_quant
Expand All @@ -50,7 +50,9 @@ mkdir -p report && mv *.html report
pytest_html_merger -i ./report -o ./report.html
cp report.html ${LOG_DIR}/

if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
set -x
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || \
[ $(grep -c 'Killed' ${ut_log_name}) != 0 ] || [ $(grep -c 'core dumped' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
echo "Find errors in pytest case, please check the output..."
echo "Please search for '== FAILURES ==' or '== ERRORS =='"
exit 1
Expand Down
53 changes: 53 additions & 0 deletions .azure-pipelines/scripts/ut/run_3x_pt_xpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
python -c "import neural_compressor as nc"
test_case="run 3x Torch with XPU"
echo "${test_case}"

echo "##[section]Run import check"
set -e
python -c "import neural_compressor.torch"
python -c "import neural_compressor.common"
echo "##[section]import check pass"

echo "##[group]set up UT env..."
export LD_LIBRARY_PATH=${HOME}/.local/lib/:$LD_LIBRARY_PATH
uv pip install -r /neural-compressor/test/torch/requirements_xpu.txt
uv pip install pytest-cov pytest-html
uv pip list
echo "##[endgroup]"

echo "##[group]check xpu env..."
echo "ZE_AFFINITY_MASK: ${ZE_AFFINITY_MASK}"
python - <<'PY'
import torch
print("torch:", torch.__version__)
print("xpu available:", torch.xpu.is_available())
print("xpu count:", torch.xpu.device_count())
PY
echo "##[endgroup]"

export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/coverage.3x_pt
inc_path=$(python -c 'import neural_compressor; print(neural_compressor.__path__[0])')
cd /neural-compressor/test || exit 1

LOG_DIR=/neural-compressor/log_dir
mkdir -p ${LOG_DIR}
ut_log_name=${LOG_DIR}/ut_3x_pt_xpu.log

find ./torch -name "test_autoround_xpu.py" | sed "s,\.\/,python -m pytest --cov=\"${inc_path}\" --cov-report term --html=report.html --self-contained-html --cov-report xml:coverage.xml --cov-append -vs --disable-warnings ,g" > run_xpu.sh
cat run_xpu.sh
numactl --physcpubind="${NUMA_CPUSET:-0-27}" --membind="${NUMA_NODE:-0}" bash run_xpu.sh 2>&1 | tee ${ut_log_name}

cp report.html ${LOG_DIR}/

set -x
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || \
[ $(grep -c 'Killed' ${ut_log_name}) != 0 ] || [ $(grep -c 'core dumped' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
echo "##[error]Find errors in pytest case, please check the output..."
exit 1
fi

# if ut pass, collect the coverage file into artifacts
cp .coverage ${LOG_DIR}/.coverage

echo "UT finished successfully! "
4 changes: 3 additions & 1 deletion .azure-pipelines/scripts/ut/run_3x_tf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ pytest_html_merger -i ./report -o ./report.html

cp report.html ${LOG_DIR}/

if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
set -x
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || \
[ $(grep -c 'Killed' ${ut_log_name}) != 0 ] || [ $(grep -c 'core dumped' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
echo "Find errors in pytest case, please check the output..."
echo "Please search for '== FAILURES ==' or '== ERRORS =='"
exit 1
Expand Down
Loading