update modeling_internvl_chat.py to call self.post_init() at the end of __init__ (line 88).
Browse filesCurrently, InternVLChatModel does not call self.post_init() during initialization, leaving model._tp_plan as None.
When using AutoModelForCausalLM.from_pretrained, this can lead to a TypeError: 'NoneType' object is not iterable, because from_pretrained may invoke caching_allocator_warmup(), which expects model._tp_plan to be properly defined.
For more details, please see this PR: https://github.com/huggingface/transformers/pull/37708.
modeling_internvl_chat.py
CHANGED
|
@@ -85,7 +85,8 @@ class InternVLChatModel(PreTrainedModel):
|
|
| 85 |
self.img_context_token_id = None
|
| 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,
|
|
|
|
| 85 |
self.img_context_token_id = None
|
| 86 |
self.conv_template = get_conv_template(self.template)
|
| 87 |
self.system_message = self.conv_template.system_message
|
| 88 |
+
# Initialize weights and apply final processing
|
| 89 |
+
self.post_init()
|
| 90 |
def forward(
|
| 91 |
self,
|
| 92 |
pixel_values: torch.FloatTensor,
|