Added softmax_scale in attentions#2828
Open
Sirorezka wants to merge 7 commits into
Open
Conversation
… attention with Q,K,V layers. Added tests for attentions.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3429290. Configure here.
Author
|
I appreciate you're very busy, but I would be exceedingly grateful for your feedback on this pull request whenever you get a chance. Thank you! @samsja @mikasenghaas @S1ro1. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This fix is required to later merge DeepSeek_V3 (#2681)
Note
High Risk
Touches the core transformer attention and distributed ring/Ulysses kernels; incorrect scaling or path selection would silently change model numerics during training.
Overview
Extends attention so custom
softmax_scale(viaAttentionConfig.scaling) flows through Flash Attention (FA2/3/4), SDPA, ring, and Ulysses varlen paths instead of always usinghead_dim**-0.5.Refactors
FlashAttention/SDPAAttentioninto core modules (kernel only) plus wrapper modules that own Q/K/V projections, so ring/Ulysses can keep patching_compute_attentionwhile shared logic lives in one place.Flash path behavior: when
cu_seqlensis omitted, attention uses the denseflash_attn_funcpath for batched inputs (batch > 1); varlen still requiresbatch == 1. Addswindow_size_lefton config for sliding-window flash kernels.Adds CUDA unit tests comparing FA variants, ring, and Ulysses varlen outputs against SDPA (including custom scale and sliding window).
Reviewed by Cursor Bugbot for commit 0b83f36. Bugbot is set up for automated code reviews on this repo. Configure here.