Skip to content

Commit 50531a4

Browse files
pragyandevpragyanecharlaix
authoredJan 28, 2025
Adding Onnx Support For Megatron-Bert (#2169)
* Adding Onnx Support For Megatron-Bert * fix style * fix style * fix style --------- Co-authored-by: pragyan <pragyan.singh@tarkas.ai> Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
1 parent 4fdeea7 commit 50531a4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
 

‎optimum/exporters/onnx/model_configs.py

+4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ class RemBertOnnxConfig(BertOnnxConfig):
171171
DEFAULT_ONNX_OPSET = 11
172172

173173

174+
class MegatronBertOnnxConfig(BertOnnxConfig):
175+
DEFAULT_ONNX_OPSET = 11
176+
177+
174178
class DistilBertOnnxConfig(BertOnnxConfig):
175179
DEFAULT_ONNX_OPSET = 14 # now uses F.scaled_dot_product_attention by default for transformers>=4.46.0
176180

‎optimum/exporters/tasks.py

+9
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,15 @@ class TasksManager:
877877
onnx="MobileBertOnnxConfig",
878878
tflite="MobileBertTFLiteConfig",
879879
),
880+
"megatron-bert": supported_tasks_mapping(
881+
"feature-extraction",
882+
"fill-mask",
883+
"text-classification",
884+
"multiple-choice",
885+
"token-classification",
886+
"question-answering",
887+
onnx="MegatronBertOnnxConfig",
888+
),
880889
"mobilevit": supported_tasks_mapping(
881890
"feature-extraction",
882891
"image-classification",

‎tests/exporters/exporters_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
"hf-internal-testing/tiny-random-UniSpeechSatForXVector": ["audio-xvector"],
198198
},
199199
"audio-spectrogram-transformer": "Ericwang/tiny-random-ast",
200+
"megatron-bert": "hf-internal-testing/tiny-random-MegatronBertModel",
200201
# Disabled for now because some operator seems to not be supported by ONNX.
201202
# "mctct": "hf-internal-testing/tiny-random-MCTCTModel",
202203
"speech-to-text": "hf-internal-testing/tiny-random-Speech2TextModel",

0 commit comments

Comments
 (0)