Apply Github PR #127 to all HF models
Browse files
modeling_internvl_chat.py
CHANGED
@@ -42,7 +42,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
42 |
def __init__(self, config: InternVLChatConfig, vision_model=None, language_model=None, use_flash_attn=True):
|
43 |
super().__init__(config)
|
44 |
|
45 |
-
assert version_cmp(transformers.__version__, '4.
|
46 |
image_size = config.force_image_size or config.vision_config.image_size
|
47 |
patch_size = config.vision_config.patch_size
|
48 |
self.patch_size = patch_size
|
@@ -111,7 +111,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
111 |
B, N, C = input_embeds.shape
|
112 |
input_embeds = input_embeds.reshape(B * N, C)
|
113 |
|
114 |
-
if torch.distributed.get_rank() == 0:
|
115 |
print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
|
116 |
|
117 |
input_ids = input_ids.reshape(B * N)
|
|
|
42 |
def __init__(self, config: InternVLChatConfig, vision_model=None, language_model=None, use_flash_attn=True):
|
43 |
super().__init__(config)
|
44 |
|
45 |
+
assert version_cmp(transformers.__version__, '4.37.0', 'ge')
|
46 |
image_size = config.force_image_size or config.vision_config.image_size
|
47 |
patch_size = config.vision_config.patch_size
|
48 |
self.patch_size = patch_size
|
|
|
111 |
B, N, C = input_embeds.shape
|
112 |
input_embeds = input_embeds.reshape(B * N, C)
|
113 |
|
114 |
+
if torch.distributed.is_initialized() and torch.distributed.get_rank() == 0:
|
115 |
print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
|
116 |
|
117 |
input_ids = input_ids.reshape(B * N)
|