tengomucho HF Staff commited on
Commit
68196e7
·
verified ·
1 Parent(s): 0d75ccd

Make modeling_internvl_chat.py compatible with transformers v5

Browse files

Append `self.post_init()` at the end of `InternVLChatModel.__init__`
(and optionally at the end of `InternVisionModel.__init__`, mirroring
the already-open PR #10). This matches the standard transformers pattern
— e.g. this model's own Qwen2 language backbone,
[`Qwen2ForCausalLM.__init__`](https://github.com/huggingface/transformers/blob/main/src/transformers/models/qwen2/modeling_qwen2.py#L422),
ends with the same line.

Files changed (1) hide show
  1. modeling_internvl_chat.py +4 -0
modeling_internvl_chat.py CHANGED
@@ -86,6 +86,10 @@ class InternVLChatModel(PreTrainedModel):
86
  self.conv_template = get_conv_template(self.template)
87
  self.system_message = self.conv_template.system_message
88
 
 
 
 
 
89
  def forward(
90
  self,
91
  pixel_values: torch.FloatTensor,
 
86
  self.conv_template = get_conv_template(self.template)
87
  self.system_message = self.conv_template.system_message
88
 
89
+ # Required by transformers v5: populates `all_tied_weights_keys`,
90
+ # tp/ep/pp plans, `_keep_in_fp32_modules`, and runs final weight init.
91
+ self.post_init()
92
+
93
  def forward(
94
  self,
95
  pixel_values: torch.FloatTensor,