Skip to content

Commit

Permalink
Add support for OLMo and OLMo2
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Dec 7, 2024
1 parent 4a7cb29 commit bbc91c0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/source/exporters/onnx/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Supported architectures from [🤗 Transformers](https://huggingface.co/docs/tra
- MT5
- Musicgen (text-conditional only)
- Nystromformer
- OLMo
- OLMo2
- OWL-ViT
- Pegasus
- Perceiver
Expand Down
9 changes: 9 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ class LlamaOnnxConfig(TextDecoderWithPositionIdsOnnxConfig):
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig


class OlmoOnnxConfig(LlamaOnnxConfig):
ATOL_FOR_VALIDATION = 1e-4
MIN_TRANSFORMERS_VERSION = version.parse("4.40.0")


class Olmo2OnnxConfig(OlmoOnnxConfig):
MIN_TRANSFORMERS_VERSION = version.parse("4.47.0")


class Qwen2OnnxConfig(LlamaOnnxConfig):
MIN_TRANSFORMERS_VERSION = version.parse("4.37.0")

Expand Down
14 changes: 14 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,20 @@ class TasksManager:
"text-generation-with-past",
onnx="GraniteOnnxConfig",
),
"olmo": supported_tasks_mapping(
"feature-extraction",
"feature-extraction-with-past",
"text-generation",
"text-generation-with-past",
onnx="OlmoOnnxConfig",
),
"olmo2": supported_tasks_mapping(
"feature-extraction",
"feature-extraction-with-past",
"text-generation",
"text-generation-with-past",
onnx="Olmo2OnnxConfig",
),
"pegasus": supported_tasks_mapping(
"feature-extraction",
"feature-extraction-with-past",
Expand Down
2 changes: 2 additions & 0 deletions tests/exporters/exporters_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
"mt5": "lewtun/tiny-random-mt5",
"musicgen": "hf-internal-testing/tiny-random-MusicgenForConditionalGeneration",
"nystromformer": "hf-internal-testing/tiny-random-NystromformerModel",
"olmo": "hf-internal-testing/tiny-random-OlmoForCausalLM",
"olmo2": "hf-internal-testing/tiny-random-Olmo2ForCausalLM",
"opt": "hf-internal-testing/tiny-random-OPTModel",
"owlv2": "hf-internal-testing/tiny-random-Owlv2Model",
"owlvit": "hf-tiny-model-private/tiny-random-OwlViTModel",
Expand Down

0 comments on commit bbc91c0

Please sign in to comment.