Skip to content

Commit

Permalink
Add gpt-neo-x support (#745)
Browse files Browse the repository at this point in the history
* add gpt-neo-x configs

* fixes

* name fix
  • Loading branch information
sidthekidder authored Feb 7, 2023
1 parent cd21dca commit f02f227
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ They specify which input generators should be used for the dummy inputs, but rem
- GPT-2
- GPT-J
- GPT-Neo
- GPT-NeoX
- GroupVit
- Hubert
- IBert
Expand Down
5 changes: 5 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ class GPTNeoOnnxConfig(TextDecoderOnnxConfig):
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig.with_args(num_attention_heads="num_heads")


class GPTNeoXOnnxConfig(TextDecoderOnnxConfig):
DEFAULT_ONNX_OPSET = 13
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig


class BloomDummyPastKeyValuesGenerator(DummyPastKeyValuesGenerator):
def generate(self, input_name: str, framework: str = "pt"):
past_key_shape = (
Expand Down
7 changes: 7 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ class TasksManager:
"sequence-classification",
onnx="GPTNeoOnnxConfig",
),
"gpt-neox": supported_tasks_mapping(
"default",
"default-with-past",
"causal-lm",
"causal-lm-with-past",
onnx="GPTNeoXOnnxConfig",
),
"groupvit": supported_tasks_mapping(
"default",
onnx="GroupViTOnnxConfig",
Expand Down
1 change: 1 addition & 0 deletions optimum/utils/normalized_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class NormalizedConfigManager:
"electra": NormalizedTextConfig,
"gpt2": GPT2LikeNormalizedTextConfig,
"gpt_neo": NormalizedTextConfig.with_args(num_attention_heads="num_heads"),
"gpt_neox": NormalizedTextConfig,
"gptj": GPT2LikeNormalizedTextConfig,
"longt5": T5LikeNormalizedTextConfig,
"marian": BartLikeNormalizedTextConfig,
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 @@ -53,6 +53,7 @@
"flaubert": "hf-internal-testing/tiny-random-flaubert",
"gpt2": "hf-internal-testing/tiny-random-gpt2",
"gpt-neo": "hf-internal-testing/tiny-random-GPTNeoModel",
"gpt-neox": "hf-internal-testing/tiny-random-GPTNeoXForCausalLM",
"gptj": "hf-internal-testing/tiny-random-GPTJModel",
"groupvit": "hf-internal-testing/tiny-random-groupvit",
"ibert": "hf-internal-testing/tiny-random-IBertModel",
Expand Down Expand Up @@ -151,6 +152,7 @@
"flaubert": "hf-internal-testing/tiny-random-flaubert", # TODO
"gpt2": "gpt2",
"gpt-neo": "EleutherAI/gpt-neo-125M",
"gpt-neox": "EleutherAI/gpt-neox-20b",
"gptj": "anton-l/gpt-j-tiny-random", # TODO
"groupvit": "nvidia/groupvit-gcc-yfcc",
"ibert": "kssteven/ibert-roberta-base",
Expand Down
2 changes: 2 additions & 0 deletions tests/onnxruntime/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"flaubert": "hf-internal-testing/tiny-random-flaubert",
"gpt2": "hf-internal-testing/tiny-random-gpt2",
"gpt_neo": "hf-internal-testing/tiny-random-GPTNeoModel",
"gpt_neox": "hf-internal-testing/tiny-random-GPTNeoXForCausalLM",
"gptj": "hf-internal-testing/tiny-random-GPTJModel",
"groupvit": "hf-internal-testing/tiny-random-groupvit",
"ibert": "hf-internal-testing/tiny-random-IBertModel",
Expand Down Expand Up @@ -1731,6 +1732,7 @@ class ORTModelForCausalLMIntegrationTest(ORTModelTestMixin):
"codegen",
"gpt2",
"gpt_neo",
"gpt_neox",
"gptj",
]

Expand Down

0 comments on commit f02f227

Please sign in to comment.