comment out generation mixin
Browse files- modeling_myolmoe.py +33 -34
modeling_myolmoe.py
CHANGED
|
@@ -16,7 +16,6 @@ from transformers.modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOut
|
|
| 16 |
from transformers.modeling_utils import PreTrainedModel
|
| 17 |
from transformers.models.olmoe.configuration_olmoe import OlmoeConfig
|
| 18 |
from transformers.utils import logging
|
| 19 |
-
from transformers.generation import GenerationMixin
|
| 20 |
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 21 |
|
| 22 |
|
|
@@ -588,41 +587,41 @@ class MyOLMoEForCausalLM(MyOLMoEPreTrainedModel):
|
|
| 588 |
router_logits=outputs.router_logits,
|
| 589 |
)
|
| 590 |
|
| 591 |
-
def prepare_inputs_for_generation(
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
):
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
|
| 608 |
-
|
| 609 |
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
|
|
|
| 16 |
from transformers.modeling_utils import PreTrainedModel
|
| 17 |
from transformers.models.olmoe.configuration_olmoe import OlmoeConfig
|
| 18 |
from transformers.utils import logging
|
|
|
|
| 19 |
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 20 |
|
| 21 |
|
|
|
|
| 587 |
router_logits=outputs.router_logits,
|
| 588 |
)
|
| 589 |
|
| 590 |
+
# def prepare_inputs_for_generation(
|
| 591 |
+
# self,
|
| 592 |
+
# input_ids,
|
| 593 |
+
# past_key_values=None,
|
| 594 |
+
# attention_mask=None,
|
| 595 |
+
# inputs_embeds=None,
|
| 596 |
+
# **kwargs,
|
| 597 |
+
# ):
|
| 598 |
+
# # Same as original implementation
|
| 599 |
+
# if past_key_values is not None:
|
| 600 |
+
# past_length = past_key_values[0][0].shape[2]
|
| 601 |
|
| 602 |
+
# if input_ids.shape[1] > past_length:
|
| 603 |
+
# remove_prefix_length = past_length
|
| 604 |
+
# else:
|
| 605 |
+
# remove_prefix_length = input_ids.shape[1] - 1
|
| 606 |
|
| 607 |
+
# input_ids = input_ids[:, remove_prefix_length:]
|
| 608 |
|
| 609 |
+
# position_ids = kwargs.get("position_ids", None)
|
| 610 |
+
# if attention_mask is not None and position_ids is None:
|
| 611 |
+
# position_ids = attention_mask.long().cumsum(-1) - 1
|
| 612 |
+
# position_ids.masked_fill_(attention_mask == 0, 1)
|
| 613 |
+
# if past_key_values:
|
| 614 |
+
# position_ids = position_ids[:, -input_ids.shape[1] :]
|
| 615 |
|
| 616 |
+
# if inputs_embeds is not None and past_key_values is None:
|
| 617 |
+
# model_inputs = {"inputs_embeds": inputs_embeds}
|
| 618 |
+
# else:
|
| 619 |
+
# model_inputs = {"input_ids": input_ids}
|
| 620 |
|
| 621 |
+
# model_inputs.update({
|
| 622 |
+
# "position_ids": position_ids,
|
| 623 |
+
# "past_key_values": past_key_values,
|
| 624 |
+
# "use_cache": kwargs.get("use_cache"),
|
| 625 |
+
# "attention_mask": attention_mask,
|
| 626 |
+
# })
|
| 627 |
+
# return model_inputs
|