From d1924f0e65917a2e4692e3d860b377cfa1da1216 Mon Sep 17 00:00:00 2001 From: IlyasMoutawwakil Date: Mon, 13 Jan 2025 12:22:30 +0100 Subject: [PATCH 1/2] uncomment modernbert --- optimum/exporters/onnx/model_configs.py | 6 +++--- optimum/exporters/tasks.py | 18 +++++++++--------- tests/exporters/exporters_utils.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/optimum/exporters/onnx/model_configs.py b/optimum/exporters/onnx/model_configs.py index fd3c20d29d..2d1a11d5f2 100644 --- a/optimum/exporters/onnx/model_configs.py +++ b/optimum/exporters/onnx/model_configs.py @@ -183,9 +183,9 @@ def inputs(self) -> Dict[str, Dict[int, str]]: return {"input_ids": dynamic_axis, "attention_mask": dynamic_axis} -# TODO: uncomment when transformers>=4.48.0 -# class ModernBertOnnxConfig(DistilBertOnnxConfig): -# pass +class ModernBertOnnxConfig(DistilBertOnnxConfig): + MIN_TRANSFORMERS_VERSION = version.parse("4.48.0") + pass class MPNetOnnxConfig(DistilBertOnnxConfig): diff --git a/optimum/exporters/tasks.py b/optimum/exporters/tasks.py index 2f7324fcf7..3793a56068 100644 --- a/optimum/exporters/tasks.py +++ b/optimum/exporters/tasks.py @@ -893,15 +893,15 @@ class TasksManager: "image-classification", onnx="MobileNetV2OnnxConfig", ), - # "modernbert": supported_tasks_mapping( - # "feature-extraction", - # "fill-mask", - # "text-classification", - # "multiple-choice", - # "token-classification", - # "question-answering", - # onnx="ModernBertOnnxConfig", - # ), + "modernbert": supported_tasks_mapping( + "feature-extraction", + "fill-mask", + "text-classification", + "multiple-choice", + "token-classification", + "question-answering", + onnx="ModernBertOnnxConfig", + ), "mpnet": supported_tasks_mapping( "feature-extraction", "fill-mask", diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py index a36ef6afa0..ee31397fd8 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -125,7 +125,7 @@ "mobilenet-v2": "hf-internal-testing/tiny-random-MobileNetV2Model", "mobilenet-v1": "google/mobilenet_v1_0.75_192", "mobilevit": "hf-internal-testing/tiny-random-mobilevit", - # "modernbert": "hf-internal-testing/tiny-random-ModernBertForMaskedLM", + "modernbert": "hf-internal-testing/tiny-random-ModernBertForMaskedLM", "mpnet": "hf-internal-testing/tiny-random-MPNetModel", "mpt": "hf-internal-testing/tiny-random-MptForCausalLM", "mt5": "lewtun/tiny-random-mt5", @@ -269,7 +269,7 @@ # "mobilenet_v1": "google/mobilenet_v1_0.75_192", # "mobilenet_v2": "google/mobilenet_v2_0.35_96", "mobilevit": "apple/mobilevit-small", - # "modernbert": "answerdotai/ModernBERT-base", + "modernbert": "answerdotai/ModernBERT-base", "mpt": "mosaicml/mpt-7b", "mt5": "lewtun/tiny-random-mt5", # Not using google/mt5-small because it takes too much time for testing. "musicgen": "facebook/musicgen-small", From 0a01569ce51abf4ff2e24b8fc61a31ddf6b5cf07 Mon Sep 17 00:00:00 2001 From: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:23:08 +0100 Subject: [PATCH 2/2] Update optimum/exporters/onnx/model_configs.py --- optimum/exporters/onnx/model_configs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/optimum/exporters/onnx/model_configs.py b/optimum/exporters/onnx/model_configs.py index 2d1a11d5f2..503f28d057 100644 --- a/optimum/exporters/onnx/model_configs.py +++ b/optimum/exporters/onnx/model_configs.py @@ -185,7 +185,6 @@ def inputs(self) -> Dict[str, Dict[int, str]]: class ModernBertOnnxConfig(DistilBertOnnxConfig): MIN_TRANSFORMERS_VERSION = version.parse("4.48.0") - pass class MPNetOnnxConfig(DistilBertOnnxConfig):