Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
406 commits
Select commit Hold shift + click to select a range
656161b
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Mar 19, 2026
0ad9382
style
IlyasMoutawwakil Mar 19, 2026
eb1712b
revert deepseek
IlyasMoutawwakil Mar 19, 2026
67a4d30
style
IlyasMoutawwakil Mar 20, 2026
85de2da
fix style
IlyasMoutawwakil Mar 20, 2026
4c94907
fix lfm cache
IlyasMoutawwakil Mar 20, 2026
47fb0a5
revert idefics
IlyasMoutawwakil Mar 20, 2026
59044fd
revert idefics
IlyasMoutawwakil Mar 20, 2026
0886f38
revert deepseek vl
IlyasMoutawwakil Mar 20, 2026
24d4735
better leaf tensors handling
IlyasMoutawwakil Mar 20, 2026
4eee818
revert patchtsmixer
IlyasMoutawwakil Mar 20, 2026
7c87d35
fix in onnx exporter order and executorch backend preparation
IlyasMoutawwakil Mar 20, 2026
a9bed19
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Mar 20, 2026
b9a547d
fix get_rope_index models and chunked vision attn models
IlyasMoutawwakil Mar 25, 2026
a2d1e8c
fix annotation
IlyasMoutawwakil Mar 25, 2026
b6d68e5
skip video llama 3
IlyasMoutawwakil Mar 25, 2026
17156c0
skip ernie vl as well
IlyasMoutawwakil Mar 25, 2026
969dbc3
introduce dynamo patches and make prepare_for_export the least impact…
IlyasMoutawwakil Mar 26, 2026
eaabee6
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Mar 30, 2026
b21385e
Merge branch 'hf-exporters' of https://github.com/huggingface/transfo…
IlyasMoutawwakil Mar 31, 2026
b75ce43
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Mar 31, 2026
ff50ce8
fix after merge
IlyasMoutawwakil Mar 31, 2026
1d81213
ultimatevlm fix (precompute stuff)
IlyasMoutawwakil Apr 1, 2026
2fe1d11
fix vlm encoders export through optional precomputed inputs
IlyasMoutawwakil Apr 1, 2026
16cbe4d
more vlms passing (t5 gemma and paddle ocr)
IlyasMoutawwakil Apr 1, 2026
96e74bc
fix qwen omni and paddle ocr export
IlyasMoutawwakil Apr 1, 2026
4a1303e
fix docs
IlyasMoutawwakil Apr 1, 2026
e814592
fix torch dep
IlyasMoutawwakil Apr 2, 2026
a6bcb66
annotations
IlyasMoutawwakil Apr 2, 2026
a955ae5
revert change
IlyasMoutawwakil Apr 2, 2026
3bf6a90
missing licence
IlyasMoutawwakil Apr 2, 2026
35b4db7
attempt fix styling
IlyasMoutawwakil Apr 2, 2026
753e70e
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Apr 2, 2026
c508d22
fix torch leak
IlyasMoutawwakil Apr 2, 2026
6a087a5
fix
IlyasMoutawwakil Apr 2, 2026
0a196a2
style
IlyasMoutawwakil Apr 2, 2026
2b928ae
fix
IlyasMoutawwakil Apr 2, 2026
ee8c7b0
style
IlyasMoutawwakil Apr 2, 2026
c3a0f24
guard
IlyasMoutawwakil Apr 2, 2026
87b2ca8
same name for torch patches
IlyasMoutawwakil Apr 2, 2026
f024c9d
fix detectron failure
IlyasMoutawwakil Apr 2, 2026
adf90da
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Apr 2, 2026
16720f9
fix musicflamingo
IlyasMoutawwakil Apr 2, 2026
4ad2a99
fix
IlyasMoutawwakil Apr 2, 2026
1ac2de8
fix
IlyasMoutawwakil Apr 2, 2026
770cc2e
support and fix gemma4
IlyasMoutawwakil Apr 2, 2026
5072edb
update docs
IlyasMoutawwakil Apr 2, 2026
5ac0267
update docs
IlyasMoutawwakil Apr 2, 2026
27ccc0f
make qwen omni audio encoders exportable
IlyasMoutawwakil Apr 3, 2026
5364d98
docs
IlyasMoutawwakil Apr 3, 2026
0a7baff
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Apr 7, 2026
9bcca9d
get cu seqlens
IlyasMoutawwakil Apr 8, 2026
ca6cfdb
leave paddle ocr
IlyasMoutawwakil Apr 8, 2026
d52bd2e
skip paddle ocr
IlyasMoutawwakil Apr 8, 2026
efafb3c
fix
IlyasMoutawwakil Apr 8, 2026
70862ce
fix layoutlmv2 onnx export
IlyasMoutawwakil Apr 8, 2026
0cc6e42
fix idefics3 on cpu
IlyasMoutawwakil Apr 8, 2026
ba8f730
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Apr 8, 2026
7f9382c
fix falcon_mamba and other idefics
IlyasMoutawwakil Apr 8, 2026
e2e951d
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Apr 9, 2026
e44c5ae
style and docs
IlyasMoutawwakil Apr 10, 2026
1a7e790
dict decomposition
IlyasMoutawwakil Apr 10, 2026
677a90d
remove deferred
IlyasMoutawwakil Apr 10, 2026
dab2d14
executorch fixes
IlyasMoutawwakil Apr 10, 2026
6ec03ba
dynamo doctests passing *-*
IlyasMoutawwakil Apr 10, 2026
5eba3d5
clean title
IlyasMoutawwakil Apr 10, 2026
c5c7020
update
IlyasMoutawwakil Apr 10, 2026
679eb1b
normalize qwen omni
IlyasMoutawwakil Apr 10, 2026
ff66d95
only pure functions
IlyasMoutawwakil Apr 10, 2026
f008002
patch views for exeuctorch
IlyasMoutawwakil Apr 12, 2026
aef0409
better vision dynamic tensors pre computation
IlyasMoutawwakil Apr 13, 2026
2ae78c7
audio functions
IlyasMoutawwakil Apr 13, 2026
e3e66c6
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Apr 13, 2026
d8432a5
fix
IlyasMoutawwakil Apr 13, 2026
234f7eb
fix
IlyasMoutawwakil Apr 13, 2026
aa220b7
define vision modeling utils
IlyasMoutawwakil Apr 13, 2026
a6f9d7b
fix docs
IlyasMoutawwakil Apr 13, 2026
745e36a
style
IlyasMoutawwakil Apr 13, 2026
9eba545
Merge remote-tracking branch 'origin/main' into hf-exporters
IlyasMoutawwakil May 15, 2026
41c864e
fix repo
IlyasMoutawwakil May 15, 2026
8a5218a
update skips
IlyasMoutawwakil May 15, 2026
f6f4735
fixes and skips
IlyasMoutawwakil May 15, 2026
719157b
fix repo
IlyasMoutawwakil May 15, 2026
f7e2b06
exportable/compilable paddleocr vl
IlyasMoutawwakil May 15, 2026
75977b6
onnx parity
IlyasMoutawwakil May 15, 2026
44c93cf
more docs
IlyasMoutawwakil May 15, 2026
6114069
style
IlyasMoutawwakil May 15, 2026
eb0d6d6
move
IlyasMoutawwakil May 15, 2026
b37d192
avoid lens
IlyasMoutawwakil May 15, 2026
98445c3
timesfm minicpmv46 canine colqwen2
IlyasMoutawwakil May 15, 2026
32e0ff5
fix test
IlyasMoutawwakil May 15, 2026
e7dd4aa
executorch fixes
IlyasMoutawwakil May 15, 2026
e3fdc32
executorch fixes
IlyasMoutawwakil May 15, 2026
bc2427d
more executorch fixes
IlyasMoutawwakil May 18, 2026
139d0e4
Merge branch 'main' into hf-exporters
IlyasMoutawwakil May 26, 2026
e66362e
Merge branch 'hf-exporters' of https://github.com/huggingface/transfo…
IlyasMoutawwakil May 26, 2026
a9bacd9
more executorch patches
IlyasMoutawwakil May 26, 2026
0c2ff1d
Merge branch 'main' into hf-exporters
IlyasMoutawwakil May 26, 2026
8ddd01d
Merge branch 'hf-exporters' of https://github.com/huggingface/transfo…
IlyasMoutawwakil May 26, 2026
26f370d
fix
IlyasMoutawwakil May 27, 2026
2be769b
Merge branch 'main' into hf-exporters
IlyasMoutawwakil May 27, 2026
c136f1d
Merge branch 'main' into hf-exporters
IlyasMoutawwakil May 28, 2026
25708e0
more fixes
IlyasMoutawwakil May 28, 2026
020d874
Update src/transformers/exporters/exporter_dynamo.py
IlyasMoutawwakil Jun 5, 2026
1e975eb
stadarize the patching and fixing api more
IlyasMoutawwakil Jun 5, 2026
93bd416
fix get_encoder is some models
IlyasMoutawwakil Jun 5, 2026
ca64a66
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Jun 5, 2026
d63f025
fix style
IlyasMoutawwakil Jun 5, 2026
86e3ae9
fix qwen omni get decoder and export
IlyasMoutawwakil Jun 5, 2026
5619ea6
fix xlstm export
IlyasMoutawwakil Jun 5, 2026
01cf3f8
per model type inputs preparation registery
IlyasMoutawwakil Jun 5, 2026
f0256c7
standarize torch and library (onnx, executorch) patching and fx progr…
IlyasMoutawwakil Jun 6, 2026
8b604d4
style
IlyasMoutawwakil Jun 6, 2026
104c379
fix gemma4 unified test
IlyasMoutawwakil Jun 6, 2026
4df0ac6
add export for generation pipeline
IlyasMoutawwakil Jun 6, 2026
cca77d2
decompose for generation helper function
IlyasMoutawwakil Jun 6, 2026
7537aef
style
IlyasMoutawwakil Jun 6, 2026
3226c29
onnx fixes
IlyasMoutawwakil Jun 6, 2026
3bd85f1
two pat fix
IlyasMoutawwakil Jun 6, 2026
14fbffd
vectorized swin attention
IlyasMoutawwakil Jun 7, 2026
4d6c469
vectorized big bird block sparse attn
IlyasMoutawwakil Jun 7, 2026
4e16cf3
avoid dino timeouts
IlyasMoutawwakil Jun 7, 2026
07f4b68
big bird and pegasus
IlyasMoutawwakil Jun 7, 2026
436ed74
fixed unified gemma4
IlyasMoutawwakil Jun 7, 2026
03a76d3
sam fixes and simplifications
IlyasMoutawwakil Jun 8, 2026
7f6601d
fix repo
IlyasMoutawwakil Jun 8, 2026
0ed56b2
fix style
IlyasMoutawwakil Jun 8, 2026
ff54211
unify model instance patches with the rest of the patching api
IlyasMoutawwakil Jun 8, 2026
7925665
change in api to allow exporting multiple models with diff configs
IlyasMoutawwakil Jun 9, 2026
41dbec5
accept dicts
IlyasMoutawwakil Jun 15, 2026
67985c5
docs review comments
IlyasMoutawwakil Jun 15, 2026
c13543c
address comments
IlyasMoutawwakil Jun 15, 2026
0390228
fix clvp by not using datasets and vectorizing loops
IlyasMoutawwakil Jun 15, 2026
72eceef
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Jun 15, 2026
05d20b4
style
IlyasMoutawwakil Jun 15, 2026
dbdfa97
handle moe per backend and better (e.g. onnx translation)
IlyasMoutawwakil Jun 15, 2026
00857c9
better export workflow, no dict constraint on inputs, less enforcing …
IlyasMoutawwakil Jun 16, 2026
c2a0b8e
modeling fixes not honoring config.use_cache
IlyasMoutawwakil Jun 16, 2026
3a17538
style
IlyasMoutawwakil Jun 16, 2026
19ce6fc
style
IlyasMoutawwakil Jun 16, 2026
07d864d
easier to mantain inputs preparation
IlyasMoutawwakil Jun 16, 2026
87081a2
fix chunk on cuda only
IlyasMoutawwakil Jun 16, 2026
b9e7919
onnx fixes
IlyasMoutawwakil Jun 17, 2026
962e70b
drop cpu gpu sync in mask update
IlyasMoutawwakil Jun 17, 2026
5bf9b8a
lower onnx export time for some models by disabling optimize
IlyasMoutawwakil Jun 17, 2026
61e9ab8
fix executorch
IlyasMoutawwakil Jun 17, 2026
c3ef445
added version drift warnings
IlyasMoutawwakil Jun 17, 2026
26e53fe
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Jun 17, 2026
7a59f83
fix more exeutorch
IlyasMoutawwakil Jun 17, 2026
77c6b5b
remove "legacy" name
IlyasMoutawwakil Jun 18, 2026
5b6993a
model fixes for export compatibility
IlyasMoutawwakil Jun 18, 2026
43326df
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 18, 2026
9e9da66
add minicpmv vision utils
IlyasMoutawwakil Jun 18, 2026
6e6e3ac
can compile
IlyasMoutawwakil Jun 18, 2026
1fce6c3
make ssms fully compilable
IlyasMoutawwakil Jun 18, 2026
7ba1546
more ssms
IlyasMoutawwakil Jun 18, 2026
ff33d8b
address new comments
IlyasMoutawwakil Jun 19, 2026
a2b3a36
fast ci fixes
IlyasMoutawwakil Jun 19, 2026
3a1971b
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
99b2057
address comments
IlyasMoutawwakil Jun 19, 2026
07bc5c7
fix minimax
IlyasMoutawwakil Jun 19, 2026
fadcdf8
fix the last falcon fast ci failure
IlyasMoutawwakil Jun 19, 2026
58f6acb
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
224f016
more comments addressed
IlyasMoutawwakil Jun 19, 2026
1c0de9a
attention
IlyasMoutawwakil Jun 19, 2026
cdc3790
reference attn
IlyasMoutawwakil Jun 19, 2026
1ea08b6
cleanup
IlyasMoutawwakil Jun 19, 2026
42a6ca1
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
21a8fd1
use can_return_tuple in patchmixer
IlyasMoutawwakil Jun 19, 2026
4983667
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
74d9b47
proper gqa expalanation
IlyasMoutawwakil Jun 19, 2026
a9eef0a
avoid 5D attention
IlyasMoutawwakil Jun 19, 2026
83f8fcb
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
7587ae6
granite export fix
IlyasMoutawwakil Jun 19, 2026
b738708
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
17f5e97
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
3ef899e
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 19, 2026
83b39d6
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 19, 2026
7caddb1
address modeling comments
IlyasMoutawwakil Jun 21, 2026
6fddf68
update
IlyasMoutawwakil Jun 21, 2026
6090851
address more comments, unify linear attention and make more models su…
IlyasMoutawwakil Jun 21, 2026
a1be3ef
style
IlyasMoutawwakil Jun 21, 2026
bf4a9c7
style
IlyasMoutawwakil Jun 21, 2026
95f5ae1
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 21, 2026
950df48
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 21, 2026
77d95f3
modeling changes for attn impl compatibility
IlyasMoutawwakil Jun 22, 2026
d8ecd8b
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 22, 2026
6f60ac8
no need for patch
IlyasMoutawwakil Jun 22, 2026
17e3d60
fix
IlyasMoutawwakil Jun 22, 2026
12b284f
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 22, 2026
78e80f6
patch is kenrels available
IlyasMoutawwakil Jun 22, 2026
9e73882
fixes
IlyasMoutawwakil Jun 22, 2026
1ecddd3
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 22, 2026
cecb23e
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 22, 2026
b2f9a31
fix lfm2 conv errors
IlyasMoutawwakil Jun 22, 2026
7fa97a0
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 22, 2026
36d3c4c
diffllama is exportable now
IlyasMoutawwakil Jun 22, 2026
2044624
enable more models
IlyasMoutawwakil Jun 22, 2026
f520f19
address most of anton's review comments
IlyasMoutawwakil Jun 22, 2026
5e7bdee
address cyril's comments
IlyasMoutawwakil Jun 22, 2026
707df61
revert conv rename
IlyasMoutawwakil Jun 22, 2026
32929f6
simpler modular
IlyasMoutawwakil Jun 22, 2026
d8f85a6
keep max_batch_size check
IlyasMoutawwakil Jun 22, 2026
25873ea
fixes
IlyasMoutawwakil Jun 22, 2026
b7d3137
fix moshi cuda graphs
IlyasMoutawwakil Jun 22, 2026
19ee666
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 23, 2026
dd95a83
fix
IlyasMoutawwakil Jun 23, 2026
5f7f241
added layer type class attr in mixers
IlyasMoutawwakil Jun 23, 2026
a14a41c
fix repo
IlyasMoutawwakil Jun 23, 2026
d11c066
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 23, 2026
fa7f996
fix
IlyasMoutawwakil Jun 23, 2026
4fc00f1
address comments
IlyasMoutawwakil Jun 23, 2026
753b086
address comments
IlyasMoutawwakil Jun 23, 2026
5bbba7f
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 23, 2026
d7ceca5
Merge branch 'hf-exporters' of https://github.com/huggingface/transfo…
IlyasMoutawwakil Jun 23, 2026
5e5c892
address comments
IlyasMoutawwakil Jun 29, 2026
cca5865
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 29, 2026
2f4e263
fix merge
IlyasMoutawwakil Jun 29, 2026
6070f0e
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 29, 2026
1faf03e
claude review findings
IlyasMoutawwakil Jun 29, 2026
e6883b5
docs comments
IlyasMoutawwakil Jun 29, 2026
5b6d9f9
address comments
IlyasMoutawwakil Jun 29, 2026
49b7037
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 29, 2026
90adb3e
style
IlyasMoutawwakil Jun 29, 2026
5d7a918
claude review
IlyasMoutawwakil Jun 29, 2026
b52f982
Merge branch 'main' into hf-exporters-models
IlyasMoutawwakil Jun 30, 2026
d4e05dd
small fix caught by copilot
IlyasMoutawwakil Jun 30, 2026
3f64fba
Merge branch 'hf-exporters-models' into hf-exporters
IlyasMoutawwakil Jun 30, 2026
f339f6f
misc fixes after merge
IlyasMoutawwakil Jun 30, 2026
f9501ba
onnx fixes
IlyasMoutawwakil Jun 30, 2026
a0a1118
fix cpu sdpa tripping
IlyasMoutawwakil Jun 30, 2026
109d201
only on cpu
IlyasMoutawwakil Jun 30, 2026
04a234c
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Jun 30, 2026
8bee7d0
fix merge
IlyasMoutawwakil Jun 30, 2026
37654c6
fix
IlyasMoutawwakil Jun 30, 2026
2927c74
address comments
IlyasMoutawwakil Jun 30, 2026
4eeaeb3
more comments
IlyasMoutawwakil Jun 30, 2026
e2a3fd5
nemotron asr
IlyasMoutawwakil Jul 1, 2026
6e97f8a
fix m3
IlyasMoutawwakil Jul 1, 2026
776d8b6
style
IlyasMoutawwakil Jul 1, 2026
c06ef0e
Merge branch 'main' into hf-exporters
IlyasMoutawwakil Jul 1, 2026
5f1692e
add tests for utils
IlyasMoutawwakil Jul 2, 2026
94d8c90
Merge branch 'hf-exporters' of https://github.com/huggingface/transfo…
IlyasMoutawwakil Jul 2, 2026
c415efa
utils testing
IlyasMoutawwakil Jul 2, 2026
de4a8db
style
IlyasMoutawwakil Jul 2, 2026
82727a5
update deprecation
IlyasMoutawwakil Jul 2, 2026
cc027ab
trim tests
IlyasMoutawwakil Jul 2, 2026
72ca863
style
IlyasMoutawwakil Jul 2, 2026
cff3450
skips for executorch
IlyasMoutawwakil Jul 2, 2026
b40ebe4
Merge branch 'main' into hf-exporters
vasqu Jul 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
title: Kernels
- local: perf_torch_compile
title: torch.compile
- local: exporters
title: Exporters
- local: perf_infer_gpu_multi
title: Tensor parallelism
- local: expert_parallelism
Expand Down Expand Up @@ -476,6 +478,8 @@
title: Pipelines
- local: main_classes/processors
title: Processors
- local: main_classes/exporters
title: Exporters
- local: main_classes/quantization
title: Quantization
- local: main_classes/tokenizer
Expand Down
520 changes: 520 additions & 0 deletions docs/source/en/exporters.md

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions docs/source/en/main_classes/exporters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--Copyright 2026 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, 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.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# Exporters

New export backends can be added to Transformers by subclassing [`HfExporter`].

<Tip>

Learn how to use the built-in exporters in the [Exporters](../exporters) guide.

</Tip>

## AutoHfExporter

[[autodoc]] exporters.auto.AutoHfExporter

## AutoExportConfig

[[autodoc]] exporters.auto.AutoExportConfig

## HfExporter

[[autodoc]] exporters.base.HfExporter

## DynamoConfig

[[autodoc]] exporters.configs.DynamoConfig

## OnnxConfig

[[autodoc]] exporters.configs.OnnxConfig

## ExecutorchConfig

[[autodoc]] exporters.configs.ExecutorchConfig
1 change: 1 addition & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"dependency_versions_table": [],
"distributed": [],
"dynamic_module_utils": [],
"exporters": [],
"feature_extraction_sequence_utils": ["SequenceFeatureExtractor"],
"feature_extraction_utils": ["BatchFeature", "FeatureExtractionMixin"],
"file_utils": [],
Expand Down
20 changes: 20 additions & 0 deletions src/transformers/exporters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
# Modifications Copyright (C) 2025, Advanced Micro Devices, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
from .auto import AutoExportConfig, AutoHfExporter, get_hf_exporter, register_export_config, register_exporter
Comment thread
ArthurZucker marked this conversation as resolved.
from .base import HfExporter
from .configs import DynamoConfig, ExecutorchConfig, ExportConfigMixin, ExportFormat, OnnxConfig
from .exporter_dynamo import DynamoExporter
from .exporter_executorch import ExecutorchExporter
from .exporter_onnx import OnnxExporter
185 changes: 185 additions & 0 deletions src/transformers/exporters/auto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
# Modifications Copyright (C) 2025, Advanced Micro Devices, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
"""Auto exporter factory for HuggingFace exporters."""

from __future__ import annotations

from ..utils import logging
from .base import HfExporter
from .configs import ExportConfigMixin, ExportFormat
from .exporter_dynamo import DynamoConfig, DynamoExporter
from .exporter_executorch import ExecutorchConfig, ExecutorchExporter
from .exporter_onnx import OnnxConfig, OnnxExporter


AUTO_EXPORTER_MAPPING = {
"executorch": ExecutorchExporter,
"dynamo": DynamoExporter,
"onnx": OnnxExporter,
}

AUTO_EXPORT_CONFIG_MAPPING = {
"executorch": ExecutorchConfig,
"dynamo": DynamoConfig,
"onnx": OnnxConfig,
}

logger = logging.get_logger(__name__)


class AutoExportConfig:
Comment thread
IlyasMoutawwakil marked this conversation as resolved.
"""
The Auto-HF export config class that takes care of automatically dispatching to the correct
export config given an export config stored in a dictionary.
"""

@classmethod
def from_dict(cls, export_config_dict: dict):
export_format = export_config_dict.get("export_format")

if export_format is None:
raise ValueError("export_config_dict must contain key 'export_format' set to exporter name")

# Allow passing an ExportFormat enum value or a plain string
if isinstance(export_format, ExportFormat):
name = export_format.value
else:
name = export_format

if name not in AUTO_EXPORT_CONFIG_MAPPING:
raise ValueError(
f"Unknown exporter type, got {name} - supported exporters are: {list(AUTO_EXPORT_CONFIG_MAPPING.keys())}"
)

target_cls = AUTO_EXPORT_CONFIG_MAPPING[name]
return target_cls.from_dict(export_config_dict)


class AutoHfExporter:
"""
The Auto-HF expoerter class that takes care of automatically instantiating to the correct
`HfExporter` given the `ExportConfig`.
"""

@classmethod
def from_config(cls, export_config: ExportConfigMixin | dict, **kwargs) -> HfExporter:
# Normalize to a dict so ``supports_export_format`` can act as the single gate.
export_config_dict = export_config.to_dict() if isinstance(export_config, ExportConfigMixin) else export_config
if not cls.supports_export_format(export_config_dict):
raise ValueError(
f"Unsupported export config: {export_config_dict!r}. "
f"Registered exporters: {sorted(AUTO_EXPORTER_MAPPING)}."
)

export_format = export_config_dict["export_format"]
name = export_format.value if isinstance(export_format, ExportFormat) else export_format
return AUTO_EXPORTER_MAPPING[name](**kwargs)

@classmethod
def from_pretrained(cls, pretrained_model_name_or_path, **kwargs) -> HfExporter | None:
"""
Load an exporter instance from a pretrained model/checkpoint that ships an export config.

**Not implemented yet** — placeholder for a first-class "export recipe" workflow.

The idea: model owners publish an ``export_config.json`` (or an ``export_config`` field in
``config.json``) alongside their weights on the Hub. That file captures the settings the
owner has already validated for their architecture — the target format (``dynamo`` /
``onnx`` / ``executorch``), exact dynamic-shape specs (e.g. ``text_ids`` dynamic to 4096,
image tiles fixed at 448, ``batch=1`` for edge deployment), ``strict`` flag, ONNX opset,
prefill vs. decode layout, ExecuTorch backend choice, and any other knob that today lives
as tribal knowledge in a README or a private notebook.

Consumers then get the owner-validated export in one call::

exporter = AutoHfExporter.from_pretrained("org/model-name")
program = exporter.export(model, inputs)

Composes with the [`register_export_input_preparer`] registry: the owner supplies the
shape spec via ``export_config.json``, transformers supplies the data-dependent
precomputations (``cu_seqlens``, vision position ids, window indices, …) for that
architecture. Together they cover the two hard parts of exporting new models — knowing
the right shape contract and preparing the right inputs — so downstream users don't
re-derive either from scratch (and don't break in production when they get it wrong).
"""
raise NotImplementedError(
"AutoHfExporter.from_pretrained is not implemented yet. "
"Load/export configs explicitly and call AutoHfExporter.from_config(...) instead."
)

@staticmethod
def supports_export_format(export_config_dict: dict) -> bool:
"""Return True if the provided dict describes an ``export_format`` that has both a
registered config class and a registered exporter class. Warns with an actionable message
when the format is missing entirely, unknown, or only half-registered."""
export_fmt = export_config_dict.get("export_format")
if export_fmt is None:
logger.warning(
"No 'export_format' key in export config — supported values are: "
f"{sorted(AUTO_EXPORTER_MAPPING)}. Skipping."
)
return False

name = export_fmt.value if isinstance(export_fmt, ExportFormat) else export_fmt
has_config = name in AUTO_EXPORT_CONFIG_MAPPING
has_exporter = name in AUTO_EXPORTER_MAPPING

if not has_config and not has_exporter:
logger.warning(
f"Unknown export format {export_fmt!r} — supported values are: "
f"{sorted(set(AUTO_EXPORTER_MAPPING) & set(AUTO_EXPORT_CONFIG_MAPPING))}. Skipping."
)
return False
if not has_config:
logger.warning(
f"Export format {name!r} has a registered exporter but no config class. "
f"Register one via ``@register_export_config({name!r})``. Skipping."
)
return False
if not has_exporter:
logger.warning(
f"Export format {name!r} has a registered config class but no exporter. "
f"Register one via ``@register_exporter({name!r})``. Skipping."
)
return False
return True


def register_exporter(name: str):
def register_exporter_fn(cls):
if name in AUTO_EXPORTER_MAPPING:
logger.warning(f"Exporter '{name}' is already registered and will be overwritten.")
if not issubclass(cls, HfExporter):
raise TypeError("Exporter must extend HfExporter")
AUTO_EXPORTER_MAPPING[name] = cls
return cls

return register_exporter_fn


def register_export_config(name: str):
def register_export_config_fn(cls):
if name in AUTO_EXPORT_CONFIG_MAPPING:
logger.warning(f"Export config '{name}' is already registered and will be overwritten.")
if not issubclass(cls, ExportConfigMixin):
raise TypeError("Export config must extend ExportConfigMixin")
AUTO_EXPORT_CONFIG_MAPPING[name] = cls
return cls

return register_export_config_fn


def get_hf_exporter(export_config) -> HfExporter:
return AutoHfExporter.from_config(export_config)
Loading
Loading