Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cover more models with openvino export #709

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions optimum/exporters/openvino/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,58 @@ def outputs(self) -> Dict[str, Dict[int, str]]:
return {
"sample": {0: "batch_size", 2: "height", 3: "width"},
}


@register_in_tasks_manager(
"persimmon",
*[
"feature-extraction",
"feature-extraction-with-past",
"text-generation",
"text-generation-with-past",
"text-classification",
],
library_name="transformers",
)
class PersimmonOpenVINOConfig(TextDecoderWithPositionIdsOnnxConfig):
DEFAULT_ONNX_OPSET = 14
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig


@register_in_tasks_manager("biogpt", *["text-generation", "text-generation-with-past"], library_name="transformers")
class BioGPTOpenVINOConfig(TextDecoderOnnxConfig):
# BioGPT does not require position_ids input.
DEFAULT_ONNX_OPSET = 13
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig


@register_in_tasks_manager(
"gpt-neox-japanese", *["text-generation", "text-generation-with-past"], library_name="transformers"
)
class GPTNeoxJapaneseOpenVINOConfig(TextDecoderOnnxConfig):
# GPTNeoxJapanese does not require position_ids input.
DEFAULT_ONNX_OPSET = 13
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig


@register_in_tasks_manager(
"cohere",
*[
"feature-extraction",
"feature-extraction-with-past",
"text-generation",
"text-generation-with-past",
"text-classification",
],
library_name="transformers",
)
class CohereOpenVINOConfig(LlamaOpenVINOConfig):
pass


@register_in_tasks_manager("xglm", *["text-generation", "text-generation-with-past"], library_name="transformers")
class XGLMConfig(TextDecoderWithPositionIdsOnnxConfig):
DEFAULT_ONNX_OPSET = 13
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig.with_args(
num_attention_heads="attention_heads", hidden_size="d_model"
)
10 changes: 9 additions & 1 deletion tests/openvino/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ class OVModelForCausalLMIntegrationTest(unittest.TestCase):
"orion",
"falcon",
"falcon-40b",
"persimmon",
"biogpt",
"gpt_neox_japanese",
"cohere",
"xglm",
)
GENERATION_LENGTH = 100
REMOTE_CODE_MODELS = (
Expand Down Expand Up @@ -617,8 +622,11 @@ def test_compare_to_transformers(self, model_arch):
if model_arch == "qwen":
return

if model_arch != "chatglm":
if model_arch not in ["chatglm", "persimmon"]:
tokenizer.pad_token_id = tokenizer.eos_token_id

if model_arch == "persimmon":
tokenizer.pad_token_id = tokenizer.bos_token_id
# Compare batched generation
tokenizer.padding_side = "left"
tokens = tokenizer(["Today is a nice day and I am longer", "This is me"], return_tensors="pt", padding=True)
Expand Down
5 changes: 5 additions & 0 deletions tests/openvino/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
"baichuan2": "katuni4ka/tiny-random-baichuan2",
"baichuan2-13b": "katuni4ka/tiny-random-baichuan2-13b",
"bigbird_pegasus": "hf-internal-testing/tiny-random-bigbird_pegasus",
"biogpt": "hf-tiny-model-private/tiny-random-BioGptForCausalLM",
"blenderbot-small": "hf-internal-testing/tiny-random-BlenderbotModel",
"blenderbot": "hf-internal-testing/tiny-random-BlenderbotModel",
"bloom": "hf-internal-testing/tiny-random-BloomModel",
"camembert": "hf-internal-testing/tiny-random-camembert",
"convbert": "hf-internal-testing/tiny-random-ConvBertForSequenceClassification",
"cohere": "hf-internal-testing/tiny-random-CohereForCausalLM",
"chatglm": "katuni4ka/tiny-random-chatglm2",
"codegen": "hf-internal-testing/tiny-random-CodeGenForCausalLM",
"data2vec_text": "hf-internal-testing/tiny-random-Data2VecTextModel",
Expand All @@ -51,6 +53,7 @@
"gpt2": "hf-internal-testing/tiny-random-gpt2",
"gpt_neo": "hf-internal-testing/tiny-random-GPTNeoModel",
"gpt_neox": "hf-internal-testing/tiny-random-GPTNeoXForCausalLM",
"gpt_neox_japanese": "hf-internal-testing/tiny-random-GPTNeoXJapaneseForCausalLM",
"gptj": "hf-internal-testing/tiny-random-GPTJModel",
"hubert": "hf-internal-testing/tiny-random-HubertModel",
"ibert": "hf-internal-testing/tiny-random-ibert",
Expand Down Expand Up @@ -78,6 +81,7 @@
"olmo": "katuni4ka/tiny-random-olmo-hf",
"orion": "katuni4ka/tiny-random-orion",
"pegasus": "hf-internal-testing/tiny-random-pegasus",
"persimmon": "hf-internal-testing/tiny-random-PersimmonForCausalLM",
"pix2struct": "fxmarty/pix2struct-tiny-random",
"phi": "echarlaix/tiny-random-PhiForCausalLM",
"phi3": "katuni4ka/tiny-random-phi3",
Expand Down Expand Up @@ -115,6 +119,7 @@
"whisper": "openai/whisper-tiny.en",
"xlm": "hf-internal-testing/tiny-random-xlm",
"xlm_roberta": "hf-internal-testing/tiny-xlm-roberta",
"xglm": "hf-internal-testing/tiny-random-XGLMForCausalLM",
}


Expand Down
Loading