Skip to content

fix #45588: guard s_aux against None in flash_attention_forward#45590

Closed
ghost wants to merge 1 commit intomainfrom
unknown repository
Closed

fix #45588: guard s_aux against None in flash_attention_forward#45590
ghost wants to merge 1 commit intomainfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Apr 23, 2026

Fix for #45588

Bug

flash_attention_forward unconditionally calls s_aux.to(query.dtype), but s_aux defaults to None and sink-less models (e.g. Gemma 4) never pass s_aux, causing:

AttributeError: 'NoneType' object has no attribute 'to'

Fix

Add a guard to only convert s_aux when it is not None:

# Before
s_aux=s_aux.to(query.dtype)

# After
s_aux=s_aux.to(query.dtype) if s_aux is not None else None

This pattern was already used in flash_paged.py (see PR #40434).

Testing

  • Python syntax check passed
  • Code follows existing pattern in codebase

Notes

  • Huggingface transformers v5.6.0
  • Affects sink-less models using flash_attention_2

Automated high-quality fix

Fixes #45588 - AttributeError when s_aux=None for sink-less models

Bug: flash_attention_forward unconditionally calls s_aux.to(query.dtype),
but s_aux defaults to None and sink-less models (e.g. Gemma 4) never pass
s_aux, causing AttributeError: 'NoneType' object has no attribute 'to'

Fix: Add guard to only convert s_aux when it is not None.
Similar pattern was already used in flash_paged.py (PR #40434).

Test: python syntax check passed
@github-actions
Copy link
Copy Markdown
Contributor

This PR was flagged by our automated quality checks. If you're a genuine
contributor, please reply here and a maintainer will review your PR.

Common reasons for flagging:

  • New GitHub account
  • Unusually high number of repository forks in a 24-hour window

We appreciate your contribution and apologize if this is a false positive!

@ghost ghost closed this by deleting the head repository Apr 23, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants