Skip to content

Commit 3d4c41e

Browse files
Merge branch 'main' into check-tests
2 parents 12814fc + 31430d6 commit 3d4c41e

File tree

76 files changed

+4805
-2223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+4805
-2223
lines changed

.github/workflows/check_code_quality.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ jobs:
5151
- name: Check style with ruff
5252
run: |
5353
source venv/bin/activate
54-
ruff .
54+
ruff check .

.github/workflows/security.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Security Checks
2+
3+
on:
4+
push:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
secrets:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- shell: bash
14+
run: |
15+
if [ "${{ github.event_name }}" == "push" ]; then
16+
echo "depth=$(($(jq length <<< '${{ toJson(github.event.commits) }}') + 2))" >> $GITHUB_ENV
17+
echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV
18+
fi
19+
if [ "${{ github.event_name }}" == "pull_request" ]; then
20+
echo "depth=$((${{ github.event.pull_request.commits }}+2))" >> $GITHUB_ENV
21+
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
22+
fi
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{env.branch}}
27+
fetch-depth: ${{env.depth}}
28+
- name: Scan for secrets
29+
uses: trufflesecurity/trufflehog@main

.github/workflows/test_inc.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ name: Intel Neural Compressor - Test
44

55
on:
66
push:
7-
branches: [ main ]
7+
branches:
8+
- main
9+
- v*-release
810
pull_request:
9-
branches: [ main ]
11+
branches:
12+
- main
1013

1114
concurrency:
1215
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/test_ipex.yml

+19-8
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@ name: Intel IPEX - Test
44

55
on:
66
push:
7-
branches: [ main ]
7+
branches:
8+
- main
9+
- v*-release
810
pull_request:
9-
branches: [ main ]
11+
branches:
12+
- main
1013

1114
concurrency:
1215
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1316
cancel-in-progress: true
1417

1518
jobs:
1619
build:
20+
runs-on: ubuntu-latest
1721
strategy:
1822
fail-fast: false
1923
matrix:
20-
python-version: [3.8, 3.9]
21-
os: [ubuntu-latest]
24+
python-version: [3.9]
25+
transformers-version: [4.39.0, 4.42.3]
26+
ipex-version: [2.2.0, 2.3.*]
27+
include:
28+
- python-version: 3.8
29+
transformers-version: 4.39.0
30+
ipex-version: 2.2.0
2231

23-
runs-on: ${{ matrix.os }}
2432
steps:
2533
- uses: actions/checkout@v2
2634
- name: Setup Python ${{ matrix.python-version }}
@@ -30,8 +38,11 @@ jobs:
3038
- name: Install dependencies
3139
run: |
3240
python -m pip install --upgrade pip
33-
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cpu
34-
pip install .[ipex,tests]
41+
pip install torch==${{ matrix.ipex-version }} --extra-index-url https://download.pytorch.org/whl/cpu
42+
pip install intel_extension_for_pytorch==${{ matrix.ipex-version }}
43+
pip install Pillow parameterized
44+
pip install transformers[testing]==${{ matrix.transformers-version }}
45+
pip install .[ipex]
3546
- name: Test with Pytest
3647
run: |
37-
pytest tests/ipex/
48+
pytest tests/ipex/

.github/workflows/test_openvino.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ name: OpenVINO - Test
44

55
on:
66
push:
7-
branches: [ main ]
7+
branches:
8+
- main
9+
- v*-release
810
pull_request:
9-
branches: [ main ]
11+
branches:
12+
- main
1013

1114
concurrency:
1215
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -17,23 +20,27 @@ jobs:
1720
strategy:
1821
fail-fast: false
1922
matrix:
20-
python-version: [3.8, 3.11]
23+
python-version: ["3.8", "3.12"]
24+
transformers-version: ["4.36.0", "4.42.*"]
2125
os: [ubuntu-latest]
2226

2327
runs-on: ${{ matrix.os }}
2428
steps:
25-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v4
2630
- name: Setup Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v2
31+
uses: actions/setup-python@v5
2832
with:
2933
python-version: ${{ matrix.python-version }}
3034
- name: Install dependencies
3135
run: |
3236
python -m pip install --upgrade pip
3337
# install PyTorch CPU version to avoid installing CUDA packages on GitHub runner without GPU
3438
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
39+
pip install transformers==${{ matrix.transformers-version }}
3540
pip install .[openvino,openvino-tokenizers,tests,diffusers] onnxruntime
3641
- name: Test with Pytest
42+
env:
43+
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
3744
run: |
3845
pytest tests/openvino/ --ignore tests/openvino/test_modeling_basic.py --durations=0
3946
- name: Test basic
@@ -46,3 +53,4 @@ jobs:
4653
pip install openvino-nightly
4754
python -c "from optimum.intel import OVModelForCausalLM; OVModelForCausalLM.from_pretrained('hf-internal-testing/tiny-random-gpt2', export=True, compile=False)"
4855
optimum-cli export openvino -m hf-internal-testing/tiny-random-gpt2 gpt2-ov
56+

.github/workflows/test_openvino_basic.yml

+24-15
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,37 @@ on:
55
schedule:
66
- cron: '41 1 * * *' # run every day at 1:41
77
push:
8-
paths:
9-
- 'tests/openvino/test_modeling_basic.py'
10-
- '.github/workflows/test_openvino_basic.yml'
8+
branches:
9+
- v*-release
1110
pull_request:
12-
paths:
13-
- 'tests/openvino/test_modeling_basic.py'
14-
- '.github/workflows/test_openvino_basic.yml'
11+
types: [opened, synchronize, reopened, labeled]
1512

1613
concurrency:
1714
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1815
cancel-in-progress: true
1916

2017
jobs:
2118
build:
19+
if: ${{ (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule') || (github.event_name == 'push') || contains( github.event.pull_request.labels.*.name, 'openvino-test') }}
2220
strategy:
2321
fail-fast: false
2422
matrix:
2523
# Testing lower and upper bound of supported Python versions
2624
# This also ensures that the test fails if dependencies break for Python 3.7
27-
python-version: ["3.8", "3.11"]
28-
transformers: ['transformers']
29-
optimum: ['optimum', 'git+https://github.com/huggingface/optimum.git']
25+
python-version: ["3.8", "3.12"]
26+
os: ["ubuntu-22.04", "windows-latest"]
27+
transformers-version: ["4.42.*"]
28+
include:
29+
- transformers-version: "4.36.0"
30+
python-version: "3.12"
31+
os: "ubuntu-22.04"
3032

31-
runs-on: ubuntu-20.04
33+
runs-on: ${{ matrix.os }}
3234

3335
steps:
34-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v4
3537
- name: Setup Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@v2
38+
uses: actions/setup-python@v5
3739
with:
3840
python-version: ${{ matrix.python-version }}
3941

@@ -43,12 +45,19 @@ jobs:
4345
# optimum or transformers to a specific version
4446
# Install PyTorch CPU to prevent unnecessary downloading/installing of CUDA packages
4547
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
46-
pip install .[tests] openvino onnx onnxruntime ${{ matrix.optimum}} ${{ matrix.transformers }}
48+
pip install transformers==${{ matrix.transformers-version }}
49+
pip install .[tests] openvino
4750
48-
- name: Pip freeze
51+
- name: Pip freeze
4952
run: pip freeze
5053

5154
- name: Test with Pytest
5255
run: |
5356
pytest tests/openvino/test_modeling_basic.py
54-
RUN_SLOW=1 pytest tests/openvino/test_modeling.py -s -m "run_slow" --durations=0
57+
58+
- name: Slow tests
59+
run: |
60+
pip install nncf
61+
pytest tests/openvino -s -m "run_slow" --durations=0
62+
env:
63+
RUN_SLOW: 1

.github/workflows/test_openvino_examples.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
python-version: ["3.8", "3.11"]
25+
python-version: ["3.8", "3.12"]
2626

2727
runs-on: ubuntu-22.04
2828

.github/workflows/test_openvino_notebooks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
python-version: ["3.8", "3.11"]
26+
python-version: ["3.8", "3.12"]
2727

2828
runs-on: ubuntu-22.04
2929

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,8 @@ Do not forget to install requirements for every example:
239239
cd <example-folder>
240240
pip install -r requirements.txt
241241
```
242+
243+
244+
## Gaudi
245+
246+
To train your model on [Intel Gaudi AI Accelerators (HPU)](https://docs.habana.ai/en/latest/index.html), check out [Optimum Habana](https://github.com/huggingface/optimum-habana) which provides a set of tools enabling easy model loading, training and inference on single- and multi-HPU settings for different downstream tasks. After training your model, feel free to submit it to the Intel [leaderboard](https://huggingface.co/spaces/Intel/powered_by_intel_llm_leaderboard) which is designed to evaluate, score, and rank open-source LLMs that have been pre-trained or fine-tuned on Intel Hardwares. Models submitted to the leaderboard will be evaluated on the Intel Developer Cloud. The evaluation platform consists of Gaudi Accelerators and Xeon CPUs running benchmarks from the Eleuther AI Language Model Evaluation Harness.

docker/Dockerfile.intel

+21-38
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# https://docs.docker.com/develop/develop-images/build_enhancements/
1010

1111
ARG BASE_IMAGE=ubuntu:22.04
12-
FROM ${BASE_IMAGE} AS dev-base
12+
FROM ${BASE_IMAGE}
13+
1314
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
14-
apt-get update && \
15-
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
15+
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
1616
ca-certificates \
1717
git \
1818
curl \
@@ -25,46 +25,29 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
2525
libjpeg-dev \
2626
pybind11-dev \
2727
libpng-dev \
28-
pybind11-dev \
29-
&& rm -rf /var/lib/apt/lists/*
28+
python3 \
29+
python3-pip \
30+
&& rm -rf /var/lib/apt/lists/*"
3031
RUN /usr/sbin/update-ccache-symlinks
3132
RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache
32-
ENV PATH /opt/conda/bin:$PATH
3333

34-
FROM dev-base as conda
35-
ARG PYTHON_VERSION=3.10
36-
RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
37-
chmod +x ~/miniconda.sh && \
38-
~/miniconda.sh -b -p /opt/conda && \
39-
rm ~/miniconda.sh && \
40-
/opt/conda/bin/conda install -y python=${PYTHON_VERSION} conda-build pyyaml numpy ipython mkl mkl-include ninja cython typing pybind11 Pillow && \
41-
/opt/conda/bin/conda clean -ya
34+
ARG IPEX_VERSION=2.3.100
35+
ARG PYTORCH_VERSION=2.3.1
36+
ARG TORCHVISION_VERSION=0.18.1+cpu
37+
ARG TORCHAUDIO_VERSION=2.3.1+cpu
4238

43-
FROM dev-base AS build
44-
ARG IPEX_VERSION=v1.13.0
45-
ARG PYTORCH_VERSION=v1.13.0
46-
ARG TORCHVISION_VERSION=0.13.0+cpu
47-
ARG TORCHAUDIO_VERSION=0.13.0+cpu
48-
COPY --from=conda /opt/conda /opt/conda
49-
RUN --mount=type=cache,target=/opt/ccache \
50-
python -m pip install --no-cache-dir torch==${PYTORCH_VERSION}+cpu torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} -f https://download.pytorch.org/whl/torch_stable.html && \
51-
git clone https://github.com/intel/intel-extension-for-pytorch && \
52-
cd intel-extension-for-pytorch && \
53-
git checkout ${IPEX_VERSION} && \
54-
git submodule sync && \
55-
git submodule update --init --recursive && \
56-
python -m pip install --no-cache-dir -r requirements.txt && \
57-
python setup.py bdist_wheel && \
58-
python -m pip install --no-cache-dir dist/*.whl && \
59-
cd .. && rm -rf intel-extension-for-pytorch
39+
RUN python3 -m pip install --no-cache-dir \
40+
torch==${PYTORCH_VERSION}+cpu \
41+
torchvision==${TORCHVISION_VERSION} \
42+
torchaudio==${TORCHAUDIO_VERSION} \
43+
-f https://download.pytorch.org/whl/torch_stable.html && \
44+
python3 -m pip install intel-extension-for-pytorch==$IPEX_VERSION && \
45+
python3 -m pip install oneccl_bind_pt --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/us/
6046

61-
FROM dev-base as dev
62-
COPY --from=build /opt/conda /opt/conda
6347
ARG OMP_NUM_THREADS=1
64-
ENV OMP_NUM_THREADS ${OMP_NUM_THREADS}
48+
ENV OMP_NUM_THREADS=${OMP_NUM_THREADS}
6549
ARG KMP_BLOCKTIME=1
66-
ENV KMP_BLOCKTIME ${KMP_BLOCKTIME}
50+
ENV KMP_BLOCKTIME=${KMP_BLOCKTIME}
6751
ARG KMP_HW_SUBSET=1T
68-
ENV KMP_HW_SUBSET ${KMP_HW_SUBSET}
69-
ENV LD_PRELOAD "/opt/conda/lib/libiomp5.so /usr/lib/x86_64-linux-gnu/libtcmalloc.so"
70-
ENV LD_LIBRARY_PATH "/opt/conda/lib/python3.8/site-packages/lib/"
52+
ENV KMP_HW_SUBSET=${KMP_HW_SUBSET}
53+
ENV LD_PRELOAD="/usr/local/lib/libiomp5.so /usr/lib/x86_64-linux-gnu/libtcmalloc.so"

docs/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ RUN npm install npm@9.8.1 -g && \
2525
RUN python3 -m pip install --no-cache-dir --upgrade pip
2626
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/doc-builder.git
2727
RUN git clone $clone_url && cd optimum-intel && git checkout $commit_sha
28-
RUN python3 -m pip install --no-cache-dir ./optimum-intel[neural-compressor,openvino,nncf,quality]
28+
RUN python3 -m pip install --no-cache-dir ./optimum-intel[neural-compressor,openvino,diffusers,quality]

docs/source/_toctree.yml

+18-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@
44
- local: installation
55
title: Installation
66
- sections:
7-
- local: optimization_inc
7+
- local: neural_compressor/optimization
88
title: Optimization
9-
- local: distributed_training
9+
- local: neural_compressor/distributed_training
1010
title: Distributed Training
11-
- local: reference_inc
11+
- local: neural_compressor/reference
1212
title: Reference
1313
title: Neural Compressor
1414
- sections:
15-
- local: inference
16-
title: Models for inference
17-
- local: optimization_ov
15+
- local: openvino/export
16+
title: Export
17+
- local: openvino/inference
18+
title: Inference
19+
- local: openvino/optimization
1820
title: Optimization
19-
- local: reference_ov
21+
- local: openvino/models
22+
title: Supported Models
23+
- local: openvino/reference
2024
title: Reference
25+
- sections:
26+
- local: openvino/tutorials/notebooks
27+
title: Notebooks
28+
- local: openvino/tutorials/diffusers
29+
title: Generate images with Diffusion models
30+
title: Tutorials
31+
isExpanded: false
2132
title: OpenVINO
2233
title: Optimum Intel
2334
isExpanded: false

docs/source/index.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ limitations under the License.
2525

2626
<div class="mt-10">
2727
<div class="w-full flex flex-col space-x-4 md:grid md:grid-cols-2 md:gap-x-5">
28-
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./optimization_inc"
28+
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="neural_compressor/optimization"
2929
><div class="w-full text-center bg-gradient-to-br from-blue-400 to-blue-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">Neural Compressor</div>
3030
<p class="text-gray-700">Learn how to apply compression techniques such as quantization, pruning and knowledge distillation to speed up inference with Intel Neural Compressor.</p>
3131
</a>
32-
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./inference"
32+
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="openvino/export"
3333
><div class="w-full text-center bg-gradient-to-br from-purple-400 to-purple-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">OpenVINO</div>
3434
<p class="text-gray-700">Learn how to run inference with OpenVINO Runtime and to apply quantization, pruning and knowledge distillation on your model to further speed up inference.</p>
3535
</a>

0 commit comments

Comments
 (0)