Skip to content

[Attention] support softmax lse - #330

Open
Valentine233 wants to merge 6 commits into
mainfrom
liaoxuan/chunk_prefill_softmax_lse
Open

[Attention] support softmax lse#330
Valentine233 wants to merge 6 commits into
mainfrom
liaoxuan/chunk_prefill_softmax_lse

Conversation

@Valentine233

@Valentine233 Valentine233 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Support softmax lse for prefill/decode/chunk_prefill.
Fix speculative decoding issue with topk>1 https://jira.devtools.intel.com/browse/SGLANGT-1430.
The wheel size increases for 1M and the compiling time hardly changes ~20min.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the FlashAttention SYCL forward path for chunk prefill (two-launch dispatcher) so that softmax_lse is returned with the correct non-empty shape even though the value is not stitched/computed on that path, addressing a speculative decoding issue when topk > 1.

Changes:

  • Allocate and return softmax_lse in the chunkprefill path with shape (nheads, total_q) instead of an empty {0} placeholder.
  • Derive total_q and num_heads from q to construct the correct softmax_lse shape.
  • Add TODO notes indicating prefill softmax_lse is currently unsupported.

Comment thread src/sycl/flash_attention.cpp Outdated
Comment thread src/sycl/flash_attention.cpp Outdated
Comment thread src/sycl/flash_attention.cpp Outdated
@Valentine233

Copy link
Copy Markdown
Collaborator Author

Figure out that softmax_lse would indeed affect the calculation.
The previous fixing only makes sure the right shape with empty values.
As the next step, I will implement the complete softmax_lse calculation for prefill and chunk_prefill.

@Valentine233
Valentine233 force-pushed the liaoxuan/chunk_prefill_softmax_lse branch from 88b4d38 to 473d5fe Compare July 30, 2026 06:35
@Valentine233 Valentine233 changed the title [Attention] softmax lse shape for chunk prefill [Attention] support softmax lse Jul 30, 2026
@Valentine233
Valentine233 force-pushed the liaoxuan/chunk_prefill_softmax_lse branch from 473d5fe to 5a1b28a Compare August 4, 2026 05:23
@Valentine233
Valentine233 force-pushed the liaoxuan/chunk_prefill_softmax_lse branch from 5a1b28a to 2384b34 Compare August 6, 2026 07:09
@ckvermaAI

ckvermaAI commented Aug 12, 2026

Copy link
Copy Markdown

repro_softmax_lse.py
@Valentine233 Please check the attached unit test. Currently it fails with this PR, please address the failing test cases.
(These test cases needs to be passed to make ring attention functional in sglang)

@Valentine233

Valentine233 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

repro_softmax_lse.py @Valentine233 Please check the attached unit test. Currently it fails with this PR, please address the failing test cases. (These test cases needs to be passed to make ring attention functional in sglang)

Hi @ckvermaAI, there are several checks in your reproducer. Could you elaborate what the exact failure is, core dump or accuracy issue?

@mingfeima

Copy link
Copy Markdown
Collaborator

need rebase.

@Valentine233

Copy link
Copy Markdown
Collaborator Author

There are some hang and accuracy issues after rebase. The fix is WIP.

@Valentine233
Valentine233 force-pushed the liaoxuan/chunk_prefill_softmax_lse branch from 08c540e to 36f5f87 Compare August 21, 2026 08:51
@Valentine233

Copy link
Copy Markdown
Collaborator Author

Issue fixed.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants