Skip to content
27 changes: 27 additions & 0 deletions optimum/exporters/openvino/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4525,6 +4525,33 @@ def generate_dummy_inputs(self, framework: str = "pt", **kwargs):
return dummy_inputs


class HunyuanDummyPastKeyValuesGenerator(MistralDummyPastKeyValuesGenerator):
def __init__(
self,
task: str,
normalized_config: NormalizedTextConfig,
batch_size: int = DEFAULT_DUMMY_SHAPES["batch_size"],
sequence_length: int = DEFAULT_DUMMY_SHAPES["sequence_length"],
random_batch_size_range: Optional[Tuple[int, int]] = None,
random_sequence_length_range: Optional[Tuple[int, int]] = None,
**kwargs,
):
super().__init__(
task=task,
normalized_config=normalized_config,
batch_size=batch_size,
sequence_length=sequence_length,
random_batch_size_range=random_batch_size_range,
random_sequence_length_range=random_sequence_length_range,
)
self.head_dim = normalized_config.attention_head_dim

@register_in_tasks_manager("hunyuan_v1_dense", *["text-generation", "text-generation-with-past"], library_name="transformers")
class HunyuanOpenVINOConfig(TextDecoderWithPositionIdsOnnxConfig):
MIN_TRANSFORMERS_VERSION = "4.56.0"

DUMMY_INPUT_GENERATOR_CLASSES = (DummyTextInputGenerator, HunyuanDummyPastKeyValuesGenerator)
DUMMY_PKV_GENERATOR_CLASS = HunyuanDummyPastKeyValuesGenerator
@register_in_tasks_manager("ernie4_5", *["text-generation", "text-generation-with-past"], library_name="transformers")
class ErnieOpenVINOConfig(TextDecoderWithPositionIdsOnnxConfig):
MIN_TRANSFORMERS_VERSION = "4.54.0"
Expand Down
4 changes: 4 additions & 0 deletions tests/openvino/test_decoder.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests for modelling to test generate() method is needed as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests for modelling to test generate() method is needed as well

its already covered in test_compare_to_transformers i think

Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class OVModelForCausalLMIntegrationTest(unittest.TestCase):

if is_transformers_version(">=", "4.54.0"):
SUPPORTED_ARCHITECTURES += ("ernie4_5",)

if is_transformers_version(">=", "4.56.0"):
SUPPORTED_ARCHITECTURES += ("hunyuan_v1_dense",)

GENERATION_LENGTH = 100
REMOTE_CODE_MODELS = (
Expand Down Expand Up @@ -219,6 +222,7 @@ class OVModelForCausalLMIntegrationTest(unittest.TestCase):
"falcon-mamba": 0,
"arcee": 2,
"ernie4_5": 2,
"hunyuan_v1_dense": 2,
}

# TODO: remove gptq/awq from here
Expand Down
3 changes: 3 additions & 0 deletions tests/openvino/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class ExportModelTest(unittest.TestCase):

if is_transformers_version(">=", "4.54"):
SUPPORTED_ARCHITECTURES.update({"ernie4_5": OVModelForCausalLM})

if is_transformers_version(">=", "4.56"):
SUPPORTED_ARCHITECTURES.update({"hunyuan_v1_dense": OVModelForCausalLM})

GENERATIVE_MODELS = ("pix2struct", "t5", "bart", "gpt2", "whisper", "llava", "speecht5")

Expand Down
1 change: 1 addition & 0 deletions tests/openvino/test_exporters_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class OVCLIExportTestCase(unittest.TestCase):
"falcon-mamba": 2,
"ernie4_5": 2,
"qwen3": 2,
"hunyuan_v1_dense": 2,
}

TOKENIZER_CHAT_TEMPLATE_TESTS_MODELS = {
Expand Down
1 change: 1 addition & 0 deletions tests/openvino/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"sana": "katuni4ka/tiny-random-sana",
"sana-sprint": "katuni4ka/tiny-random-sana-sprint",
"ltx-video": "katuni4ka/tiny-random-ltx-video",
"hunyuan_v1_dense": "snake7gun/tiny-random-hunyuan",
}


Expand Down