Added softmax_scale in attentions#2828
Open
Sirorezka wants to merge 9 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 paths; wrong scaling or kernel routing would silently change training numerics across models.
Overview
Adds configurable attention scaling (
AttentionConfig.scaling/softmax_scale) and threads it through flash varlen, padded flash, SDPA (scale=), ring FA3/FA4, and Ulysses so non-default scales (e.g. upcoming DeepSeek V3) stay consistent across kernels and CP patches.Refactors flash/SDPA into
FlashAttentionCore/SDPAAttentionCore(kernel +_attention_core) withFlashAttention/SDPAAttentionowning Q/K/V projections—same hook point for ring/Ulysses_compute_attentionoverrides on model-specific classes.Behavior change: when
cu_seqlensis absent, flash now uses standardflash_attn_funcon[bs, sl, nh, dim](batch > 1 without CP); varlen remainsbs == 1only. Sliding window is driven viawindow_size_lefton config/core.Adds CUDA unit tests comparing FA2/3/4, ring varlen, Ulysses varlen, and sliding-window cores against SDPA (default and custom scale).
Reviewed by Cursor Bugbot for commit c15bc1d. Bugbot is set up for automated code reviews on this repo. Configure here.