Skip to content

Commit 06f6b0d

Browse files
committed
Merge branch 'main' into add-owlv2
2 parents f366dd3 + bb21ae7 commit 06f6b0d

32 files changed

+1044
-631
lines changed

.github/workflows/build_main_documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
- name: Combine subpackage documentation
172172
run: |
173173
cd optimum
174-
sudo python docs/combine_docs.py --subpackages habana intel neuron furiosa amd --version ${{ env.VERSION }}
174+
sudo python docs/combine_docs.py --subpackages nvidia amd intel neuron habana furiosa --version ${{ env.VERSION }}
175175
cd ..
176176
177177
- name: Push to repositories

.github/workflows/build_pr_documentation.yml

+16-31
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
name: Build PR documentation
22

3-
# WARNING: As this workflow supports the pull_request_target event, please exercise extra care when editing it.
4-
53
on:
64
workflow_dispatch:
7-
pull_request_target:
5+
pull_request:
86
branches: [ main ]
9-
types: [ opened, synchronize, reopened, labeled ]
107
paths:
118
- "optimum/**.py"
129
- "docs/**.mdx"
@@ -17,14 +14,7 @@ concurrency:
1714
cancel-in-progress: true
1815

1916
jobs:
20-
authorize:
21-
if: (github.event.action == 'labeled' && github.event.label.name == 'build-pr-doc') || github.event_name != 'pull_request_target' || (! github.event.pull_request.head.repo.fork)
22-
runs-on: ubuntu-latest
23-
steps:
24-
- run: true
25-
2617
build_documentation:
27-
needs: authorize
2818
runs-on: ubuntu-latest
2919
env:
3020
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
@@ -42,7 +32,6 @@ jobs:
4232
with:
4333
repository: 'huggingface/optimum'
4434
path: optimum
45-
ref: ${{ github.event.pull_request.merge_commit_sha }}
4635

4736
- uses: actions/checkout@v2
4837
with:
@@ -59,6 +48,11 @@ jobs:
5948
repository: 'huggingface/optimum-furiosa'
6049
path: optimum-furiosa
6150

51+
- uses: actions/checkout@v2
52+
with:
53+
repository: 'huggingface/optimum-amd'
54+
path: optimum-amd
55+
6256
- name: Setup environment
6357
run: |
6458
pip uninstall -y doc-builder
@@ -84,26 +78,17 @@ jobs:
8478
sudo mv intel-doc-build ../optimum
8579
cd ..
8680
81+
# TODO: enable Furiosa doc build in PRs once archive.furiosa.ai is public
8782
- name: Make Furiosa documentation
8883
run: |
89-
cd optimum-furiosa
90-
pip install .
91-
sudo apt update
92-
sudo apt install -y ca-certificates apt-transport-https gnupg
93-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 5F03AFA423A751913F249259814F888B20B09A7E
94-
# TODO: remove secrets and pull_request_target once archive.furiosa.ai is public
95-
sudo tee -a /etc/apt/auth.conf.d/furiosa.conf > /dev/null <<EOT
96-
machine archive.furiosa.ai
97-
login ${{ secrets.FURIOSA_ACCESS_KEY }}
98-
password ${{ secrets.FURIOSA_SECRET_ACCESS_KEY }}
99-
EOT
100-
sudo chmod 400 /etc/apt/auth.conf.d/furiosa.conf
101-
sudo tee -a /etc/apt/sources.list.d/furiosa.list <<EOT
102-
deb [arch=amd64] https://archive.furiosa.ai/ubuntu jammy restricted
103-
EOT
104-
sudo apt update && sudo apt install -y furiosa-libnux
105-
doc-builder build optimum.furiosa docs/source/ --build_dir furiosa-doc-build --version pr_$PR_NUMBER --version_tag_suffix "" --html --clean
106-
mv furiosa-doc-build ../optimum
84+
echo "For PRs we don't build Furiosa doc"
85+
86+
- name: Make AMD documentation
87+
run: |
88+
sudo docker system prune -a -f
89+
cd optimum-amd
90+
make doc BUILD_DIR=amd-doc-build VERSION=pr_$PR_NUMBER
91+
sudo mv amd-doc-build ../optimum
10792
cd ..
10893
10994
- name: Make Optimum documentation
@@ -116,7 +101,7 @@ jobs:
116101
- name: Combine subpackage documentation
117102
run: |
118103
cd optimum
119-
sudo python docs/combine_docs.py --subpackages habana intel neuron furiosa --version pr_$PR_NUMBER
104+
sudo python docs/combine_docs.py --subpackages nvidia amd intel neuron habana furiosa --version pr_$PR_NUMBER
120105
sudo mv optimum-doc-build ../
121106
cd ..
122107

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ python -m pip install optimum[onnxruntime]@git+https://github.com/huggingface/op
3939

4040
## Accelerated Inference
4141

42-
🤗 Optimum provides multiple tools to export and run optimized models on various ecosystems:
42+
🤗 Optimum provides multiple tools to export and run optimized models on various ecosystems:
4343

4444
- [ONNX](https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/export_a_model) / [ONNX Runtime](https://huggingface.co/docs/optimum/onnxruntime/usage_guides/models)
4545
- TensorFlow Lite

docs/combine_docs.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import yaml
77

88

9+
SUBPACKAGE_TOC_INSERT_INDEX = 2
10+
11+
912
parser = argparse.ArgumentParser(
1013
description="Script to combine doc builds from subpackages with base doc build of Optimum. "
1114
"Assumes all subpackage doc builds are present in the root of the `optimum` repo."
@@ -89,7 +92,7 @@ def add_neuron_doc(base_toc: List):
8992
"""
9093
# Update optimum table of contents
9194
base_toc.insert(
92-
1,
95+
SUBPACKAGE_TOC_INSERT_INDEX,
9396
{
9497
"sections": [
9598
{
@@ -118,9 +121,17 @@ def main():
118121
if subpackage == "neuron":
119122
# Neuron has its own doc so it is managed differently
120123
add_neuron_doc(base_toc)
124+
elif subpackage == "nvidia":
125+
# At the moment, Optimum Nvidia's doc is the README of the GitHub repo
126+
# It is linked to in optimum/docs/source/nvidia_overview.mdx
127+
continue
121128
else:
122129
subpackage_path = Path(f"{subpackage}-doc-build")
123130

131+
# The doc of Furiosa will be missing for PRs
132+
if subpackage == "furiosa" and not subpackage_path.is_dir():
133+
continue
134+
124135
# Copy all HTML files from subpackage into optimum
125136
rename_copy_subpackage_html_paths(
126137
subpackage,
@@ -136,10 +147,13 @@ def main():
136147
# Extend table of contents sections with the subpackage name as the parent folder
137148
rename_subpackage_toc(subpackage, subpackage_toc)
138149
# Just keep the name of the partner in the TOC title
139-
subpackage_toc[0]["title"] = subpackage_toc[0]["title"].split("Optimum ")[-1]
150+
if subpackage == "amd":
151+
subpackage_toc[0]["title"] = subpackage_toc[0]["title"].split("Optimum-")[-1]
152+
else:
153+
subpackage_toc[0]["title"] = subpackage_toc[0]["title"].split("Optimum ")[-1]
140154
if subpackage != "graphcore":
141155
# Update optimum table of contents
142-
base_toc.insert(1, subpackage_toc[0])
156+
base_toc.insert(SUBPACKAGE_TOC_INSERT_INDEX, subpackage_toc[0])
143157

144158
# Write final table of contents
145159
with open(base_toc_path, "w") as f:

docs/source/_toctree.yml

+17-12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
title: Quantization
1313
title: Conceptual guides
1414
title: Overview
15+
- sections:
16+
- local: nvidia_overview
17+
title: 🤗 Optimum Nvidia
18+
title: Nvidia
19+
isExpanded: false
1520
- sections:
1621
- local: onnxruntime/overview
1722
title: Overview
@@ -95,6 +100,18 @@
95100
title: "TFLite"
96101
title: Exporters
97102
isExpanded: false
103+
- sections:
104+
- local: bettertransformer/overview
105+
title: Overview
106+
- sections:
107+
- local: bettertransformer/tutorials/convert
108+
title: Convert Transformers models to use BetterTransformer
109+
- local: bettertransformer/tutorials/contribute
110+
title: How to add support for new architectures?
111+
title: Tutorials
112+
isExpanded: false
113+
title: BetterTransformer
114+
isExpanded: false
98115
- sections:
99116
- local: torch_fx/overview
100117
title: Overview
@@ -115,18 +132,6 @@
115132
isExpanded: false
116133
title: Torch FX
117134
isExpanded: false
118-
- sections:
119-
- local: bettertransformer/overview
120-
title: Overview
121-
- sections:
122-
- local: bettertransformer/tutorials/convert
123-
title: Convert Transformers models to use BetterTransformer
124-
- local: bettertransformer/tutorials/contribute
125-
title: How to add support for new architectures?
126-
title: Tutorials
127-
isExpanded: false
128-
title: BetterTransformer
129-
isExpanded: false
130135
- sections:
131136
- local: llm_quantization/usage_guides/quantization
132137
title: GPTQ quantization

docs/source/index.mdx

+36-10
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@ As such, Optimum enables developers to efficiently use any of these platforms wi
1919

2020
🤗 Optimum is distributed as a collection of packages - check out the links below for an in-depth look at each one.
2121

22+
23+
## Hardware partners
24+
25+
The packages below enable you to get the best of the 🤗 Hugging Face ecosystem on various types of devices.
26+
2227
<div class="mt-10">
2328
<div class="w-full flex flex-col space-y-4 md:space-y-0 md:grid md:grid-cols-3 md:gap-y-4 md:gap-x-5">
24-
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./habana/index"
25-
><div class="w-full text-center bg-gradient-to-br from-indigo-400 to-indigo-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">Habana</div>
26-
<p class="text-gray-700">Maximize training throughput and efficiency with <span class="underline" onclick="event.preventDefault(); window.open('https://docs.habana.ai/en/latest/Gaudi_Overview/Gaudi_Architecture.html', '_blank');">Habana's Gaudi processor</span></p>
29+
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="https://github.com/huggingface/optimum-nvidia"
30+
><div class="w-full text-center bg-gradient-to-br from-green-600 to-green-600 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">NVIDIA</div>
31+
<p class="text-gray-700">Accelerate inference with NVIDIA TensorRT-LLM on the <span class="underline" onclick="event.preventDefault(); window.open('https://developer.nvidia.com/blog/nvidia-tensorrt-llm-supercharges-large-language-model-inference-on-nvidia-h100-gpus/', '_blank');">NVIDIA platform</span></p>
32+
</a>
33+
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./amd/index"
34+
><div class="w-full text-center bg-gradient-to-br from-red-600 to-red-600 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">AMD</div>
35+
<p class="text-gray-700">Enable performance optimizations for <span class="underline" onclick="event.preventDefault(); window.open('https://www.amd.com/en/graphics/instinct-server-accelerators', '_blank');">AMD Instinct GPUs</span> and <span class="underline" onclick="event.preventDefault(); window.open('https://ryzenai.docs.amd.com/en/latest/index.html', '_blank');">AMD Ryzen AI NPUs</span></p>
2736
</a>
2837
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./intel/index"
2938
><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">Intel</div>
@@ -33,25 +42,42 @@ As such, Optimum enables developers to efficiently use any of these platforms wi
3342
><div class="w-full text-center bg-gradient-to-br from-orange-400 to-orange-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">AWS Trainium/Inferentia</div>
3443
<p class="text-gray-700">Accelerate your training and inference workflows with <span class="underline" onclick="event.preventDefault(); window.open('https://aws.amazon.com/machine-learning/trainium/', '_blank');">AWS Trainium</span> and <span class="underline" onclick="event.preventDefault(); window.open('https://aws.amazon.com/machine-learning/inferentia/', '_blank');">AWS Inferentia</span></p>
3544
</a>
36-
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="https://github.com/huggingface/optimum-nvidia"
37-
><div class="w-full text-center bg-gradient-to-br from-green-600 to-green-600 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">NVIDIA</div>
38-
<p class="text-gray-700">Accelerate inference with NVIDIA TensorRT-LLM on the <span class="underline" onclick="event.preventDefault(); window.open('https://developer.nvidia.com/blog/nvidia-tensorrt-llm-supercharges-large-language-model-inference-on-nvidia-h100-gpus/', '_blank');">NVIDIA platform</span></p>
39-
</a>
40-
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./amd/index"
41-
><div class="w-full text-center bg-gradient-to-br from-red-600 to-red-600 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">AMD</div>
42-
<p class="text-gray-700">Enable performance optimizations for <span class="underline" onclick="event.preventDefault(); window.open('https://www.amd.com/en/graphics/instinct-server-accelerators', '_blank');">AMD Instinct GPUs</span> and <span class="underline" onclick="event.preventDefault(); window.open('https://ryzenai.docs.amd.com/en/latest/index.html', '_blank');">AMD Ryzen AI NPUs</span></p>
45+
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./habana/index"
46+
><div class="w-full text-center bg-gradient-to-br from-indigo-400 to-indigo-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">Habana</div>
47+
<p class="text-gray-700">Maximize training throughput and efficiency with <span class="underline" onclick="event.preventDefault(); window.open('https://docs.habana.ai/en/latest/Gaudi_Overview/Gaudi_Architecture.html', '_blank');">Habana's Gaudi processor</span></p>
4348
</a>
4449
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./furiosa/index"
4550
><div class="w-full text-center bg-gradient-to-br from-green-400 to-green-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">FuriosaAI</div>
4651
<p class="text-gray-700">Fast and efficient inference on <span class="underline" onclick="event.preventDefault(); window.open('https://www.furiosa.ai/', '_blank');">FuriosaAI WARBOY</span></p>
4752
</a>
53+
</div>
54+
</div>
55+
56+
> [!TIP]
57+
> Some packages provide hardware-agnostic features (e.g. INC interface in Optimum Intel).
58+
59+
60+
## Open-source integrations
61+
62+
🤗 Optimum also supports a variety of open-source frameworks to make model optimization very easy.
63+
64+
<div class="mt-10">
65+
<div class="w-full flex flex-col space-y-4 md:space-y-0 md:grid md:grid-cols-3 md:gap-y-4 md:gap-x-5">
4866
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./onnxruntime/overview"
4967
><div class="w-full text-center bg-gradient-to-br from-pink-400 to-pink-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">ONNX Runtime</div>
5068
<p class="text-gray-700">Apply quantization and graph optimization to accelerate Transformers models training and inference with <span class="underline" onclick="event.preventDefault(); window.open('https://onnxruntime.ai/', '_blank');">ONNX Runtime</span></p>
5169
</a>
70+
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./exporters/overview"
71+
><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">Exporters</div>
72+
<p class="text-gray-700">Export your PyTorch or TensorFlow model to different formats such as ONNX and TFLite</p>
73+
</a>
5274
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./bettertransformer/overview"
5375
><div class="w-full text-center bg-gradient-to-br from-yellow-400 to-yellow-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">BetterTransformer</div>
5476
<p class="text-gray-700">A one-liner integration to use <span class="underline" onclick="event.preventDefault(); window.open('https://pytorch.org/blog/a-better-transformer-for-fast-transformer-encoder-inference/', '_blank');">PyTorch's BetterTransformer</span> with Transformers models</p>
5577
</a>
78+
<a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./torch_fx/overview"
79+
><div class="w-full text-center bg-gradient-to-br from-green-400 to-green-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">Torch FX</div>
80+
<p class="text-gray-700">Create and compose custom graph transformations to optimize PyTorch Transformers models with <span class="underline" onclick="event.preventDefault(); window.open('https://pytorch.org/docs/stable/fx.html#', '_blank');">Torch FX</span></p>
81+
</a>
5682
</div>
5783
</div>

docs/source/nvidia_overview.mdx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 🤗 Optimum Nvidia
2+
3+
Find more information about 🤗 Optimum Nvidia [here](https://github.com/huggingface/optimum-nvidia).

examples/onnxruntime/training/image-classification/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
-->
1313

14-
# Language Modeling
15-
16-
## Image Classification Training
14+
# Image Classification
1715

1816
By running the scripts [`run_image_classification.py`](https://github.com/huggingface/optimum/blob/main/examples/onnxruntime/training/image-classification/run_image_classification.py) we will be able to leverage the [`ONNX Runtime`](https://github.com/microsoft/onnxruntime) accelerator to train the language models from the
1917
[HuggingFace hub](https://huggingface.co/models).
@@ -32,6 +30,7 @@ torchrun --nproc_per_node=NUM_GPUS_YOU_HAVE run_image_classification.py \
3230
--dataset_name beans \
3331
--output_dir ./beans_outputs/ \
3432
--remove_unused_columns False \
33+
--label_column_name labels \
3534
--do_train \
3635
--do_eval \
3736
--learning_rate 2e-5 \

0 commit comments

Comments
 (0)