Skip to content

Why do we need proxy fence in FA4 BWD postprocess kernel? #2718

Description

@pchen7e2

There is a cute.arch.fence_view_async_shared(), which translates to fence.proxy.async.shared::cta; PTX, follwing G2S, S2R and R2S copies of the BWD postprocess kernel:

https://github.com/Dao-AILab/flash-attention/blame/77aacb68d194ba9af1010eda5eac3e7c0df8e6f6/flash_attn/cute/flash_bwd_postprocess.py#L453

https://github.com/Dao-AILab/flash-attention/blame/77aacb68d194ba9af1010eda5eac3e7c0df8e6f6/flash_attn/cute/flash_bwd_postprocess.py#L468

https://github.com/Dao-AILab/flash-attention/blame/77aacb68d194ba9af1010eda5eac3e7c0df8e6f6/flash_attn/cute/flash_bwd_postprocess.py#L489

If I understand it correctly, all these copies are using ld or st to access GMEM and SMEM, which should all be in generic proxy, so there's no need for a fence between generic and async proxy.

From ncu it also seems the perf cost is not none:

Image

I'll be glad to put up a PR if we agree they're not needed

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions