Skip to content

Commit cea2d1f

Browse files
committed
add tests and docs
1 parent 05e0a1d commit cea2d1f

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

docs/source/openvino/models.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Here is the list of the supported architectures :
5858
- GPT-NeoX-Japanese
5959
- Gemma
6060
- Gemma2
61+
- Granite
62+
- GraniteMoE
6163
- Hubert
6264
- IBert
6365
- InternLM

optimum/exporters/openvino/model_patcher.py

+2
Original file line numberDiff line numberDiff line change
@@ -3603,6 +3603,7 @@ def __exit__(self, exc_type, exc_value, traceback):
36033603
block.attn.forward = block.attn._orig_forward
36043604

36053605

3606+
# copied from https://github.com/huggingface/transformers/blob/v4.47.1/src/transformers/models/granitemoe/modeling_granitemoe.py#L321
36063607
def _granite_moe_topk_gating_forward(self, hidden_states):
36073608
# compute the top_k routing decision
36083609
logits = self.layer(hidden_states).float() # [batch_size x seq_len, num_experts]
@@ -3629,6 +3630,7 @@ def _granite_moe_topk_gating_forward(self, hidden_states):
36293630
return index_sorted_experts, batch_index, batch_gates, expert_size, logits
36303631

36313632

3633+
# copied from https://github.com/huggingface/transformers/blob/v4.47.1/src/transformers/models/granitemoe/modeling_granitemoe.py#L281
36323634
def _granite_moe_parallel_experts_forward(self, inputs, expert_size):
36333635
output_list = []
36343636
# difference with original

tests/openvino/utils_tests.py

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"gpt_neox": "hf-internal-testing/tiny-random-GPTNeoXForCausalLM",
7373
"gpt_neox_japanese": "hf-internal-testing/tiny-random-GPTNeoXJapaneseForCausalLM",
7474
"gptj": "hf-internal-testing/tiny-random-GPTJModel",
75+
"granite": "katuni4ka/tiny-random-granite",
76+
"granite-moe": "katuni4ka/tiny-random-granite-moe",
7577
"hubert": "hf-internal-testing/tiny-random-HubertModel",
7678
"ibert": "hf-internal-testing/tiny-random-ibert",
7779
"internlm": "katuni4ka/tiny-random-internlm",

0 commit comments

Comments
 (0)