From d6f8e10c059651c08891f05d321ff2d7bcce073f Mon Sep 17 00:00:00 2001 From: Ella Charlaix Date: Fri, 22 Sep 2023 18:18:08 +0200 Subject: [PATCH 1/3] Fix normalized config key for models architecture --- optimum/utils/normalized_config.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/optimum/utils/normalized_config.py b/optimum/utils/normalized_config.py index 30bbec030ab..f09643f06cf 100644 --- a/optimum/utils/normalized_config.py +++ b/optimum/utils/normalized_config.py @@ -209,7 +209,7 @@ class NormalizedConfigManager: # "big_bird": NormalizedTextConfig, # "bigbird_pegasus": BartLikeNormalizedTextConfig, "blenderbot": BartLikeNormalizedTextConfig, - "blenderbot_small": BartLikeNormalizedTextConfig, + "blenderbot-small": BartLikeNormalizedTextConfig, "bloom": NormalizedTextConfig.with_args(num_layers="n_layer"), "falcon": NormalizedTextConfig.with_args(num_layers="num_hidden_layers", num_attention_heads="num_kv_heads"), "camembert": NormalizedTextConfig, @@ -224,8 +224,8 @@ class NormalizedConfigManager: "encoder-decoder": NormalizedEncoderDecoderConfig, "gpt2": GPT2LikeNormalizedTextConfig, "gpt-bigcode": GPT2LikeNormalizedTextConfig, - "gpt_neo": NormalizedTextConfig.with_args(num_attention_heads="num_heads"), - "gpt_neox": NormalizedTextConfig, + "gpt-neo": NormalizedTextConfig.with_args(num_attention_heads="num_heads"), + "gpt-neox": NormalizedTextConfig, "llama": NormalizedTextConfig, "gptj": GPT2LikeNormalizedTextConfig, "imagegpt": GPT2LikeNormalizedTextConfig, @@ -233,7 +233,7 @@ class NormalizedConfigManager: "marian": BartLikeNormalizedTextConfig, "mbart": BartLikeNormalizedTextConfig, "mt5": T5LikeNormalizedTextConfig, - "m2m_100": BartLikeNormalizedTextConfig, + "m2m-100": BartLikeNormalizedTextConfig, "nystromformer": NormalizedTextConfig, "opt": NormalizedTextConfig, "pegasus": BartLikeNormalizedTextConfig, @@ -242,7 +242,7 @@ class NormalizedConfigManager: "regnet": NormalizedVisionConfig, "resnet": NormalizedVisionConfig, "roberta": NormalizedTextConfig, - "speech_to_text": SpeechToTextLikeNormalizedTextConfig, + "speech-to-text": SpeechToTextLikeNormalizedTextConfig, "splinter": NormalizedTextConfig, "t5": T5LikeNormalizedTextConfig, "trocr": TrOCRLikeNormalizedTextConfig, @@ -252,7 +252,7 @@ class NormalizedConfigManager: "xlm-roberta": NormalizedTextConfig, "yolos": NormalizedVisionConfig, "mpt": MPTNormalizedTextConfig, - "gpt_bigcode": GPTBigCodeNormalizedTextConfig, + "gpt-bigcode": GPTBigCodeNormalizedTextConfig, } @classmethod @@ -266,5 +266,6 @@ def check_supported_model(cls, model_type: str): @classmethod def get_normalized_config_class(cls, model_type: str) -> Type: + model_type = model_type.replace("_", "-") cls.check_supported_model(model_type) return cls._conf[model_type] From dc657a29869ba6c6b5698b0630fa181f7273f059 Mon Sep 17 00:00:00 2001 From: Ella Charlaix Date: Fri, 22 Sep 2023 18:26:21 +0200 Subject: [PATCH 2/3] fix --- optimum/utils/normalized_config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/optimum/utils/normalized_config.py b/optimum/utils/normalized_config.py index f09643f06cf..14dd17488c4 100644 --- a/optimum/utils/normalized_config.py +++ b/optimum/utils/normalized_config.py @@ -223,7 +223,7 @@ class NormalizedConfigManager: "electra": NormalizedTextConfig, "encoder-decoder": NormalizedEncoderDecoderConfig, "gpt2": GPT2LikeNormalizedTextConfig, - "gpt-bigcode": GPT2LikeNormalizedTextConfig, + "gpt-bigcode": GPTBigCodeNormalizedTextConfig, "gpt-neo": NormalizedTextConfig.with_args(num_attention_heads="num_heads"), "gpt-neox": NormalizedTextConfig, "llama": NormalizedTextConfig, @@ -252,7 +252,6 @@ class NormalizedConfigManager: "xlm-roberta": NormalizedTextConfig, "yolos": NormalizedVisionConfig, "mpt": MPTNormalizedTextConfig, - "gpt-bigcode": GPTBigCodeNormalizedTextConfig, } @classmethod From 4ad92aa72cd46688d1940408dae0cc2ec26c1601 Mon Sep 17 00:00:00 2001 From: Ella Charlaix Date: Mon, 2 Oct 2023 11:51:41 +0200 Subject: [PATCH 3/3] uniformize --- optimum/onnxruntime/utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/optimum/onnxruntime/utils.py b/optimum/onnxruntime/utils.py index 4152febb2d7..9f5178c46c0 100644 --- a/optimum/onnxruntime/utils.py +++ b/optimum/onnxruntime/utils.py @@ -101,8 +101,8 @@ class ORTConfigManager: "albert": "bert", "bart": "bart", "bert": "bert", - "big_bird": "bert", - # "bigbird_pegasus": None, # bug in `fusion_skiplayernorm.py` + "big-bird": "bert", + # "bigbird-pegasus": None, # bug in `fusion_skiplayernorm.py` "blenderbot": "bert", "bloom": "gpt2", "camembert": "bert", @@ -112,9 +112,9 @@ class ORTConfigManager: "distilbert": "bert", "electra": "bert", "gpt2": "gpt2", - "gpt_bigcode": "gpt2", - "gpt_neo": "gpt2", - "gpt_neox": "gpt2", + "gpt-bigcode": "gpt2", + "gpt-neo": "gpt2", + "gpt-neox": "gpt2", "gptj": "gpt2", # longt5 with O4 results in segmentation fault "longt5": "bert", @@ -122,7 +122,7 @@ class ORTConfigManager: "marian": "bart", "mbart": "bart", "mt5": "bart", - "m2m_100": "bart", + "m2m-100": "bart", "nystromformer": "bert", "pegasus": "bert", "roberta": "bert", @@ -134,6 +134,7 @@ class ORTConfigManager: @classmethod def get_model_ort_type(cls, model_type: str) -> str: + model_type = model_type.replace("_", "-") cls.check_supported_model(model_type) return cls._conf[model_type] @@ -161,7 +162,7 @@ def check_optimization_supported_model(cls, model_type: str, optimization_config "vit", "swin", ] - + model_type = model_type.replace("_", "-") if (model_type not in cls._conf) or (cls._conf[model_type] not in supported_model_types_for_optimization): raise NotImplementedError( f"ONNX Runtime doesn't support the graph optimization of {model_type} yet. Only {list(cls._conf.keys())} are supported. "