Skip to content

Commit b4ba6d0

Browse files
authored
Merge branch 'main' into ipex-xpu
2 parents 0d3930a + 3586b5b commit b4ba6d0

File tree

87 files changed

+5842
-3427
lines changed

Some content is hidden

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

87 files changed

+5842
-3427
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 .
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build and Test Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docker/Dockerfile.intel'
9+
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- 'docker/Dockerfile.intel'
15+
16+
jobs:
17+
build_and_run:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Build and Run Docker Image
28+
run: |
29+
IMAGE_NAME="intel_image:latest"
30+
docker build -f docker/Dockerfile.intel -t $IMAGE_NAME .
31+
if [ $? -ne 0 ]; then
32+
echo "Docker image build failed."
33+
exit 1
34+
fi
35+
CONTAINER_ID=$(docker run -d $IMAGE_NAME tail -f /dev/null)
36+
if docker inspect -f '{{.State.Running}}' $CONTAINER_ID 2>/dev/null | grep -q 'true'; then
37+
echo "Container is running."
38+
else
39+
echo "Container failed to start."
40+
docker logs $CONTAINER_ID 2>/dev/null || echo "No container ID found."
41+
exit 1
42+
fi
43+
docker stop $CONTAINER_ID
44+
docker rm $CONTAINER_ID

.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

+29-20
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,45 @@ 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-
transformers-version: [4.39.0, 4.41.2]
22-
os: [ubuntu-latest]
24+
python-version: [3.9]
25+
transformers-version: ["4.39.0", "4.44.*"]
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
2331

24-
runs-on: ${{ matrix.os }}
2532
steps:
26-
- uses: actions/checkout@v2
27-
- name: Setup Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v2
29-
with:
30-
python-version: ${{ matrix.python-version }}
31-
- name: Install dependencies
32-
run: |
33-
python -m pip install --upgrade pip
34-
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cpu
35-
pip install .[ipex,tests]
36-
pip install transformers==${{ matrix.transformers-version }}
37-
- name: Test with Pytest
38-
run: |
39-
pytest tests/ipex/
33+
- uses: actions/checkout@v2
34+
- name: Setup Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
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]
46+
- name: Test with Pytest
47+
run: |
48+
pytest tests/ipex/

.github/workflows/test_openvino.yml

+33-26
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 }}
@@ -18,32 +21,36 @@ jobs:
1821
fail-fast: false
1922
matrix:
2023
python-version: ["3.8", "3.12"]
24+
transformers-version: ["4.36.0", "4.44.*"]
2125
os: [ubuntu-latest]
2226

2327
runs-on: ${{ matrix.os }}
2428
steps:
25-
- uses: actions/checkout@v4
26-
- name: Setup Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: ${{ matrix.python-version }}
30-
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
# install PyTorch CPU version to avoid installing CUDA packages on GitHub runner without GPU
34-
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
35-
pip install .[openvino,openvino-tokenizers,tests,diffusers] onnxruntime
36-
- name: Test with Pytest
37-
run: |
38-
pytest tests/openvino/ --ignore tests/openvino/test_modeling_basic.py --durations=0
39-
- name: Test basic
40-
run: |
41-
pip uninstall -y nncf
42-
pytest tests/openvino/test_modeling_basic.py
43-
- name: Test openvino-nightly
44-
run: |
45-
pip uninstall -y openvino
46-
pip install openvino-nightly
47-
python -c "from optimum.intel import OVModelForCausalLM; OVModelForCausalLM.from_pretrained('hf-internal-testing/tiny-random-gpt2', export=True, compile=False)"
48-
optimum-cli export openvino -m hf-internal-testing/tiny-random-gpt2 gpt2-ov
29+
- uses: actions/checkout@v4
30+
- name: Setup Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
4934

35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
# install PyTorch CPU version to avoid installing CUDA packages on GitHub runner without GPU
39+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
40+
pip install .[openvino,openvino-tokenizers,tests,diffusers] onnxruntime
41+
pip install transformers==${{ matrix.transformers-version }}
42+
43+
- name: Test with Pytest
44+
env:
45+
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
46+
run: |
47+
pytest tests/openvino/ --ignore tests/openvino/test_modeling_basic.py --durations=0
48+
- name: Test basic
49+
run: |
50+
pip uninstall -y nncf
51+
pytest tests/openvino/test_modeling_basic.py
52+
- name: Test openvino-nightly
53+
run: |
54+
pip install -U --pre openvino openvino-tokenizers --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
55+
python -c "from optimum.intel import OVModelForCausalLM; OVModelForCausalLM.from_pretrained('hf-internal-testing/tiny-random-gpt2', export=True, compile=False)"
56+
optimum-cli export openvino -m hf-internal-testing/tiny-random-gpt2 gpt2-ov

.github/workflows/test_openvino_basic.yml

+39-34
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,62 @@ name: OpenVINO - Basic Test
33
on:
44
workflow_dispatch:
55
schedule:
6-
- cron: '41 1 * * *' # run every day at 1:41
6+
- 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
2725
python-version: ["3.8", "3.12"]
28-
optimum: ['optimum', 'git+https://github.com/huggingface/optimum.git']
2926
os: ["ubuntu-22.04", "windows-latest"]
27+
transformers-version: ["4.44.*"]
28+
include:
29+
- python-version: "3.12"
30+
os: "ubuntu-22.04"
31+
transformers-version: "4.36.0"
3032

3133
runs-on: ${{ matrix.os }}
3234

3335
steps:
34-
- uses: actions/checkout@v4
35-
- name: Setup Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@v5
37-
with:
38-
python-version: ${{ matrix.python-version }}
39-
40-
- name: Install dependencies
41-
run: |
42-
# Install openvino manually to prevent dependency conflicts when .[openvino] pins
43-
# optimum or transformers to a specific version
44-
# Install PyTorch CPU to prevent unnecessary downloading/installing of CUDA packages
45-
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
46-
pip install .[tests] openvino onnxruntime ${{ matrix.optimum}}
47-
48-
- name: Pip freeze
49-
run: pip freeze
50-
51-
- name: Test with Pytest
52-
run: |
53-
pytest tests/openvino/test_modeling_basic.py
54-
55-
- name: Slow tests
56-
run: |
57-
pytest tests/openvino/test_modeling.py -s -m "run_slow" --durations=0
58-
env:
59-
RUN_SLOW: 1
36+
- uses: actions/checkout@v4
37+
- name: Setup Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Install dependencies
43+
run: |
44+
python -m pip install --upgrade pip
45+
# Install PyTorch CPU to prevent unnecessary downloading/installing of CUDA packages
46+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
47+
# Install openvino manually to prevent dependency conflicts when .[openvino] pins
48+
# optimum or transformers to a specific version
49+
pip install .[tests] openvino
50+
pip install transformers==${{ matrix.transformers-version }}
51+
52+
- name: Pip freeze
53+
run: pip freeze
54+
55+
- name: Test with Pytest
56+
run: |
57+
pytest tests/openvino/test_modeling_basic.py
58+
59+
- name: Slow tests
60+
run: |
61+
pip install nncf
62+
pytest tests/openvino -s -m "run_slow" --durations=0
63+
env:
64+
RUN_SLOW: 1

.github/workflows/test_openvino_notebooks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ jobs:
4040
# ffmpeg, torchaudio and pillow are required for image classification and audio classification pipelines
4141
sudo apt-get install ffmpeg
4242
pip install torch torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
43-
pip install ".[tests, openvino]" nbval
4443
pip install -r notebooks/openvino/requirements.txt
44+
pip install .[tests,openvino] nbval
4545
4646
- run: free -h
4747
- run: lscpu

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Below are examples of how to use OpenVINO and its [NNCF](https://docs.openvino.a
7272

7373
#### Export:
7474

75-
It is possible to export your model to the [OpenVINO IR](https://docs.openvino.ai/2024/documentation/openvino-ir-format.html) format with the CLI :
75+
It is also possible to export your model to the [OpenVINO IR](https://docs.openvino.ai/2024/documentation/openvino-ir-format.html) format with the CLI :
7676

7777
```plain
7878
optimum-cli export openvino --model gpt2 ov_model
@@ -223,15 +223,14 @@ To load your IPEX model, you can just replace your `AutoModelForXxx` class with
223223
tokenizer = AutoTokenizer.from_pretrained(model_id)
224224
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
225225
results = pipe("He's a dreadful magician and")
226-
227226
```
228227

229228
For more details, please refer to the [documentation](https://intel.github.io/intel-extension-for-pytorch/#introduction).
230229

231230

232231
## Running the examples
233232

234-
Check out the [`examples`](https://github.com/huggingface/optimum-intel/tree/main/examples) directory to see how 🤗 Optimum Intel can be used to optimize models and accelerate inference.
233+
Check out the [`examples`](https://github.com/huggingface/optimum-intel/tree/main/examples) and [`notebooks`](https://github.com/huggingface/optimum-intel/tree/main/notebooks) directory to see how 🤗 Optimum Intel can be used to optimize models and accelerate inference.
235234

236235
Do not forget to install requirements for every example:
237236

0 commit comments

Comments
 (0)