From ba106c23e95450fcf141a160c43ef863aca95b7c Mon Sep 17 00:00:00 2001 From: Helena Date: Wed, 24 Apr 2024 17:35:20 +0000 Subject: [PATCH] Update workflow to run example tests --- .github/workflows/test_openvino_examples.yml | 20 +++++++++---------- .github/workflows/test_openvino_notebooks.yml | 4 ++-- .../openvino/question-answering/README.md | 3 ++- notebooks/openvino/requirements.txt | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test_openvino_examples.yml b/.github/workflows/test_openvino_examples.yml index 61b411c967..747afa31b5 100644 --- a/.github/workflows/test_openvino_examples.yml +++ b/.github/workflows/test_openvino_examples.yml @@ -7,11 +7,11 @@ on: push: paths: - '.github/workflows/test_openvino_examples.yml' - - 'examples/openvino/*' + - 'examples/openvino/**' pull_request: paths: - '.github/workflows/test_openvino_examples.yml' - - 'examples/openvino/*' + - 'examples/openvino/**' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -22,9 +22,9 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.10"] + python-version: ["3.8", "3.11"] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 @@ -35,12 +35,12 @@ jobs: - 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 + pip install .[openvino] jstyleson pytest + pip install -r examples/openvino/audio-classification/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu + pip install -r examples/openvino/image-classification/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu + pip install -r examples/openvino/question-answering/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu + pip install -r examples/openvino/text-classification/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu - name: Test examples run: | - python -m pytest examples/openvino/test_examples.py \ No newline at end of file + python -m pytest examples/openvino/test_examples.py diff --git a/.github/workflows/test_openvino_notebooks.yml b/.github/workflows/test_openvino_notebooks.yml index 7b037d0565..ed77077e87 100644 --- a/.github/workflows/test_openvino_notebooks.yml +++ b/.github/workflows/test_openvino_notebooks.yml @@ -23,9 +23,9 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.10"] + python-version: ["3.8", "3.11"] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 diff --git a/examples/openvino/question-answering/README.md b/examples/openvino/question-answering/README.md index c57d332e63..94efc201bc 100644 --- a/examples/openvino/question-answering/README.md +++ b/examples/openvino/question-answering/README.md @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -# Question answering +# Question nswering This folder contains [`run_qa.py`](https://github.com/huggingface/optimum/blob/main/examples/openvino/question-answering/run_qa.py), a script to fine-tune a 🤗 Transformers model on a question answering dataset while applying quantization aware training (QAT). QAT can be easily applied by replacing the Transformers [`Trainer`](https://huggingface.co/docs/transformers/main/en/main_classes/trainer#trainer) with the Optimum [`OVTrainer`]. An `QuestionAnsweringOVTrainer` is defined in [`trainer_qa.py`](https://github.com/huggingface/optimum/blob/main/examples/openvino/question-answering/trainer_qa.py), which inherits from `OVTrainer` and is adapted to perform question answering tasks evaluation. @@ -47,6 +47,7 @@ python run_qa.py \ ``` ### Joint Pruning, Quantization and Distillation (JPQD) for BERT on SQuAD1.0 + `OVTrainer` also provides an advanced optimization workflow through the NNCF when Transformer model can be structurally pruned along with 8-bit quantization and distillation. Below is an example which demonstrates how to jointly prune, quantize BERT-base for SQuAD 1.0 using NNCF config `--nncf_compression_config` and distill from BERT-large teacher. This example closely resembles the movement sparsification work of [Lagunas et al., 2021, Block Pruning For Faster Transformers](https://arxiv.org/pdf/2109.04838.pdf). This example takes about 12 hours with a single V100 GPU and ~40% of the weights of the Transformer blocks were pruned. For launching the script on multiple GPUs specify `--nproc-per-node=`. Note, that different batch size and other hyperparameters qmight be required to achieve the same results as on a single GPU. More on how to configure movement sparsity, see NNCF documentation [here](https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/torch/sparsity/movement/MovementSparsity.md). diff --git a/notebooks/openvino/requirements.txt b/notebooks/openvino/requirements.txt index 3432e949e9..bb7a517cff 100644 --- a/notebooks/openvino/requirements.txt +++ b/notebooks/openvino/requirements.txt @@ -1,4 +1,4 @@ -optimum-intel[openvino, nncf] +optimum-intel[openvino] datasets evaluate[evaluator] ipywidgets