[Feature] USP: Replace SDPA with Flash Attention for memory optimization & Add Online Mode#425
Merged
sleepcoo merged 6 commits intosgl-project:mainfrom Jan 14, 2026
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
11a2e13 to
bf7f659
Compare
Collaborator
|
I tried train seqlen=65536 with ring=8, ulysses=2 and it'll cost 94G. The setting with ring=4, ulysses=2 and it'll also cost 94G. Does it normal? |
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.
waiting for #400 to be merged
Motivation
To accelerate long-context training, this PR integrates Flash Attention into the Unified Sequence Parallelism (USP) framework. By replacing standard PyTorch operations with optimized kernels inside the Ring Attention loop, this implementation significantly improves memory efficiency for Eagle3 draft models.
Additionally, this PR adds support for online mode within the USP framework.
Modifications
LlamaUSPFlashAttention: Added a hybrid sequence parallel attention layer that combines Ulysses, Ring Attention, and Flash Attention (flash_attn_func).Usage
Related Issues
Accuracy Test
compare to sdpa implement bf16 diff less than 2e-2, fp16 diff less than 5e-3


Benchmark & Profiling
todo
TODO
Checklist