czczup commited on
Commit
859659b
1 Parent(s): d044c87

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