Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9afac3c
Initial commit
danielssonsimonbcg Sep 2, 2025
4bc0fab
Add OnnxConfig
simondanielsson Sep 2, 2025
ae1bfce
Add gemma3 to list of models requiring position ids
simondanielsson Sep 2, 2025
1775f54
Add vocab size to text config
simondanielsson Sep 2, 2025
35a647f
Add normaliezd text and vision config to Gemma3
simondanielsson Sep 2, 2025
454d47b
Update normalized config to grab from manager
simondanielsson Sep 2, 2025
cd831b6
Remove unused logigng
simondanielsson Sep 3, 2025
97c09b9
Update dummy input generator
simondanielsson Sep 3, 2025
03d4de3
Add gemma3 tests
simondanielsson Sep 3, 2025
8345410
Improve formatting of Gemma3OnnxConfig
simondanielsson Sep 3, 2025
55b5280
Add gemma3 onnxruntime tests
simondanielsson Sep 3, 2025
510c2b7
Add Gemma and Gemma3 to list of supported models in docs
simondanielsson Sep 3, 2025
41f0c75
Add Gemma3 to test_decoder.py
simondanielsson Sep 3, 2025
709fff4
Remove commented code
simondanielsson Sep 3, 2025
329062c
Reset formatting in onnx.py
simondanielsson Sep 3, 2025
401f5f7
Remove .DS_Store
simondanielsson Sep 3, 2025
38407e9
Fix formatting
simondanielsson Sep 3, 2025
bd4f48c
Stub base VLM onnx config
simondanielsson Sep 4, 2025
33e2ec6
First version of multimodal OnnxConfig
simondanielsson Sep 4, 2025
d9bd16c
Allow registering custom classes and tasks from optimum-onnx
simondanielsson Sep 4, 2025
04709f9
Implement monolith export of Gemma3
simondanielsson Sep 5, 2025
30fde4c
Add support for exporting multi submodels
simondanielsson Sep 5, 2025
57499b8
Add support for exporting for feature-extraction
simondanielsson Sep 6, 2025
ad68aa1
Add support for with-past
simondanielsson Sep 8, 2025
b420d36
Move classes to appropriate modules
simondanielsson Sep 8, 2025
90bf94c
Remove TODO comment
simondanielsson Sep 8, 2025
e973905
Remove another comment
simondanielsson Sep 8, 2025
01611f4
Rename constant
simondanielsson Sep 8, 2025
7eca9c6
Fix with make style
simondanielsson Sep 8, 2025
e1cedf4
Remove dev from transformer version
simondanielsson Sep 9, 2025
bf27714
Add copyright/license in top of input_generators.py
simondanielsson Sep 9, 2025
a8c0d4a
Remove injection of preprocessors
simondanielsson Sep 9, 2025
54b7e2b
Generate random inputs
simondanielsson Sep 9, 2025
da4b9de
Update VLMDecoderOnnxConfig to be streamlined
simondanielsson Sep 9, 2025
3b2cca6
Add large model test
simondanielsson Sep 9, 2025
522264f
Remove ds.store
simondanielsson Sep 9, 2025
8c0c97e
Propagate behaviors correctly
simondanielsson Sep 9, 2025
eea29dc
Remove modelpatcher and implement direclty in patch_model_for_export
simondanielsson Sep 9, 2025
1359fb1
Remove unused import
simondanielsson Sep 9, 2025
c0148b3
Apply use_cache if use_past is enabled and running LM or monolith
simondanielsson Sep 9, 2025
d6ff393
Add failing tests
simondanielsson Sep 9, 2025
6253636
Attach correct configs for submodels
simondanielsson Sep 9, 2025
e400e07
Add export of multimodal projector
simondanielsson Sep 10, 2025
2f7aa20
Add LM patcher from optimum-intel
simondanielsson Sep 10, 2025
710057d
Remove import of override
simondanielsson Sep 10, 2025
ddd4e74
Update tests
simondanielsson Sep 10, 2025
e9a8811
Run make style
simondanielsson Sep 10, 2025
436b59e
Remove LM head and add text_encoder
simondanielsson Sep 11, 2025
6398669
Remove LM head from tests
simondanielsson Sep 11, 2025
37ea777
Add LANGUAGE_MODEL_WITH_HEAD behvaior
simondanielsson Sep 11, 2025
67a4302
Update tests to use _with_head
simondanielsson Sep 11, 2025
60b250f
Update exported submodels
simondanielsson Sep 11, 2025
c7bb9f9
Stub modeling_vlm module and proper onnxruntime tests
simondanielsson Sep 11, 2025
e76ab45
Remove unused injection of processors in OnnxConfigWithPast
simondanielsson Sep 11, 2025
9b839bc
Remove dsstore
simondanielsson Sep 11, 2025
99be0fb
Change superclass of ORTModelForVIualCausalLM ot ORTModel
simondanielsson Sep 11, 2025
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
2 changes: 2 additions & 0 deletions docs/source/onnx/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Supported architectures from [🤗 Transformers](https://huggingface.co/docs/tra
- ESM
- Falcon
- Flaubert
- Gemma
- Gemma3
- GPT-2
- GPT-BigCode
- GPT-J
Expand Down
11 changes: 11 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,17 @@ class GemmaOnnxConfig(LlamaOnnxConfig):
MIN_TRANSFORMERS_VERSION = version.parse("4.38.0")


@register_tasks_manager_onnx("gemma3", *[*COMMON_TEXT_GENERATION_TASKS, "text-classification"])
class Gemma3OnnxConfig(LlamaOnnxConfig):
DUMMY_INPUT_GENERATOR_CLASSES = (
DummyTextInputGenerator,
DummyVisionInputGenerator,
)
DUMMY_PKV_GENERATOR_CLASS = GemmaDummyPastKeyValuesGenerator
NORMALIZED_CONFIG_CLASS = NormalizedConfigManager.get_normalized_config_class("gemma3")
MIN_TRANSFORMERS_VERSION = version.parse("4.52.0.dev0")
Copy link
Member

@IlyasMoutawwakil IlyasMoutawwakil Sep 3, 2025

Choose a reason for hiding this comment

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

for example, here the model will only support text inputs, as it inherits its inputs property form llama. it also only supports classic decoder model (LLM) tasks, like text-generation.
if your intention is to support text only generation with gemma3, then yes this would be acceptable, in that case there's no need for DummyVisionInputGenerator. Also for NORMALIZED_CONFIG_CLASS, you can define it directly instead of using the config manager.



@register_tasks_manager_onnx("nemotron", *COMMON_TEXT_GENERATION_TASKS)
class NemotronOnnxConfig(GemmaOnnxConfig):
MIN_TRANSFORMERS_VERSION = version.parse("4.48.0") # More stable version than 4.44.0
Expand Down
1 change: 1 addition & 0 deletions optimum/exporters/onnx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"cohere",
"falcon",
"gemma",
"gemma3",
"gpt2",
"gpt_bigcode",
"gpt_neo",
Expand Down
1 change: 1 addition & 0 deletions tests/exporters/onnx/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
},
"flaubert": "hf-internal-testing/tiny-random-flaubert",
"gemma": "fxmarty/tiny-random-GemmaForCausalLM",
"gemma3": "hf-internal-testing/tiny-random-Gemma3ForConditionalGeneration",
"glpn": "hf-internal-testing/tiny-random-GLPNModel",
"gpt2": "hf-internal-testing/tiny-random-gpt2",
"gpt_bigcode": "hf-internal-testing/tiny-random-GPTBigCodeModel",
Expand Down
3 changes: 3 additions & 0 deletions tests/onnxruntime/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
BloomOnnxConfig,
CohereOnnxConfig,
DeepSeekV3OnnxConfig,
Gemma3OnnxConfig,
GemmaOnnxConfig,
GraniteOnnxConfig,
HeliumOnnxConfig,
Expand Down Expand Up @@ -108,6 +109,8 @@ class ORTModelForCausalLMIntegrationTest(ORTModelTestMixin):
SUPPORTED_ARCHITECTURES.append("qwen2")
if is_transformers_version(">=", str(GemmaOnnxConfig.MIN_TRANSFORMERS_VERSION)):
SUPPORTED_ARCHITECTURES.append("gemma")
if is_transformers_version(">=", str(Gemma3OnnxConfig.MIN_TRANSFORMERS_VERSION)):
SUPPORTED_ARCHITECTURES.append("gemma3")
if is_transformers_version(">=", str(MPTOnnxConfig.MIN_TRANSFORMERS_VERSION)):
SUPPORTED_ARCHITECTURES.append("mpt")
if is_transformers_version(">=", str(NemotronOnnxConfig.MIN_TRANSFORMERS_VERSION)):
Expand Down
1 change: 1 addition & 0 deletions tests/onnxruntime/testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"flaubert": "hf-internal-testing/tiny-random-flaubert",
"flux": "optimum-internal-testing/tiny-random-flux",
"gemma": "fxmarty/tiny-random-GemmaForCausalLM",
"gemma3": "hf-internal-testing/tiny-random-Gemma3ForConditionalGeneration",
"gpt2": "hf-internal-testing/tiny-random-GPT2LMHeadModel",
"gpt_bigcode": "hf-internal-testing/tiny-random-GPTBigCodeModel",
"gpt_bigcode-multi_query-False": "optimum-internal-testing/tiny-random-gpt_bigcode-multi_query-False",
Expand Down