Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[PoC] HF exporters#41992

Merged
vasqu merged 406 commits into
mainfrom
hf-exporters
Jul 2, 2026
Merged

[PoC] HF exporters#41992
vasqu merged 406 commits into
mainfrom
hf-exporters

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Nov 3, 2025

Copy link
Copy Markdown
Member

CI

HfExporters: Native, Unified export for PyTorch / ONNX / ExecuTorch

thumbnail

Edit: pieces of this PR were merged separately (#42697, #42317), so this one is now focused on the HfExporters machinery itself.

What this adds

A native, in-Transformers export pipeline — one base class (HfExporter), three subclasses for the runtimes we care about, one unified API:

Exporter Output Runtime
DynamoExporter ExportedProgram Any PyTorch runtime, AOT compilation
OnnxExporter ONNXProgram Any ONNX runtime (ORT, TensorRT, OpenVINO, …)
ExecutorchExporter ExecutorchProgramManager Mobile and edge (ExecuTorch)

Same call shape across all three. Dynamic shapes by default. Generation-style models split automatically into prefill + decode (+ vision/audio sub-encoders for VLMs).

from transformers import AutoModelForMaskedLM, AutoTokenizer
from transformers.exporters import OnnxExporter, OnnxConfig

model_id = "hf-internal-testing/tiny-random-BertForMaskedLM"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id).eval()
inputs = tokenizer(["Hello, my dog is cute"] * 2, return_tensors="pt")
onnx_program = OnnxExporter().export(model, inputs, config=OnnxConfig(dynamic=True))

new_input = tokenizer("Hello, my cat is so adorable!", return_tensors="pt")
torch.testing.assert_close(
    onnx_program.call_reference(**new_input)[0],   # numpy reference
    onnx_program(**new_input)[0],                  # onnxruntime
    rtol=1e-4, atol=1e-4,
)

Swap one line for another runtime — DynamoExporter() / DynamoConfig or ExecutorchExporter() / ExecutorchConfig(backend=...).

For generative models the prefill/decode split is captured automatically:

from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.exporters import OnnxExporter, OnnxConfig

model_id = "hf-internal-testing/tiny-random-LlamaForCausalLM"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id).eval()
inputs = tokenizer(["Hello, my dog is cute"] * 2, return_tensors="pt")

artifacts = OnnxExporter().export_for_generation(model, inputs, config=OnnxConfig(dynamic=True))
# {"prefill": ONNXProgram, "decode": ONNXProgram}
# For VLMs: also vision_encoder, audio_encoder, multi_modal_projector, language_model, lm_head

Why native, not via Optimum

torch.export is fast and clean but strict compared to TorchScript — data-dependent ifs that TorchScript would just trace through (with a warning) become hard guard failures, hence the if not torch.compiler.is_exporting() opt-outs landing throughout modeling code. Living downstream in Optimum means every new architecture (a new attention pattern, a new cache type, a new modality) waits for someone to write export glue. By colocating the exporters with the models, the export evolves with the model and breakages surface in the model's own test file, not weeks later in a separate repo.

Optimum will keep building on this — generating inputs, dynamic axes, splitting components, wiring inference. This PR is the API and the registry it builds on.

How it works

export_for_generation runs the model's real generate(..., max_new_tokens=2) once, hooks forward to capture the actual prefill and decode kwargs, then exports each independently. Multimodal models decompose further into per-component sub-graphs. Decoder-only, SSM, encoder-decoder — same machinery.

Multi-stage patching

Every backend follows the same pipeline (5 stages for ONNX, 4 for the others). The principle: fix exports without touching modeling code wherever possible. Each fix lives at the lowest stage that can express it cleanly.

Stage Mechanism When to use
1. Torch patches @register_patch(backend, "torch.X.method") reversible class-attribute swap during tracing The op's graph structure needs to change (no ONNX equivalent, missing decomposition, data-dependent branch)
2. FX node fixes @register_fx_node_fix(backend) per-node rewriters on the post-export graph Functional-graph violations (in-place ops, alias chains), dead symbolic-guard nodes
3. FX program fixes @register_fx_program_fix(backend) program-level passes on the ExportedProgram Structural repairs (signature alignment, cross-graph rewrites)
4. ONNX translations _ONNX_TRANSLATION_TABLE custom onnxscript per aten op Op traces correctly but lacks a correct ONNX lowering
5. ONNX IR fixes post-export mutation of the ONNXProgram Backend-specific quirks (e.g. TopK(sorted=1) for ORT)

@register_export_input_preparer(*markers) covers a related case: precompute data-dependent kwargs (cu_seqlens, position ids, window indices, bilinear interpolation grids, audio chunking) outside the traced graph.

Adding support for a new model is a function and a decorator. No new files, no plumbing, no per-backend boilerplate.

Other moving parts

  • Dynamic shapes by default. dynamic=True walks tensors / caches / dicts / lists / ModelOutputs and assigns Dim.AUTO everywhere — no per-model dynamic_shapes dict.
  • Cache pytree registration is reflection-driven. Cache.__subclasses__() is walked at export time and each registered as a pytree node; model-specific cache types (anything ending in Cache) get picked up too. past_key_values becomes just another tensor structure to the exporter.
  • State cleanup after export. Stateful tensor attrs (sliding-window buffers, etc.) that torch.export may leave as FakeTensors are reset so a follow-up eager forward on the same module stays safe.
  • Forward-signature flattening. **kwargs: Unpack[TransformersKwargs] is rewritten to a flat signature derived from the user's inputs — otherwise torch.export bundles **kwargs into one blob that doesn't line up with dynamic_shapes.

What's tested

The export tests are wired into ModelTesterMixin directly, so every model that uses the standard test mixin gets test_torch_export_*, test_onnx_export_*, and test_executorch_export_* for free (forward + generation variants where relevant). That's the bulk of the model zoo — LLMs, VLMs, audio encoders, vision backbones, detection / segmentation.

Skip lists in tests/exporters/test_utils.py are short, scoped, and each entry points to a specific upstream torch.export / onnxscript issue or modeling bug we want to fix at the source — not paper over here.

What's not perfect yet

  • export_for_generation returns independent graphs, not a turnkey inference pipeline. Wiring them together (encoder → projector → language model → lm_head, decode loop) is downstream's job. We're actively working to reduce that glue.
  • Some workarounds in the registries will disappear when PyTorch or onnxscript lands the equivalent fix. Each is marked with the issue it works around — keeping these visible is the point.

Reproducing

pip install -e . torch onnxscript executorch onnxruntime

Then any of the snippets above; full per-model tests:

RUN_SLOW=1 pytest tests/models/<model>/test_modeling_<model>.py \
    -k "test_onnx_export or test_torch_export or test_executorch_export"

@IlyasMoutawwakil IlyasMoutawwakil marked this pull request as draft November 3, 2025 14:29
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@IlyasMoutawwakil

IlyasMoutawwakil commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

Currently all models (except a select few) are tested and pass the tests successfully !

389 passed, 87 skipped, 413 warnings in 143.73s (0:02:23)

skipped tests either:

  • explicitly skipped with test_torch_exportable = False, this is for custom cache models and some MoEs (15).
  • errors with an informative error torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNod (67).
  • errors with a cryptic Expected cond to be True, but got False.. (16).

@IlyasMoutawwakil IlyasMoutawwakil changed the title Hf exporters [PoC] HF exporters Nov 6, 2025
@IlyasMoutawwakil IlyasMoutawwakil requested review from vasqu and removed request for vasqu November 10, 2025 15:52
@IlyasMoutawwakil IlyasMoutawwakil marked this pull request as ready for review November 13, 2025 08:42
"qwen3_vl", # fast_pos_embed_interpolate is data-dependent
"qwen3_vl_moe", # fast_pos_embed_interpolate is highly data-dependent
"siglip2", # torch.export is failing on torch.nn.functional.interpolate
"siglip2_vision_model", # torch.export is failing on torch.nn.functional.interpolate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the issue related to unsupported combination of parameters (e.g., antialias=True, mode=bicubic)? In such a case, I think adding a warning and falling back to a similar mode is sufficient.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really the issue i was seeing, dynamo is having problems with the for loops in

for t, h, w in zip(grid_ts, grid_hs, grid_ws):
for example, but I haven't dug as deep as with the MoEs to not block the PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for siglip2_vision_model? 👀

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh let me check

@IlyasMoutawwakil IlyasMoutawwakil Nov 19, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problems I see are in this loop:


there are a couple problems, the first one we see when we export is torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNode: Could not guard on data-dependent expression u0 > 0 (unhinted: u0 > 0) which is fixable by adding some hints on max_h and max_w.
however there's a second one that pops right afterward that I'm not sure how to fix, and then there's the fact that this is all happening in data-dependent loop (static batch size).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay I just found the hint that was missing to fix the dynamo export ! 😁

@IlyasMoutawwakil IlyasMoutawwakil Nov 19, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now lfm2_vl and siglip2 are both exportable 😁
(siglip2_vision onnx exported model however seems to have very different outputs than torch)

Comment thread src/transformers/exporters/utils.py Outdated
MODEL_TYPES_WITH_UNSUPPORTED_CACHE_CLASS: set[str] = {
"falcon_mamba",
"jamba",
"lfm2",

@xenova xenova Nov 18, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of model with this cache class supported: https://huggingface.co/onnx-community/LFM2-350M-ONNX

(in case we will add it eventually)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes pytree support is easy to add for all of them, I'm leaving them as leftover for other PRs because this one got big enough 😭 (it was supposed to be a simple poc but well 😂)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha sounds good!

Comment thread src/transformers/exporters/utils.py Outdated
Comment on lines +184 to +185
"mamba",
"mamba2",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of model with this cache class supported: https://huggingface.co/onnx-community/granite-4.0-h-350m-ONNX

(in case we will add it eventually)

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thanks a lot, most of the changes look very good to me!

Finally for onnx, I don't think we want to handle the list of ops to patch ourselves.

It is a good start tho, I am not very closed to this if it helps making sure our exports are correct. Its something important that we have to talk about.

But for now I would isolate changes related to modeling code, bench a tad bit and if its not affecting perf we can alreaddy merge them

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this I don't mind, I think @Cyrilvallez would know a bit better

Comment thread src/transformers/exporters/exporter_onnx.py

@jackzhxng jackzhxng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IlyasMoutawwakil @ArthurZucker thoughts on moving static cache export tests like these into a single inherited test under CausalLMModelTest such that all new causal LM models automatically run this test, similar to what you are doing with ModelTesterMixin? The advantage of this is that model authors who have their models pass this test will be able to run on ExecuTorch.

cc @mergennachin

"encodec", # torch.export struggles with torch.nn.functional.pad with "reflect" mode
"esm", # uses compute_tm function which data-dependent
"fastspeech2_conformer", # Even after making parts of it exportable, dynamo still struggle with the convolutions in FastSpeech2ConformerMultiLayeredConv1d
"fastspeech2_conformer_with_hifigan", # Even after making parts of it exportable, dynamo still struggle with the convolutions in FastSpeech2ConformerMultiLayeredConv1d

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a missing op or a tracer issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-dep guard error so tracer issue i guess, i haven't seen any missing ops (only ones i can think are when the model uses custom kernels or torch compile).
you can check the error by commenting the model_type from this list and running RUN_SLOW=1 pytest tests/models/{model_type}/ -k "test_torch_export" -vvvv

Comment thread src/transformers/exporters/exporter_dynamo.py Outdated
Comment thread src/transformers/exporters/exporter_dynamo.py Outdated

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing some docs! But otherwise LGTM!
ExportConfig is nice,

Comment thread src/transformers/exporters/__init__.py
Comment thread src/transformers/exporters/exporter_dynamo.py


# (object, attribute, factory) triples installed by patch_torch_ops.
_TORCH_PATCH_TABLE = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot! 🤗

@IlyasMoutawwakil IlyasMoutawwakil Mar 18, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of these should be upstreamed into either torch or executorch

Comment on lines +176 to +184
# ── Stage 1: Torch patches ─────────────────────────────────────────────────────
# Monkey-patches applied during torch.export / Dynamo tracing.
# Each _patch_* function is a factory: receives the original op and returns the
# replacement, closing over the original.
#
# _TORCH_PATCH_TABLE is a list of (object, attr, factory) triples.
# patch_torch_ops installs them and restores on exit.
#
# To add a new patch: define a _patch_* factory and append to _TORCH_PATCH_TABLE.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want this in the doc as well not only the code!

Comment on lines +411 to +414
# ── Stage 2: FX graph patches ──────────────────────────────────────────────────
# Rewrite FX nodes between torch.export (stage 1) and run_decompositions.
# Each fixer: (gm, node) -> bool. Return True = node consumed, stop.
#

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same a doc on this exporter would be nice, for potentially other PRs and explaining why we do this! i have no idea :)

Comment on lines +394 to +396
if is_tracing():
seq_len = seq_len.item()
torch_compilable_check(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need allll those checks?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, idefics is a very messy model (it changes its state during forward) we can just not support export for it at this point since it's kinda old.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually no longer needed, it seems that the vlm decomposition i introduced makes the components easy to export (compared to exporting the entire prefill graph)

Comment on lines 1142 to 1143
output_hidden_states: bool | None = None,
return_dict: bool | None = None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decorator is probably missing here instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use decorator instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non generative models won't have export tests anymore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they do, basically now we do a forward test for all models (through ExportTesterMixin) and a generate test for all generative models (through ExportGenerateTesterMixin)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure we also had some integration tests re executorch: Kind of the same comment that we might want to move forward and uses exporters and remove the executorch integration (via alias or similar)

Comment on lines +887 to +896
@deprecate_kwarg("image_grid_thw", new_name="grid_thw", version="5.14.0")
def forward(
self, pixel_values: torch.Tensor, image_grid_thw: torch.Tensor, **kwargs: Unpack[TransformersKwargs]
self, pixel_values: torch.Tensor, grid_thw: torch.Tensor, **kwargs: Unpack[TransformersKwargs]
) -> BaseModelOutputWithPooling:
r"""
image_grid_thw (`torch.Tensor` of shape `(num_images, 3)`):
grid_thw (`torch.Tensor` of shape `(num_images, 3)`):
The temporal, height and width of feature shape of each image.
"""
embeds = self.embeddings(pixel_values).to(self.pre_layrnorm.weight.dtype)
cos, sin = self.rotary_emb(image_grid_thw, device=embeds.device, dtype=embeds.dtype)
cos, sin = self.rotary_emb(grid_thw, device=embeds.device, dtype=embeds.dtype, kwargs=kwargs)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we increase the version a bit? But otherwise fine with that

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a native “HF exporters” subsystem inside Transformers, providing a unified export API across torch.export (Dynamo), ONNX, and ExecuTorch, along with test mixins to exercise exportability across the model test suite and initial documentation.

Changes:

  • Adds a new transformers.exporters package (configs, base API, backend exporters, shared utils, auto-factory).
  • Integrates exporter test coverage into ModelTesterMixin / GenerationTesterMixin via new tests/exporters/test_utils.py mixins and updates/annotates per-model exportability flags.
  • Extends a few core utilities needed by exporters (vision position IDs, pytree registration, availability checks, small model-side changes to accept precomputed kwargs).

Reviewed changes

Copilot reviewed 87 out of 88 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_modeling_common.py Mixes export test coverage into ModelTesterMixin and removes legacy test_torch_export implementation.
tests/generation/test_utils.py Mixes generation export tests into GenerationTesterMixin.
tests/exporters/test_utils.py New exporter test mixins + skip/optimize-control registries for export sweeps.
tests/exporters/init.py Declares tests.exporters package for test mixin imports.
tests/models/vits/test_modeling_vits.py Adds reason comment for test_torch_exportable = False.
tests/models/vilt/test_modeling_vilt.py Adds reason comment for test_torch_exportable = False and removes redundant subclass override.
tests/models/videomt/test_modeling_videomt.py Removes test_torch_exportable = False override.
tests/models/video_llama_3/test_modeling_video_llama_3.py Marks VideoLlama3 vision + VLM tests as not torch-exportable with rationale.
tests/models/timesfm/test_modeling_timesfm.py Removes test_torch_exportable = False override.
tests/models/tapas/test_modeling_tapas.py Adds reason comment for test_torch_exportable = False.
tests/models/superpoint/test_modeling_superpoint.py Adds reason comment for test_torch_exportable = False.
tests/models/superglue/test_modeling_superglue.py Adds reason comment for test_torch_exportable = False.
tests/models/slanext/test_modeling_slanext.py Adjusts tiny config sizes and removes test_torch_exportable = False override.
tests/models/slanet/test_modeling_slanet.py Adds reason comment for test_torch_exportable = False.
tests/models/rwkv/test_modeling_rwkv.py Removes test_torch_exportable = False override.
tests/models/reformer/test_modeling_reformer.py Removes one test_torch_exportable override and adds rationale to another.
tests/models/qwen3_omni_moe/test_modeling_qwen3_omni_moe.py Removes nested model_type from audio config in tests.
tests/models/qwen2_5_omni/test_modeling_qwen2_5_omni.py Removes nested model_type from audio config in tests.
tests/models/qianfan_ocr/test_modeling_qianfan_ocr.py Removes test_torch_exportable = False override.
tests/models/pixtral/test_modeling_pixtral.py Adds reason comment for test_torch_exportable = False.
tests/models/pi0/test_modeling_pi0.py Removes test_torch_exportable = False override.
tests/models/phi4_multimodal/test_modeling_phi4_multimodal.py Adds reason comment for test_torch_exportable = False.
tests/models/pe_audio_video/test_modeling_pe_audio_video.py Adds reason comment for test_torch_exportable = False.
tests/models/parakeet/test_modeling_parakeet.py Removes test_torch_exportable = False overrides.
tests/models/paddleocr_vl/test_modeling_paddleocr_vl.py Removes nested model_type in test configs.
tests/models/oneformer/test_modeling_oneformer.py Adds reason comment for test_torch_exportable = False.
tests/models/omdet_turbo/test_modeling_omdet_turbo.py Updates rationale for test_torch_exportable = False.
tests/models/nemotron3_5_asr/test_modeling_nemotron3_5_asr.py Removes test_torch_exportable = False override.
tests/models/mra/test_modeling_mra.py Removes test_torch_exportable = False override.
tests/models/mm_grounding_dino/test_modeling_mm_grounding_dino.py Adjusts test shapes (batch size, image size).
tests/models/mistral3/test_modeling_mistral3.py Adds reason comment for test_torch_exportable = False.
tests/models/minicpmv4_6/test_modeling_minicpmv4_6.py Ensures target_sizes tensor is created on torch_device.
tests/models/mimi/test_modeling_mimi.py Adds reason comment for test_torch_exportable = False.
tests/models/longformer/test_modeling_longformer.py Adds reason comment for test_torch_exportable = False.
tests/models/llava_onevision/test_modeling_llava_onevision.py Removes test_torch_exportable = False override.
tests/models/llava_next/test_modeling_llava_next.py Removes test_torch_exportable = False override.
tests/models/llava_next_video/test_modeling_llava_next_video.py Removes test_torch_exportable = False override.
tests/models/lighton_ocr/test_modeling_lighton_ocr.py Adds reason comment for test_torch_exportable = False.
tests/models/lightglue/test_modeling_lightglue.py Adds reason comment for test_torch_exportable = False.
tests/models/lfm2_vl/test_modeling_lfm2_vl.py Removes test_torch_exportable = False override.
tests/models/led/test_modeling_led.py Adds reason comment for test_torch_exportable = False.
tests/models/instructblipvideo/test_modeling_instructblipvideo.py Removes test_torch_exportable = False override.
tests/models/instructblip/test_modeling_instructblip.py Removes test_torch_exportable = False override.
tests/models/ibert/test_modeling_ibert.py Moves/clarifies test_torch_exportable = False with updated rationale.
tests/models/hiera/test_modeling_hiera.py Adds reason comment for test_torch_exportable = False.
tests/models/grounding_dino/test_modeling_grounding_dino.py Adjusts test shapes (batch size, image size).
tests/models/granite4_vision/test_modeling_granite4_vision.py Removes test_torch_exportable = False override.
tests/models/gemma4/test_modeling_gemma4.py Ensures boolean mask tensor is created on torch_device.
tests/models/gemma4_unified/test_modeling_gemma4_unified.py Ensures boolean mask tensor is created on torch_device.
tests/models/funnel/test_modeling_funnel.py Adds reason comments for test_torch_exportable = False.
tests/models/fastspeech2_conformer/test_modeling_fastspeech2_conformer.py Adds reason comments for test_torch_exportable = False.
tests/models/evolla/test_modeling_evolla.py Adds reason comment for test_torch_exportable = False.
tests/models/esm/test_modeling_esmfold.py Adds reason comment for test_torch_exportable = False.
tests/models/eomt/test_modeling_eomt.py Adds reason comment for test_torch_exportable = False.
tests/models/eomt_dinov3/test_modeling_eomt_dinov3.py Adds reason comment for test_torch_exportable = False.
tests/models/encodec/test_modeling_encodec.py Adds reason comment for test_torch_exportable = False.
tests/models/emu3/test_modeling_emu3.py Adds reason comment for test_torch_exportable = False.
tests/models/diffusion_gemma/test_modeling_diffusion_gemma.py Removes test_torch_exportable = False override (commented rationale removed).
tests/models/deepseek_ocr2/test_modeling_deepseek_ocr2.py Removes test_torch_exportable = False override.
tests/models/colqwen2/test_modeling_colqwen2.py Removes test_torch_exportable = False override.
tests/models/clvp/test_modeling_clvp.py Removes dataset dependency in test input creation; adjusts imports; removes test_torch_exportable override.
tests/models/canine/test_modeling_canine.py Removes test_torch_exportable = False override.
tests/models/bridgetower/test_modeling_bridgetower.py Removes test_torch_exportable = False override.
tests/models/bigbird_pegasus/test_modeling_bigbird_pegasus.py Adjusts test sequence length.
tests/models/autoformer/test_modeling_autoformer.py Updates rationale comment for test_torch_exportable = False.
src/transformers/vision_utils.py Extends get_vision_position_ids with include_temporal support and refactors block-major computation.
src/transformers/utils/import_utils.py Adds is_onnxscript_available, is_onnxruntime_available, is_executorch_available.
src/transformers/utils/generic.py Adds flatten_with_keys_fn to ModelOutput pytree registration.
src/transformers/utils/init.py Re-exports new availability helpers.
src/transformers/testing_utils.py Adds require_onnxscript, require_onnxruntime, require_executorch decorators.
src/transformers/models/qwen3_asr/modular_qwen3_asr.py Passes kwargs into get_audio_cu_seqlens for precomputed export inputs.
src/transformers/models/qwen3_asr/modeling_qwen3_asr.py Same kwargs pass-through in generated modeling file.
src/transformers/models/minimax_m3_vl/modular_minimax_m3_vl.py Reuses shared vision position ID helper, deprecates image_grid_thw kwarg, and adjusts rotary embedding math.
src/transformers/models/minimax_m3_vl/modeling_minimax_m3_vl.py Same changes in generated modeling file.
src/transformers/integrations/sdpa_attention.py Avoids unnecessary KV repetition when num_key_value_groups == 1.
src/transformers/integrations/executorch.py Docstring wording update (“dynamo” instead of “torchdynamo”).
src/transformers/exporters/base.py Introduces base HfExporter API + environment validation and generation export helper.
src/transformers/exporters/configs.py Adds export config dataclasses and ExportFormat enum.
src/transformers/exporters/utils.py Adds shared export utilities: patch registries, tensor helpers, input precomputers, and decomposition helpers.
src/transformers/exporters/exporter_dynamo.py Implements DynamoExporter wrapper around torch.export + patching/pytree/dynamic-shape/state-reset.
src/transformers/exporters/exporter_executorch.py Implements ExecutorchExporter with backend preparation, torch/executorch patching, and FX fixes.
src/transformers/exporters/auto.py Adds auto-factory classes for exporters/configs (currently has runtime issues).
src/transformers/exporters/init.py Exposes exporters public API.
src/transformers/init.py Adds exporters to lazy import structure.
docs/source/en/main_classes/exporters.md Adds API reference page for exporter classes/configs.
docs/source/en/exporters.md Adds user guide for exporters usage (install, quickstart, dynamic shapes, generation).
docs/source/en/_toctree.yml Adds exporters docs to the documentation TOC.

Comment thread src/transformers/exporters/auto.py
Comment thread src/transformers/exporters/auto.py
Comment thread src/transformers/exporters/configs.py
Comment thread src/transformers/exporters/utils.py

@vasqu vasqu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some last comments from my side, only took a look at the tests but lmk if I should take a look at something else

Also looks like CI is failing because certain packages are not installed on CI

Comment thread tests/exporters/test_utils.py Outdated
Comment thread tests/exporters/test_utils.py Outdated
Comment thread tests/exporters/test_utils.py Outdated
@IlyasMoutawwakil IlyasMoutawwakil added this pull request to the merge queue Jul 2, 2026
@IlyasMoutawwakil IlyasMoutawwakil removed this pull request from the merge queue due to a manual request Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: autoformer, bigbird_pegasus, bridgetower, canine, clvp, colqwen2, deepseek_ocr2, diffusion_gemma, emu3, encodec, eomt, eomt_dinov3, esm, evolla, fastspeech2_conformer, funnel

@vasqu vasqu enabled auto-merge July 2, 2026 17:42
@vasqu vasqu added this pull request to the merge queue Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 28610022278:1
Result: success | Jobs: 14 | Tests: 47,273 | Failures: 0 | Duration: 16h 58m

Merged via the queue into main with commit fde2b96 Jul 2, 2026
103 checks passed
@vasqu vasqu deleted the hf-exporters branch July 2, 2026 18:29
@justinchuby

Copy link
Copy Markdown
Contributor

Congrats!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.