Skip to content

flash-attn2: fix forward epilogue reduction for sycl-tla 0.9.2 - #1065

Merged
danieldk merged 5 commits into
huggingface:mainfrom
jiqing-feng:fa2-cri-sycl-tla-092
Aug 25, 2026
Merged

danieldk merged 5 commits into
huggingface:mainfrom
jiqing-feng:fa2-cri-sycl-tla-092

Conversation

@jiqing-feng

@jiqing-feng jiqing-feng commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Depends on the build-side changes in
huggingface/kernels#734.

Only a build fix: one reduction in the forward epilogue needed explicit tensor
access to compile against sycl-tla 0.9.2.

Validation

Built (torch213-cxx11-xpu20260-x86_64-linux) and checked numerics on BMG
hardware and the CRI TBX simulator. Each case runs only the kernel on XPU; data
generation, the fp32 reference and error statistics stay on CPU.

  • flash-attn2 — 8/8 pass (fix / varlen × fp16 / bf16 × causal / non-causal), max
    abs error 5.4e-04 (fp16) / 4.0e-03 (bf16).

The row-max reduction passed ReduceFragARow directly to cute::transform,
which no longer resolves against sycl-tla 0.9.2. Access the underlying
tensor explicitly and write through the Base subobject.

No functional change.
@github-actions github-actions Bot added the chore Version bumps, releases, misc maintenance label Aug 6, 2026
@jiqing-feng
jiqing-feng marked this pull request as ready for review August 6, 2026 07:07
@jiqing-feng

Copy link
Copy Markdown
Contributor Author

Hi @danieldk . This PR can be reviewed now. Thanks!

danieldk
danieldk previously approved these changes Aug 25, 2026
@danieldk

Copy link
Copy Markdown
Member

/kernel-bot build flash-attn2

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot build flash-attn2
Mode: build only
Target branch: pr-1065
PR head SHA: 26b8f42dffdcb25a1a988007fa9bb8f8eb66dc02
Workflows: build.yaml, build-mac.yaml, build-windows.yaml

Dispatched (1):

sycl-tla 0.9.2 changed cute::reduce() to return a SubgroupTensor, so the
epilogue reduction had to reach through to the underlying cute::Tensor.
That form only compiles against 0.9.2: on 0.8 and 0.9.1 cute::reduce()
still returns a plain cute::Tensor, which has no nested Base type, and
the XPU build fails with "no type named 'Base'".

Detect the subgroup wrapper instead of assuming it. as_plain_tensor()
casts to the Base tensor when the type has one and is the identity
otherwise, so the same source builds against every sycl-tla the build
matrix uses.
@danieldk

Copy link
Copy Markdown
Member

/kernel-bot build flash-attn2

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot build flash-attn2
Mode: build only
Target branch: pr-1065
PR head SHA: d09473ff86e90cf23d4ddff6a16b07aefdf49874
Workflows: build.yaml, build-mac.yaml, build-windows.yaml

Dispatched (1):

@danieldk
danieldk merged commit 48628c8 into huggingface:main Aug 25, 2026
1 check passed
@danieldk

Copy link
Copy Markdown
Member

/kernel-bot merge-and-upload flash-attn2

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot merge-and-upload flash-attn2
Mode: merge, build and upload
Target branch: ``
PR head SHA: d09473ff86e90cf23d4ddff6a16b07aefdf49874
Workflows: `build.yaml, build-mac.yaml, build-windows.yaml`

Merge result: PR is already merged. Continuing with build/upload.

Dispatched (1):

Hub uploads:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Version bumps, releases, misc maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants