czczup commited on
Commit
d5df3a1
1 Parent(s): ee27093

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
@@ -43,7 +43,7 @@ class InternVLChatModel(PreTrainedModel):
43
  def __init__(self, config: InternVLChatConfig, vision_model=None, language_model=None, use_flash_attn=True):
44
  super().__init__(config)
45
 
46
- assert version_cmp(transformers.__version__, '4.36.2', 'ge')
47
  image_size = config.force_image_size or config.vision_config.image_size
48
  patch_size = config.vision_config.patch_size
49
  self.patch_size = patch_size
@@ -112,7 +112,7 @@ class InternVLChatModel(PreTrainedModel):
112
  B, N, C = input_embeds.shape
113
  input_embeds = input_embeds.reshape(B * N, C)
114
 
115
- if torch.distributed.get_rank() == 0:
116
  print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
117
 
118
  input_ids = input_ids.reshape(B * N)
 
43
  def __init__(self, config: InternVLChatConfig, vision_model=None, language_model=None, use_flash_attn=True):
44
  super().__init__(config)
45
 
46
+ assert version_cmp(transformers.__version__, '4.37.0', 'ge')
47
  image_size = config.force_image_size or config.vision_config.image_size
48
  patch_size = config.vision_config.patch_size
49
  self.patch_size = patch_size
 
112
  B, N, C = input_embeds.shape
113
  input_embeds = input_embeds.reshape(B * N, C)
114
 
115
+ if torch.distributed.is_initialized() and torch.distributed.get_rank() == 0:
116
  print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
117
 
118
  input_ids = input_ids.reshape(B * N)