optimum-executorch 0.0.0.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. optimum_executorch-0.0.0.dev0/LICENSE +201 -0
  2. optimum_executorch-0.0.0.dev0/PKG-INFO +289 -0
  3. optimum_executorch-0.0.0.dev0/README.md +233 -0
  4. optimum_executorch-0.0.0.dev0/optimum/commands/export/executorch.py +236 -0
  5. optimum_executorch-0.0.0.dev0/optimum/commands/register/register_export.py +19 -0
  6. optimum_executorch-0.0.0.dev0/optimum/executorch/__init__.py +43 -0
  7. optimum_executorch-0.0.0.dev0/optimum/executorch/attentions/custom_kv_cache.py +415 -0
  8. optimum_executorch-0.0.0.dev0/optimum/executorch/attentions/custom_sdpa.py +143 -0
  9. optimum_executorch-0.0.0.dev0/optimum/executorch/modeling.py +1388 -0
  10. optimum_executorch-0.0.0.dev0/optimum/executorch/passes/remove_padding_idx_embedding_pass.py +22 -0
  11. optimum_executorch-0.0.0.dev0/optimum/executorch/stats.py +209 -0
  12. optimum_executorch-0.0.0.dev0/optimum/executorch/version.py +15 -0
  13. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/__init__.py +59 -0
  14. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/__main__.py +174 -0
  15. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/convert.py +91 -0
  16. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/integrations.py +884 -0
  17. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/quantization.py +108 -0
  18. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/recipe_registry.py +70 -0
  19. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/recipes/__init__.py +15 -0
  20. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/recipes/coreml.py +151 -0
  21. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/recipes/cuda.py +129 -0
  22. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/recipes/metal.py +129 -0
  23. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/recipes/portable.py +91 -0
  24. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/recipes/xnnpack.py +123 -0
  25. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/task_registry.py +70 -0
  26. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/tasks/__init__.py +15 -0
  27. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/tasks/asr.py +105 -0
  28. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/tasks/causal_lm.py +149 -0
  29. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/tasks/image_classification.py +42 -0
  30. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/tasks/masked_lm.py +54 -0
  31. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/tasks/multimodal_text_to_text.py +249 -0
  32. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/tasks/seq2seq_lm.py +58 -0
  33. optimum_executorch-0.0.0.dev0/optimum/exporters/executorch/utils.py +205 -0
  34. optimum_executorch-0.0.0.dev0/optimum_executorch.egg-info/PKG-INFO +289 -0
  35. optimum_executorch-0.0.0.dev0/optimum_executorch.egg-info/SOURCES.txt +38 -0
  36. optimum_executorch-0.0.0.dev0/optimum_executorch.egg-info/dependency_links.txt +1 -0
  37. optimum_executorch-0.0.0.dev0/optimum_executorch.egg-info/requires.txt +35 -0
  38. optimum_executorch-0.0.0.dev0/optimum_executorch.egg-info/top_level.txt +1 -0
  39. optimum_executorch-0.0.0.dev0/pyproject.toml +112 -0
  40. optimum_executorch-0.0.0.dev0/setup.cfg +4 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,289 @@
1
+ Metadata-Version: 2.4
2
+ Name: optimum-executorch
3
+ Version: 0.0.0.dev0
4
+ Summary: Optimum Executorch is an interface between the Hugging Face libraries and ExecuTorch
5
+ Author-email: "HuggingFace Inc. Special Ops Team" <hardware@huggingface.co>
6
+ License: Apache
7
+ Project-URL: Homepage, https://github.com/huggingface/optimum
8
+ Keywords: transformers,quantization,inference,executorch
9
+ Classifier: Development Status :: 2 - Pre-Alpha
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.10.0
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: optimum~=1.24
24
+ Requires-Dist: executorch>=1.0.0
25
+ Requires-Dist: transformers==4.56.1
26
+ Provides-Extra: tests
27
+ Requires-Dist: accelerate>=0.26.0; extra == "tests"
28
+ Requires-Dist: coremltools>=8.2.0; extra == "tests"
29
+ Requires-Dist: datasets==3.6.0; extra == "tests"
30
+ Requires-Dist: parameterized; extra == "tests"
31
+ Requires-Dist: pytest; extra == "tests"
32
+ Requires-Dist: safetensors; extra == "tests"
33
+ Requires-Dist: sentencepiece; extra == "tests"
34
+ Requires-Dist: numba!=0.58.0; extra == "tests"
35
+ Requires-Dist: librosa; extra == "tests"
36
+ Requires-Dist: soundfile; extra == "tests"
37
+ Requires-Dist: tiktoken; extra == "tests"
38
+ Provides-Extra: quality
39
+ Requires-Dist: black~=23.1; extra == "quality"
40
+ Requires-Dist: ruff==0.4.4; extra == "quality"
41
+ Provides-Extra: dev
42
+ Requires-Dist: accelerate>=0.26.0; extra == "dev"
43
+ Requires-Dist: coremltools>=8.2.0; extra == "dev"
44
+ Requires-Dist: datasets==3.6.0; extra == "dev"
45
+ Requires-Dist: parameterized; extra == "dev"
46
+ Requires-Dist: pytest; extra == "dev"
47
+ Requires-Dist: safetensors; extra == "dev"
48
+ Requires-Dist: sentencepiece; extra == "dev"
49
+ Requires-Dist: numba!=0.58.0; extra == "dev"
50
+ Requires-Dist: librosa; extra == "dev"
51
+ Requires-Dist: soundfile; extra == "dev"
52
+ Requires-Dist: tiktoken; extra == "dev"
53
+ Requires-Dist: black~=23.1; extra == "dev"
54
+ Requires-Dist: ruff==0.4.4; extra == "dev"
55
+ Dynamic: license-file
56
+
57
+ <div align="center">
58
+
59
+ <img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/executorch/logo/optimum-executorch.png" width=80%>
60
+
61
+ # πŸ€— Optimum ExecuTorch
62
+
63
+ **Optimize and deploy Hugging Face models with ExecuTorch**
64
+
65
+ [Documentation](https://huggingface.co/docs/optimum-executorch/en/index) | [ExecuTorch](https://github.com/pytorch/executorch) | [Hugging Face](https://huggingface.co/)
66
+
67
+ </div>
68
+
69
+ ## πŸ“‹ Overview
70
+
71
+ Optimum ExecuTorch enables efficient deployment of transformer models using Meta's ExecuTorch framework. It provides:
72
+ - πŸ”„ Easy conversion of Hugging Face models to ExecuTorch format
73
+ - ⚑ Optimized inference with hardware-specific optimizations
74
+ - 🀝 Seamless integration with Hugging Face Transformers
75
+ - πŸ“± Efficient deployment on various devices
76
+
77
+ ## ⚑ Quick Installation
78
+
79
+ ### 1. Create a virtual environment
80
+ Install [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) on your machine. Then, create a virtual environment to manage our dependencies.
81
+ ```
82
+ conda create -n optimum-executorch python=3.11
83
+ conda activate optimum-executorch
84
+ ```
85
+
86
+ ### 2. Install optimum-executorch from source
87
+ ```
88
+ git clone https://github.com/huggingface/optimum-executorch.git
89
+ cd optimum-executorch
90
+ pip install '.[dev]'
91
+ ```
92
+
93
+ - πŸ”œ Install from pypi coming soon...
94
+
95
+ ### 3. Install dependencies in dev mode
96
+
97
+ To access every available optimization and experiment with the newest features, run:
98
+ ```
99
+ python install_dev.py
100
+ ```
101
+
102
+ This script will install `executorch`, `torch`, `torchao`, `transformers`, etc. from nightly builds or from source to access the latest models and optimizations.
103
+
104
+ To leave an existing ExecuTorch installation untouched, run `install_dev.py` with `--skip_override_torch` to prevent it from being overwritten.
105
+
106
+ ## 🎯 Quick Start
107
+
108
+ There are two ways to use Optimum ExecuTorch:
109
+
110
+ ### Option 1: Export and Load in One Python API
111
+ ```python
112
+ from optimum.executorch import ExecuTorchModelForCausalLM
113
+ from transformers import AutoTokenizer
114
+
115
+ # Load and export the model on-the-fly
116
+ model_id = "HuggingFaceTB/SmolLM2-135M-Instruct"
117
+ model = ExecuTorchModelForCausalLM.from_pretrained(
118
+ model_id,
119
+ recipe="xnnpack",
120
+ attn_implementation="custom_sdpa", # Use custom SDPA implementation for better performance
121
+ use_custom_kv_cache=True, # Use custom KV cache for better performance
122
+ **{"qlinear": "8da4w", "qembedding": "8w"}, # Quantize linear and embedding layers
123
+ )
124
+
125
+ # Generate text right away
126
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
127
+ generated_text = model.text_generation(
128
+ tokenizer=tokenizer,
129
+ prompt="Once upon a time",
130
+ max_seq_len=128,
131
+ )
132
+ print(generated_text)
133
+ ```
134
+
135
+ > **Note:** If an ExecuTorch model is already cached on the Hugging Face Hub, the API will automatically skip the export step and load the cached `.pte` file. To test this, replace the `model_id` in the example above with `"executorch-community/SmolLM2-135M"`, where the `.pte` file is pre-cached. Additionally, the `.pte` file can be directly associated with the eager model, as demonstrated in this [example](https://huggingface.co/optimum-internal-testing/tiny-random-llama/tree/executorch).
136
+
137
+
138
+ ### Option 2: Export and Load Separately
139
+
140
+ #### Step 1: Export your model
141
+ Use the CLI tool to convert your model to ExecuTorch format:
142
+ ```
143
+ optimum-cli export executorch \
144
+ --model "HuggingFaceTB/SmolLM2-135M-Instruct" \
145
+ --task "text-generation" \
146
+ --recipe "xnnpack" \
147
+ --use_custom_sdpa \
148
+ --use_custom_kv_cache \
149
+ --qlinear 8da4w \
150
+ --qembedding 8w \
151
+ --output_dir="hf_smollm2"
152
+ ```
153
+ Explore the various export options by running the command: `optimum-cli export executorch --help`.
154
+ To read more about how to export different types of models on Optimum ExecuTorch, please revert to the export [README](optimum/exporters/executorch/README.md).
155
+
156
+ #### Step 2: Validate the Exported Model on Host Using the Python API
157
+ Use the exported model for text generation:
158
+ ```python
159
+ from optimum.executorch import ExecuTorchModelForCausalLM
160
+ from transformers import AutoTokenizer
161
+
162
+ # Load the exported model
163
+ model = ExecuTorchModelForCausalLM.from_pretrained("./hf_smollm2")
164
+
165
+ # Initialize tokenizer and generate text
166
+ tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM2-135M-Instruct")
167
+ generated_text = model.text_generation(
168
+ tokenizer=tokenizer,
169
+ prompt="Once upon a time",
170
+ max_seq_len=128
171
+ )
172
+ print(generated_text)
173
+ ```
174
+
175
+ #### Step 3: Run inference on-device
176
+ To perform on-device inference, you can use ExecuTorch’s sample runner or the example iOS/Android applications. For detailed instructions, refer to the [ExecuTorch Sample Runner guide](https://github.com/pytorch/executorch/blob/main/examples/models/qwen3/README.md#example-run).
177
+
178
+ ## βš™οΈ Optimizations
179
+
180
+ ### Custom Operators
181
+ Optimum transformer models utilize:
182
+ - A [**custom SDPA**](https://github.com/pytorch/executorch/blob/a4322c71c3a97e79e0454a8223db214b010f1193/extension/llm/README.md?plain=1#L40) for CPU based on Flash Attention, boosting performance by around **3x** compared to default SDPA.
183
+ - A **custom KV cache** that uses a custom op for efficient in-place cache update on CPU, boosting performance by **2.5x** compared to default static KV cache.
184
+
185
+ ### Backends Delegation
186
+ Currently, **Optimum-ExecuTorch** supports the [XNNPACK Backend](https://pytorch.org/executorch/main/backends-xnnpack.html) for CPU and [CoreML Backend](https://docs.pytorch.org/executorch/stable/backends-coreml.html) for GPU on Apple devices.
187
+
188
+ For a comprehensive overview of all backends supported by ExecuTorch, please refer to the [ExecuTorch Backend Overview](https://pytorch.org/executorch/main/backends-overview.html).
189
+
190
+ ### Quantization
191
+ We currently support Post-Training Quantization (PTQ) for linear layers and embeddings using the [TorchAO](https://github.com/pytorch/ao) quantization library.
192
+
193
+
194
+ ## πŸ€— Supported Models
195
+
196
+ The following models have been successfully tested with Executorch. For details on the specific optimizations supported and how to use them for each model, please consult their respective test files in the [`tests/models/`](https://github.com/huggingface/optimum-executorch/tree/main/tests/models) directory.
197
+
198
+ ### Text Models
199
+ We currently support a wide range of popular transformer models, including encoder-only, decoder-only, and encoder-decoder architectures, as well as models specialized for various tasks like text generation, translation, summarization, and mask prediction, etc. These models reflect the current trends and popularity across the Hugging Face community:
200
+ #### LLMs (Large Language Models)
201
+ ##### Decoder-only
202
+ - [Codegen](https://huggingface.co/Salesforce/codegen-350M-mono): Salesforce's `codegen-350M-mono` and its variants
203
+ - [Gemma](https://huggingface.co/google/gemma-2b): `Gemma-2b` and its variants
204
+ - [Gemma2](https://huggingface.co/google/gemma-2-2b): `Gemma-2-2b` and its variants
205
+ - [Gemma3](https://huggingface.co/google/gemma-3-1b-it): `Gemma-3-1b` and its variants (πŸ’‘[**NEW**] 270M, 1B)
206
+ - [Glm](https://huggingface.co/THUDM/glm-edge-1.5b-chat): `glm-edge-1.5b` and its variants
207
+ - [Gpt2](https://huggingface.co/AI-Sweden-Models/gpt-sw3-126m): `gpt-sw3-126m` and its variants
208
+ - [GptJ](https://huggingface.co/Milos/slovak-gpt-j-405M): `gpt-j-405M` and its variants
209
+ - [GptNeoX](https://huggingface.co/EleutherAI/pythia-14m): EleutherAI's `pythia-14m` and its variants
210
+ - [GptNeoXJapanese](https://huggingface.co/abeja/gpt-neox-japanese-2.7b): `gpt-neox-japanese-2.7b` and its variants
211
+ - [Granite](https://huggingface.co/ibm-granite/granite-3.3-2b-instruct): `granite-3.3-2b-instruct` and its variants
212
+ - [Llama](https://huggingface.co/meta-llama/Llama-3.2-1B): `Llama-3.2-1B` and its variants
213
+ - [Mistral](https://huggingface.co/ministral/Ministral-3b-instruct): `Ministral-3b-instruct` and its variants
214
+ - [Qwen2](https://huggingface.co/Qwen/Qwen2.5-0.5B): `Qwen2.5-0.5B` and its variants
215
+ - [Qwen3](https://huggingface.co/Qwen/Qwen3-0.6B): `Qwen3-0.6B`, `Qwen3-Embedding-0.6B` and other variants
216
+ - [Olmo](https://huggingface.co/allenai/OLMo-1B-hf): `OLMo-1B-hf` and its variants
217
+ - [Phi](https://huggingface.co/johnsnowlabs/JSL-MedPhi2-2.7B): `JSL-MedPhi2-2.7B` and its variants
218
+ - [Phi4](https://huggingface.co/microsoft/Phi-4-mini-instruct): `Phi-4-mini-instruct` and its variants
219
+ - [Smollm](https://huggingface.co/HuggingFaceTB/SmolLM2-135M): πŸ€— `SmolLM2-135M` and its variants
220
+ - [Smollm3](https://huggingface.co/HuggingFaceTB/SmolLM3-3B): πŸ€— `SmolLM3-3B` and its variants
221
+ - [Starcoder2](https://huggingface.co/bigcode/starcoder2-3b): `starcoder2-3b` and its variants
222
+ ##### Encoder-decoder (Seq2Seq)
223
+ - [T5](https://huggingface.co/google-t5/t5-small): Google's `T5` and its variants
224
+ #### NLU (Natural Language Understanding)
225
+ - [Albert](https://huggingface.co/albert/albert-base-v2): `albert-base-v2` and its variants
226
+ - [Bert](https://huggingface.co/google-bert/bert-base-uncased): Google's `bert-base-uncased` and its variants
227
+ - [Distilbert](https://huggingface.co/distilbert/distilbert-base-uncased): `distilbert-base-uncased` and its variants
228
+ - [Eurobert](https://huggingface.co/EuroBERT/EuroBERT-210m): `EuroBERT-210m` and its variants
229
+ - [Roberta](https://huggingface.co/FacebookAI/xlm-roberta-base): FacebookAI's `xlm-roberta-base` and its variants
230
+
231
+ ### Vision Models
232
+ - [Cvt](https://huggingface.co/microsoft/cvt-13): Convolutional Vision Transformer
233
+ - [Deit](https://huggingface.co/facebook/deit-base-distilled-patch16-224): Distilled Data-efficient Image Transformer (base-sized)
234
+ - [Dit](https://huggingface.co/microsoft/dit-base-finetuned-rvlcdip): Document Image Transformer (base-sized)
235
+ - [EfficientNet](https://huggingface.co/google/efficientnet-b0): EfficientNet (b0-b7 sized)
236
+ - [Focalnet](https://huggingface.co/microsoft/focalnet-tiny): FocalNet (tiny-sized)
237
+ - [Mobilevit](https://huggingface.co/apple/mobilevit-xx-small): Apple's MobileViT xx-small
238
+ - [Mobilevit2](https://huggingface.co/apple/mobilevitv2-1.0-imagenet1k-256): Apple's MobileViTv2
239
+ - [Pvt](https://huggingface.co/Zetatech/pvt-tiny-224): Pyramid Vision Transformer (tiny-sized)
240
+ - [Swin](https://huggingface.co/microsoft/swin-tiny-patch4-window7-224): Swin Transformer (tiny-sized)
241
+
242
+ ### Audio Models
243
+ #### ASR (Automatic Speech Recognition)
244
+ - [Whisper](https://huggingface.co/openai/whisper-tiny): OpenAI's `Whisper` and its variants
245
+
246
+ #### Speech text-to-text (Automatic Speech Recognition)
247
+ - πŸ’‘[**NEW**] [Granite Speech](https://huggingface.co/ibm-granite/granite-speech-3.3-2b): `granite-speech-3.3-2b` and its variants
248
+ - πŸ’‘[**NEW**] [Voxtral](https://huggingface.co/mistralai/Voxtral-Mini-3B-2507): Mistral's newest speech/text-to-text model
249
+
250
+ *πŸ“Œ Note: This list is continuously expanding. As we continue to expand support, more models will be added.*
251
+
252
+ ## πŸš€ Benchmarks on Mobile Devices
253
+
254
+ The following benchmarks show example **decode performance** (tokens/sec) across Android and iOS devices for popular edge LLMs.
255
+
256
+ | Model | Samsung Galaxy S22 5G<br/>(Android 13) | Samsung Galaxy S22 Ultra 5G<br/>(Android 14) | iPhone 15<br/>(iOS 18.0) | iPhone 15 Plus<br/>(iOS 17.4.1) | iPhone 15 Pro<br/>(iOS 18.4.1) |
257
+ |-------|:---:|:---:|:---:|:---:|:---:|
258
+ | [**SmolLM2-135M**](https://tinyurl.com/25ud3th8) | 202.28 | 202.61 | 7.47 | 6.43 | 29.64 |
259
+ | [**Qwen3-0.6B**](https://tinyurl.com/35946h8b) | 59.16 | 56.49 | 7.05 | 5.48 | 17.99 |
260
+ | [**google/gemma-3-1b-it**](https://tinyurl.com/4d8pezpv) | 25.07 | 23.89 | 21.51 | 21.33 | 17.8 |
261
+ | [**Llama-3.2-1B**](https://tinyurl.com/bddjewau) | 44.91 | 37.39 | 11.04 | 8.93 | 25.78 |
262
+ | [**OLMo-1B**](https://tinyurl.com/4runxesd) | 44.98 | 38.22 | 14.49 | 8.72 | 20.24 |
263
+
264
+ > πŸ“Š **View Live Benchmarks**: Explore comprehensive performance data, compare models across devices, and track performance trends over time on the [ExecuTorch Benchmark Dashboard](https://hud.pytorch.org/benchmark/llms?repoName=pytorch%2Fexecutorch).
265
+
266
+ > Performance measured with custom SDPA, KV-cache optimization, and 8da4w quantization. Results may vary based on device conditions and prompt characteristics.
267
+
268
+
269
+ ## πŸ› οΈ Advanced Usage
270
+
271
+ Check our [ExecuTorch GitHub repo](https://github.com/pytorch/executorch) directly for:
272
+ - More backends and performance optimization options
273
+ - Deployment guides for Android, iOS, and embedded devices
274
+ - Additional examples and benchmarks
275
+
276
+ ## 🀝 Contributing
277
+
278
+ We love your input! We want to make contributing to Optimum ExecuTorch as easy and transparent as possible. Check out our:
279
+
280
+ - [Contributing Guidelines](https://github.com/huggingface/optimum/blob/main/CONTRIBUTING.md)
281
+ - [Code of Conduct](https://github.com/huggingface/optimum/blob/main/CODE_OF_CONDUCT.md)
282
+
283
+ ## πŸ“ License
284
+
285
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](https://github.com/huggingface/optimum/blob/main/LICENSE) file for details.
286
+
287
+ ## πŸ“« Get in Touch
288
+
289
+ - Report bugs through [GitHub Issues](https://github.com/huggingface/optimum-executorch/issues)