Skip to content

Commit e5558b0

Browse files
committed
Merge from main branch and update code style
Signed-off-by: Cheng, Penghui <penghui.cheng@intel.com>
2 parents f970272 + 77503fc commit e5558b0

28 files changed

+935
-1352
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: OpenVINO - Examples Test
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: 0 1 * * 1 # run weekly: every Monday at 1am
7+
push:
8+
paths:
9+
- '.github/workflows/test_openvino_examples.yml'
10+
- 'examples/openvino/*'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/test_openvino_examples.yml'
14+
- 'examples/openvino/*'
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
python-version: ["3.8", "3.10"]
26+
27+
runs-on: ubuntu-20.04
28+
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Setup Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v2
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Install dependencies
37+
run: |
38+
pip install optimum[openvino] jstyleson nncf pytest
39+
pip install -r examples/openvino/audio-classification/requirements.txt
40+
pip install -r examples/openvino/image-classification/requirements.txt
41+
pip install -r examples/openvino/question-answering/requirements.txt
42+
pip install -r examples/openvino/text-classification/requirements.txt
43+
44+
- name: Test examples
45+
run: |
46+
python -m pytest examples/openvino/test_examples.py

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ REAL_CLONE_URL = $(if $(CLONE_URL),$(CLONE_URL),$(DEFAULT_CLONE_URL))
2222
# Run code quality checks
2323
style_check:
2424
black --check .
25-
ruff .
25+
ruff check .
2626

2727
style:
2828
black .
29-
ruff . --fix
29+
ruff check . --fix
3030

3131
# Run tests for the library
3232
test:

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,26 @@ Quantization aware training (QAT) is applied in order to simulate the effects of
202202
You can find more examples in the [documentation](https://huggingface.co/docs/optimum/intel/index).
203203

204204

205+
## IPEX
206+
To load your IPEX model, you can just replace your `AutoModelForXxx` class with the corresponding `IPEXModelForXxx` class. You can set `export=True` to load a PyTorch checkpoint, export your model via TorchScript and apply IPEX optimizations : both operators optimization (replaced with customized IPEX operators) and graph-level optimization (like operators fusion) will be applied on your model.
207+
```diff
208+
from transformers import AutoTokenizer, pipeline
209+
- from transformers import AutoModelForCausalLM
210+
+ from optimum.intel import IPEXModelForCausalLM
211+
212+
213+
model_id = "gpt2"
214+
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
215+
+ model = IPEXModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, export=True)
216+
tokenizer = AutoTokenizer.from_pretrained(model_id)
217+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
218+
results = pipe("He's a dreadful magician and")
219+
220+
```
221+
222+
For more details, please refer to the [documentation](https://intel.github.io/intel-extension-for-pytorch/#introduction).
223+
224+
205225
## Running the examples
206226

207227
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.

examples/neural_compressor/language-modeling/run_clm.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,18 @@ class OptimizationArguments:
228228
metadata={"help": "Quantization methodology for weight only quantization. Choose from 'RTN' and 'GPTQ'."},
229229
)
230230
damp_percent: float = field(
231-
232231
default=0.01,
233-
metadata={"help": "Percentage of Hessian's diagonal values average, which will be added to Hessian's diagonal to increase numerical stability, used for GPTQ quantization"},
232+
metadata={
233+
"help": "Percentage of Hessian's diagonal values average, which will be added to Hessian's diagonal to increase numerical stability, used for GPTQ quantization"
234+
},
234235
)
235236
gptq_block_size: int = field(
236237
default=128,
237238
metadata={"help": "Block size. sub weight matrix size to run GPTQ."},
238239
)
239-
num_calibration_samples: int = field(default=128, metadata={"help": "Number of examples to use for the GPTQ calibration step."})
240+
num_calibration_samples: int = field(
241+
default=128, metadata={"help": "Number of examples to use for the GPTQ calibration step."}
242+
)
240243
use_max_length: bool = field(
241244
default=False,
242245
metadata={"help": "Set all sequence length to be same length of args.gptq_pad_max_length"},

examples/openvino/stable-diffusion/README.md

-111
This file was deleted.

examples/openvino/stable-diffusion/requirements.txt

-6
This file was deleted.

0 commit comments

Comments
 (0)