Charlie81 commited on
Commit
36b7e2b
·
1 Parent(s): affa284

comment out generation mixin

Browse files
Files changed (1) hide show
  1. 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
- self,
593
- input_ids,
594
- past_key_values=None,
595
- attention_mask=None,
596
- inputs_embeds=None,
597
- **kwargs,
598
- ):
599
- # Same as original implementation
600
- if past_key_values is not None:
601
- past_length = past_key_values[0][0].shape[2]
602
 
603
- if input_ids.shape[1] > past_length:
604
- remove_prefix_length = past_length
605
- else:
606
- remove_prefix_length = input_ids.shape[1] - 1
607
 
608
- input_ids = input_ids[:, remove_prefix_length:]
609
 
610
- position_ids = kwargs.get("position_ids", None)
611
- if attention_mask is not None and position_ids is None:
612
- position_ids = attention_mask.long().cumsum(-1) - 1
613
- position_ids.masked_fill_(attention_mask == 0, 1)
614
- if past_key_values:
615
- position_ids = position_ids[:, -input_ids.shape[1] :]
616
 
617
- if inputs_embeds is not None and past_key_values is None:
618
- model_inputs = {"inputs_embeds": inputs_embeds}
619
- else:
620
- model_inputs = {"input_ids": input_ids}
621
 
622
- model_inputs.update({
623
- "position_ids": position_ids,
624
- "past_key_values": past_key_values,
625
- "use_cache": kwargs.get("use_cache"),
626
- "attention_mask": attention_mask,
627
- })
628
- return model_inputs
 
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