Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/transformers/integrations/flex_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ def score_mod(score, batch_idx, head_idx, q_idx, kv_idx):
# On CPU we must skip returning LSE due to a runtime issue; elsewhere, follow PyTorch API and return it
return_lse = query.device.type != "cpu"

# Validate that s_aux is not silently ignored
if not return_lse and s_aux is not None:
logger.warning_once("s_aux provided with return_lse=False - forcing return_lse=True to avoid silent failure")
return_lse = True
raise ValueError(
"Attention sinks cannot be run on CPU with flex attention. Please switch to a different device, e.g. CUDA"
)

flex_attention_output = compile_friendly_flex_attention(
query,
Expand Down