Skip to content

[CuTe, FA4] Preserve first-tile flag during scheduler reconstruction - #2705

Merged
drisspg merged 5 commits into
Dao-AILab:mainfrom
dongxiao92:agent/preserve-cute-scheduler-state
Aug 6, 2026
Merged

[CuTe, FA4] Preserve first-tile flag during scheduler reconstruction#2705
drisspg merged 5 commits into
Dao-AILab:mainfrom
dongxiao92:agent/preserve-cute-scheduler-state

Conversation

@dongxiao92

@dongxiao92 dongxiao92 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve the Python-only _is_first_block flag when CuTe reconstructs FlashAttention single-tile schedulers from their MLIR values.

Root cause

These schedulers omit _is_first_block from their MLIR representation, but their constructors initialize it to True.

After advance_to_next_work() marks the first tile consumed, reconstruction therefore resets the omitted flag and makes the first tile valid again. The kernel can repeat that tile and deadlock its producer/consumer pipeline.

Change

Copy _is_first_block from the original object after reconstructing:

  • SingleTileScheduler
  • SingleTileVarlenScheduler
  • Sm100FmhaStaticTileScheduler

Validation

Main branch and cutlass-4.7.0 could pass with this change

@dongxiao92 dongxiao92 changed the title Preserve scheduler state during CuTe reconstruction Preserve and isolate scheduler state during CuTe reconstruction Jul 13, 2026
@dongxiao92 dongxiao92 changed the title Preserve and isolate scheduler state during CuTe reconstruction [Cute,Sm100] Fix scheduler reconstruction across staged warp roles Jul 13, 2026
@dongxiao92
dongxiao92 force-pushed the agent/preserve-cute-scheduler-state branch from 37e2062 to b509a9e Compare July 14, 2026 02:59
@dongxiao92 dongxiao92 changed the title [Cute,Sm100] Fix scheduler reconstruction across staged warp roles [CuTe, FA4] Preserve first-tile flag during scheduler reconstruction Jul 14, 2026
@dongxiao92

Copy link
Copy Markdown
Contributor Author

This changes should not be merged before cutlass-dsl 4.7 release. I will update the version once the dsl package is public

dongxiao92 added a commit to dongxiao92/flash-attention that referenced this pull request Jul 21, 2026
@dongxiao92

dongxiao92 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@tridao 4.7.0 is live. I have also updated the version. Could you help to review? Thanks

Comment thread flash_attn/cute/tile_scheduler.py Outdated
values = values[n_items:]
return SingleTileScheduler(*(tuple(obj_list)), loc=self._loc)
scheduler = SingleTileScheduler(*(tuple(obj_list)), loc=self._loc)
# Preserve the Python-only first-tile flag across CuTe reconstruction.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it safe to say this was a bug in older versions? regardless of 4.7 and this just happend to work; since I imagine we will need to sync the quack upgrade can we just have this change in this or a separate PR and the 4.7 bump isolated?

@dongxiao92 dongxiao92 Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it safe to say this was a bug in older versions? regardless of 4.7 and this just happend to work

Yes. It happened to work and got exposed with some DSL frontend changes in 4.7.

can we just have this change in this or a separate PR and the 4.7 bump isolated?

Sounds good to me. I can cancel the version update. Should I add any comments to the code changes then?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeh I think 1 small commetn e.g. # Note python-only attributes; mlir drops the attributes that have no mlir equivalent and are only valid on the python object, and then for the later call sties you just do see # Note python-only attributes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Please help to review again

@drisspg
drisspg merged commit 7a08d7a into Dao-AILab:main Aug 6, 2026
StevenWang-CY pushed a commit to StevenWang-CY/flash-attention that referenced this pull request Aug 28, 2026
…ao-AILab#2705)

* [CuTe, FA4] Preserve first-tile flag during scheduler reconstruction

* Pin nvidia-cutlass-dsl to 4.7.0

* Keep scheduler fix separate from DSL upgrade

(cherry picked from commit 7a08d7a)
Signed-off-by: StevenWang-CY <stevenwang0805@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants