Repository: huggingface/transformers
Pull request: Remove unnecessary CUDA sync in qwen2_5_vl

# What does this PR do?
Remove a sync point in qwen2.5 vl training. See its overhead collected in my SFT using py-spy (other lines are omitted):
```
 %Own   %Total  OwnTime  TotalTime  Function (filename:line)
 27.00%  27.00%   16.44s    16.44s   forward (transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py:248)
```
 

Changed files:
filename: src/transformers/models/glm4v/modeling_glm4v.py
patch: @@ -325,7 +325,7 @@ def forward(
 
         if self.config._attn_implementation == "flash_attention_2":
             # Flash Attention 2: Use cu_seqlens for variable length attention
-            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
+            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
             attn_output, _ = attention_interface(
                 self,
                 query_states,

filename: src/transformers/models/qwen2_5_omni/modeling_qwen2_5_omni.py
patch: @@ -592,7 +592,7 @@ def forward(
         query_states = query_states.transpose(0, 1).unsqueeze(0)
         key_states = key_states.transpose(0, 1).unsqueeze(0)
         value_states = value_states.transpose(0, 1).unsqueeze(0)
-        max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
+        max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
 
         attention_interface: Callable = eager_attention_forward
         if self.config._attn_implementation != "eager":
@@ -927,7 +927,7 @@ def forward(
 
         if self.config._attn_implementation == "flash_attention_2":
             # Flash Attention 2: Use cu_seqlens for variable length attention
-            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
+            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
             attn_output, _ = attention_interface(
                 self,
                 query_states,

filename: src/transformers/models/qwen2_5_omni/modular_qwen2_5_omni.py
patch: @@ -1619,7 +1619,7 @@ def forward(
         query_states = query_states.transpose(0, 1).unsqueeze(0)
         key_states = key_states.transpose(0, 1).unsqueeze(0)
         value_states = value_states.transpose(0, 1).unsqueeze(0)
-        max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
+        max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
 
         attention_interface: Callable = eager_attention_forward
         if self.config._attn_implementation != "eager":
@@ -1928,7 +1928,7 @@ def forward(
 
         if self.config._attn_implementation == "flash_attention_2":
             # Flash Attention 2: Use cu_seqlens for variable length attention
-            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
+            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
             attn_output, _ = attention_interface(
                 self,
                 query_states,

filename: src/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py
patch: @@ -245,7 +245,7 @@ def forward(
 
         if self.config._attn_implementation == "flash_attention_2":
             # Flash Attention 2: Use cu_seqlens for variable length attention
-            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
+            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
             attn_output, _ = attention_interface(
                 self,
                 query_states,

filename: src/transformers/models/qwen2_vl/modeling_qwen2_vl.py
patch: @@ -363,7 +363,7 @@ def forward(
 
         if self.config._attn_implementation == "flash_attention_2":
             # Flash Attention 2: Use cu_seqlens for variable length attention
-            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max().item()
+            max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
             attn_output, _ = attention_interface(
                 self,
                 query_states,