Skip to content

Commit

Permalink
Merge branch 'main' into check-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-savelyevv committed Jul 26, 2024
2 parents 12814fc + 31430d6 commit 3d4c41e
Show file tree
Hide file tree
Showing 76 changed files with 4,805 additions and 2,223 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
- name: Check style with ruff
run: |
source venv/bin/activate
ruff .
ruff check .
29 changes: 29 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Security Checks

on:
push:

permissions:
contents: read

jobs:
secrets:
runs-on: ubuntu-latest
steps:
- shell: bash
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "depth=$(($(jq length <<< '${{ toJson(github.event.commits) }}') + 2))" >> $GITHUB_ENV
echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV
fi
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "depth=$((${{ github.event.pull_request.commits }}+2))" >> $GITHUB_ENV
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{env.branch}}
fetch-depth: ${{env.depth}}
- name: Scan for secrets
uses: trufflesecurity/trufflehog@main
7 changes: 5 additions & 2 deletions .github/workflows/test_inc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ name: Intel Neural Compressor - Test

on:
push:
branches: [ main ]
branches:
- main
- v*-release
pull_request:
branches: [ main ]
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/test_ipex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@ name: Intel IPEX - Test

on:
push:
branches: [ main ]
branches:
- main
- v*-release
pull_request:
branches: [ main ]
branches:
- main

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

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-latest]
python-version: [3.9]
transformers-version: [4.39.0, 4.42.3]
ipex-version: [2.2.0, 2.3.*]
include:
- python-version: 3.8
transformers-version: 4.39.0
ipex-version: 2.2.0

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand All @@ -30,8 +38,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install torch torchaudio torchvision --extra-index-url https://download.pytorch.org/whl/cpu
pip install .[ipex,tests]
pip install torch==${{ matrix.ipex-version }} --extra-index-url https://download.pytorch.org/whl/cpu
pip install intel_extension_for_pytorch==${{ matrix.ipex-version }}
pip install Pillow parameterized
pip install transformers[testing]==${{ matrix.transformers-version }}
pip install .[ipex]
- name: Test with Pytest
run: |
pytest tests/ipex/
pytest tests/ipex/
18 changes: 13 additions & 5 deletions .github/workflows/test_openvino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ name: OpenVINO - Test

on:
push:
branches: [ main ]
branches:
- main
- v*-release
pull_request:
branches: [ main ]
branches:
- main

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

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# install PyTorch CPU version to avoid installing CUDA packages on GitHub runner without GPU
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install transformers==${{ matrix.transformers-version }}
pip install .[openvino,openvino-tokenizers,tests,diffusers] onnxruntime
- name: Test with Pytest
env:
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
run: |
pytest tests/openvino/ --ignore tests/openvino/test_modeling_basic.py --durations=0
- name: Test basic
Expand All @@ -46,3 +53,4 @@ jobs:
pip install openvino-nightly
python -c "from optimum.intel import OVModelForCausalLM; OVModelForCausalLM.from_pretrained('hf-internal-testing/tiny-random-gpt2', export=True, compile=False)"
optimum-cli export openvino -m hf-internal-testing/tiny-random-gpt2 gpt2-ov
39 changes: 24 additions & 15 deletions .github/workflows/test_openvino_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@ on:
schedule:
- cron: '41 1 * * *' # run every day at 1:41
push:
paths:
- 'tests/openvino/test_modeling_basic.py'
- '.github/workflows/test_openvino_basic.yml'
branches:
- v*-release
pull_request:
paths:
- 'tests/openvino/test_modeling_basic.py'
- '.github/workflows/test_openvino_basic.yml'
types: [opened, synchronize, reopened, labeled]

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

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

runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}

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

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

- name: Test with Pytest
run: |
pytest tests/openvino/test_modeling_basic.py
RUN_SLOW=1 pytest tests/openvino/test_modeling.py -s -m "run_slow" --durations=0
- name: Slow tests
run: |
pip install nncf
pytest tests/openvino -s -m "run_slow" --durations=0
env:
RUN_SLOW: 1
2 changes: 1 addition & 1 deletion .github/workflows/test_openvino_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]

runs-on: ubuntu-22.04

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_openvino_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]

runs-on: ubuntu-22.04

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,8 @@ Do not forget to install requirements for every example:
cd <example-folder>
pip install -r requirements.txt
```


## Gaudi

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.
59 changes: 21 additions & 38 deletions docker/Dockerfile.intel
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# https://docs.docker.com/develop/develop-images/build_enhancements/

ARG BASE_IMAGE=ubuntu:22.04
FROM ${BASE_IMAGE} AS dev-base
FROM ${BASE_IMAGE}

RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
ca-certificates \
git \
curl \
Expand All @@ -25,46 +25,29 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
libjpeg-dev \
pybind11-dev \
libpng-dev \
pybind11-dev \
&& rm -rf /var/lib/apt/lists/*
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*"
RUN /usr/sbin/update-ccache-symlinks
RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache
ENV PATH /opt/conda/bin:$PATH

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

FROM dev-base AS build
ARG IPEX_VERSION=v1.13.0
ARG PYTORCH_VERSION=v1.13.0
ARG TORCHVISION_VERSION=0.13.0+cpu
ARG TORCHAUDIO_VERSION=0.13.0+cpu
COPY --from=conda /opt/conda /opt/conda
RUN --mount=type=cache,target=/opt/ccache \
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 && \
git clone https://github.com/intel/intel-extension-for-pytorch && \
cd intel-extension-for-pytorch && \
git checkout ${IPEX_VERSION} && \
git submodule sync && \
git submodule update --init --recursive && \
python -m pip install --no-cache-dir -r requirements.txt && \
python setup.py bdist_wheel && \
python -m pip install --no-cache-dir dist/*.whl && \
cd .. && rm -rf intel-extension-for-pytorch
RUN python3 -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 && \
python3 -m pip install intel-extension-for-pytorch==$IPEX_VERSION && \
python3 -m pip install oneccl_bind_pt --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/us/

FROM dev-base as dev
COPY --from=build /opt/conda /opt/conda
ARG OMP_NUM_THREADS=1
ENV OMP_NUM_THREADS ${OMP_NUM_THREADS}
ENV OMP_NUM_THREADS=${OMP_NUM_THREADS}
ARG KMP_BLOCKTIME=1
ENV KMP_BLOCKTIME ${KMP_BLOCKTIME}
ENV KMP_BLOCKTIME=${KMP_BLOCKTIME}
ARG KMP_HW_SUBSET=1T
ENV KMP_HW_SUBSET ${KMP_HW_SUBSET}
ENV LD_PRELOAD "/opt/conda/lib/libiomp5.so /usr/lib/x86_64-linux-gnu/libtcmalloc.so"
ENV LD_LIBRARY_PATH "/opt/conda/lib/python3.8/site-packages/lib/"
ENV KMP_HW_SUBSET=${KMP_HW_SUBSET}
ENV LD_PRELOAD="/usr/local/lib/libiomp5.so /usr/lib/x86_64-linux-gnu/libtcmalloc.so"
2 changes: 1 addition & 1 deletion docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ RUN npm install [email protected] -g && \
RUN python3 -m pip install --no-cache-dir --upgrade pip
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/doc-builder.git
RUN git clone $clone_url && cd optimum-intel && git checkout $commit_sha
RUN python3 -m pip install --no-cache-dir ./optimum-intel[neural-compressor,openvino,nncf,quality]
RUN python3 -m pip install --no-cache-dir ./optimum-intel[neural-compressor,openvino,diffusers,quality]
25 changes: 18 additions & 7 deletions docs/source/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,31 @@
- local: installation
title: Installation
- sections:
- local: optimization_inc
- local: neural_compressor/optimization
title: Optimization
- local: distributed_training
- local: neural_compressor/distributed_training
title: Distributed Training
- local: reference_inc
- local: neural_compressor/reference
title: Reference
title: Neural Compressor
- sections:
- local: inference
title: Models for inference
- local: optimization_ov
- local: openvino/export
title: Export
- local: openvino/inference
title: Inference
- local: openvino/optimization
title: Optimization
- local: reference_ov
- local: openvino/models
title: Supported Models
- local: openvino/reference
title: Reference
- sections:
- local: openvino/tutorials/notebooks
title: Notebooks
- local: openvino/tutorials/diffusers
title: Generate images with Diffusion models
title: Tutorials
isExpanded: false
title: OpenVINO
title: Optimum Intel
isExpanded: false
4 changes: 2 additions & 2 deletions docs/source/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ limitations under the License.

<div class="mt-10">
<div class="w-full flex flex-col space-x-4 md:grid md:grid-cols-2 md:gap-x-5">
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./optimization_inc"
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="neural_compressor/optimization"
><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>
<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>
</a>
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./inference"
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="openvino/export"
><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>
<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>
</a>
Expand Down
Loading

0 comments on commit 3d4c41e

Please sign in to comment.