Add patch to fix when attention mask is None in task_heads.py
Browse files153 unmodified lines154155156157158159153 unmodified lines- loss: Cross-entropy loss if labels provided, else None- hidden_states: Final layer hidden states [batch_size, seq_len, hidden_size]"""# Run the base decoder model# This applies all the transformer layers with causal attention153 unmodified lines154155156157158159160161162163164165166167168169170171172173153 unmodified lines- loss: Cross-entropy loss if labels provided, else None- hidden_states: Final layer hidden states [batch_size, seq_len, hidden_size]"""# Adding a patch for when attention_mask is None# ---------------------------# >>> PATCH: ensure a mask if none is provided# ---------------------------if attention_mask is None and input_ids is not None:# Create an all-ones mask (no padding) so SDPA mask prep won’t crash# dtype long/bool are both accepted by HF mask utils; long is common.attention_mask = torch.ones((input_ids.size(0), input_ids.size(1)),dtype=torch.long,device=input_ids.device,)# ---------------------------# Run the base decoder model# This applies all the transformer layers with causal attention
task_heads.py+14