czczup commited on
Commit
53ca0a8
1 Parent(s): 3a8e91d

Apply Github PR #127 to all HF models

Browse files
Files changed (1) hide show
  1. modeling_internvl_chat.py +2 -2
modeling_internvl_chat.py CHANGED
@@ -40,7 +40,7 @@ class InternVLChatModel(PreTrainedModel):
40
  def __init__(self, config: InternVLChatConfig, vision_model=None, language_model=None, use_flash_attn=True):
41
  super().__init__(config)
42
 
43
- assert version_cmp(transformers.__version__, '4.36.2', 'ge')
44
  image_size = config.force_image_size or config.vision_config.image_size
45
  patch_size = config.vision_config.patch_size
46
  self.patch_size = patch_size
@@ -107,7 +107,7 @@ class InternVLChatModel(PreTrainedModel):
107
  B, N, C = input_embeds.shape
108
  input_embeds = input_embeds.reshape(B * N, C)
109
 
110
- if torch.distributed.get_rank() == 0:
111
  print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
112
 
113
  input_ids = input_ids.reshape(B * N)
 
40
  def __init__(self, config: InternVLChatConfig, vision_model=None, language_model=None, use_flash_attn=True):
41
  super().__init__(config)
42
 
43
+ assert version_cmp(transformers.__version__, '4.37.0', 'ge')
44
  image_size = config.force_image_size or config.vision_config.image_size
45
  patch_size = config.vision_config.patch_size
46
  self.patch_size = patch_size
 
107
  B, N, C = input_embeds.shape
108
  input_embeds = input_embeds.reshape(B * N, C)
109
 
110
+ if torch.distributed.is_initialized() and torch.distributed.get_rank() == 0:
111
  print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
112
 
113
  input_ids = input_ids.reshape(B * N)