Skip to content

Commit

Permalink
Merge from main branch and update code style
Browse files Browse the repository at this point in the history
Signed-off-by: Cheng, Penghui <[email protected]>
  • Loading branch information
PenghuiCheng committed Mar 24, 2024
2 parents f970272 + 77503fc commit e5558b0
Show file tree
Hide file tree
Showing 28 changed files with 935 additions and 1,352 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test_openvino_examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: OpenVINO - Examples Test

on:
workflow_dispatch:
schedule:
- cron: 0 1 * * 1 # run weekly: every Monday at 1am
push:
paths:
- '.github/workflows/test_openvino_examples.yml'
- 'examples/openvino/*'
pull_request:
paths:
- '.github/workflows/test_openvino_examples.yml'
- 'examples/openvino/*'

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

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10"]

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install optimum[openvino] jstyleson nncf pytest
pip install -r examples/openvino/audio-classification/requirements.txt
pip install -r examples/openvino/image-classification/requirements.txt
pip install -r examples/openvino/question-answering/requirements.txt
pip install -r examples/openvino/text-classification/requirements.txt
- name: Test examples
run: |
python -m pytest examples/openvino/test_examples.py
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ REAL_CLONE_URL = $(if $(CLONE_URL),$(CLONE_URL),$(DEFAULT_CLONE_URL))
# Run code quality checks
style_check:
black --check .
ruff .
ruff check .

style:
black .
ruff . --fix
ruff check . --fix

# Run tests for the library
test:
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,26 @@ Quantization aware training (QAT) is applied in order to simulate the effects of
You can find more examples in the [documentation](https://huggingface.co/docs/optimum/intel/index).


## IPEX
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.
```diff
from transformers import AutoTokenizer, pipeline
- from transformers import AutoModelForCausalLM
+ from optimum.intel import IPEXModelForCausalLM


model_id = "gpt2"
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
+ model = IPEXModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, export=True)
tokenizer = AutoTokenizer.from_pretrained(model_id)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
results = pipe("He's a dreadful magician and")

```

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


## Running the examples

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.
Expand Down
9 changes: 6 additions & 3 deletions examples/neural_compressor/language-modeling/run_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,18 @@ class OptimizationArguments:
metadata={"help": "Quantization methodology for weight only quantization. Choose from 'RTN' and 'GPTQ'."},
)
damp_percent: float = field(

default=0.01,
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"},
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"
},
)
gptq_block_size: int = field(
default=128,
metadata={"help": "Block size. sub weight matrix size to run GPTQ."},
)
num_calibration_samples: int = field(default=128, metadata={"help": "Number of examples to use for the GPTQ calibration step."})
num_calibration_samples: int = field(
default=128, metadata={"help": "Number of examples to use for the GPTQ calibration step."}
)
use_max_length: bool = field(
default=False,
metadata={"help": "Set all sequence length to be same length of args.gptq_pad_max_length"},
Expand Down
111 changes: 0 additions & 111 deletions examples/openvino/stable-diffusion/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions examples/openvino/stable-diffusion/requirements.txt

This file was deleted.

Loading

0 comments on commit e5558b0

Please sign in to comment.