Skip to content

Use single mma warp group for short q_len in FA to optimize decoding performance#18985

Merged
Fridge003 merged 4 commits intosgl-project:mainfrom
Qiaolin-Yu:fa
Feb 23, 2026
Merged

Use single mma warp group for short q_len in FA to optimize decoding performance#18985
Fridge003 merged 4 commits intosgl-project:mainfrom
Qiaolin-Yu:fa

Conversation

@Qiaolin-Yu
Copy link
Collaborator

@Qiaolin-Yu Qiaolin-Yu commented Feb 18, 2026

sgl-project/sgl-flash-attn#34

accuracy:

[{'eval_name': 'gpqa', 'model_name': 'dummy-medium_temp1.0_20260218_210226', 'metric': 0.7051767676767676}]

Benchmarking

input len 32000, output len 2000

bs1:

  • before: 264.20
  • after: 273.64

bs16:

  • before: 2087.19
  • after: 2421.24

bs32:

  • before: 2951.04
  • after: 3486.82

bs64

  • before: 3801.22
  • after: 4907.68

profiling

bs 64 before

image

profiling after (also enables pdl with #18756)

image

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Qiaolin-Yu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on optimizing Flash Attention for short query lengths by updating the sgl-attn submodule and configuring the build system to leverage advanced GPU features on SM90 architectures. These changes aim to improve performance and throughput, as evidenced by the provided benchmarking and profiling results.

Highlights

  • Flash Attention Submodule Update: The sgl-attn submodule has been updated to a newer commit (224a674ddc489f4dee3510cfa4678e662524e099), likely incorporating the latest Flash Attention optimizations.
  • CUTLASS Build Configuration: New CMake flags (CUTLASS_ENABLE_GDC_FOR_SM90 and CUTE_SM90_EXTENDED_MMA_SHAPES_ENABLED) were added to enable specific CUTLASS features for SM90 architectures, supporting PDL and WGMMA shapes.
  • Flash Attention 3 Source File Globbing: The glob patterns for Flash Attention 3 (FA3) source files (BF16, FP16, FP8) were refined to use individual hdim[0-9]* files instead of hdimall, specifically to avoid ptxas crashes for FP16.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • sgl-kernel/CMakeLists.txt
    • Updated the GIT_TAG for the repo-flash-attention submodule to a newer commit.
    • Added CUTLASS_ENABLE_GDC_FOR_SM90 and CUTE_SM90_EXTENDED_MMA_SHAPES_ENABLED flags to the CUDA compile options when SGL_KERNEL_ENABLE_FA3 is enabled.
    • Modified the file(GLOB) patterns for FA3_BF16_GEN_SRCS, FA3_FP16_GEN_SRCS, and FA3_FP8_GEN_SRCS to match hdim[0-9]* instead of hdimall files.
Activity
  • The pull request is currently marked as "Do not merge" and is awaiting the sgl-flash-attention dependency.
  • Accuracy metrics for 'gpqa' are provided, showing a score of 0.7051767676767676.
  • Benchmarking results for batch sizes 1, 16, 32, and 64 are included, indicating performance improvements across various configurations.
  • Profiling images are attached, comparing the performance before and after the changes, with the 'after' profiling also showing PDL enabled.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the flash-attention dependency and related build configurations to enable using a single MMA for short query lengths, which shows significant performance improvements in the provided benchmarks. The changes include updating a git submodule, adding new compiler flags for SM90, and modifying file globbing patterns in CMake. My review confirms the changes are logical, and I've provided suggestions to make the globbing patterns more robust to avoid potential issues with incorrect file matching.


file(GLOB FA3_BF16_GEN_SRCS
"${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdimall_bf16*_sm90.cu")
"${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdim[0-9]*_bf16*_sm90.cu")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The glob pattern [0-9]* can match an empty string, which might lead to unintended files being included if, for example, a file named flash_fwd_hdim_bf16_sm90.cu exists. To ensure that you only match files with at least one digit in the head dimension, it's safer to use [0-9][0-9]*.

        "${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdim[0-9][0-9]*_bf16*_sm90.cu")

# FP16 source files - use individual hdim files instead of hdimall to avoid ptxas crash
file(GLOB FA3_FP16_GEN_SRCS
"${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdimall_fp16*_sm90.cu")
"${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdim[0-9]*_fp16*_sm90.cu")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and to prevent accidentally matching files without a head dimension, it's better to use [0-9][0-9]* instead of [0-9]*. This ensures at least one digit is present.

        "${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdim[0-9][0-9]*_fp16*_sm90.cu")

# FP8 source files
file(GLOB FA3_FP8_GEN_SRCS
"${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdimall_e4m3*_sm90.cu")
"${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdim[0-9]*_e4m3*_sm90.cu")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and to prevent accidentally matching files without a head dimension, it's better to use [0-9][0-9]* instead of [0-9]*. This ensures at least one digit is present.

        "${repo-flash-attention_SOURCE_DIR}/hopper/instantiations/flash_fwd_hdim[0-9][0-9]*_e4m3*_sm90.cu")

@Qiaolin-Yu Qiaolin-Yu changed the title [Do not merge] Use single mma for short q_len in FA Use single mma for short q_len in FA Feb 20, 2026
@Qiaolin-Yu
Copy link
Collaborator Author

/tag-and-rerun-ci

@Qiaolin-Yu Qiaolin-Yu changed the title Use single mma for short q_len in FA Use single mma warp group for short q_len in FA to optimize decoding performance Feb 21, 2026
@Fridge003
Copy link
Collaborator

/rerun-stage stage-c-test-8-gpu-h200

@github-actions
Copy link
Contributor

✅ Triggered stage-c-test-8-gpu-h200 to run independently (skipping dependencies).

@github-actions
Copy link
Contributor

🔗 View workflow run

@Fridge003
Copy link
Collaborator

/rerun-stage stage-c-test-4-gpu-b200

@github-actions
Copy link
Contributor

✅ Triggered stage-c-test-4-gpu-b200 to run independently (skipping dependencies).

@github-actions
Copy link
Contributor

🔗 View workflow run

@Fridge003 Fridge003 merged commit d80c884 into sgl-project:main Feb 23, 2026
231 of 254 checks passed
@Qiaolin-Yu Qiaolin-Yu deleted the fa branch February 23, 2026 22:42
xiaobaicxy added a commit to xiaobaicxy/sglang that referenced this pull request Feb 24, 2026
…o xverse_moe

* 'xverse_moe' of https://github.com/xiaobaicxy/sglang: (275 commits)
  fix: add missing blank line after docstring in serving_transcription.py (sgl-project#19206)
  Whisper model support & `/v1/audio/transcriptions` endpoint & benchmark (sgl-project#16983)
  fix: patch docker image fixes (sgl-project#19100)
  [PD-Disagg] Unify prefill info data transition flow, all with `PrefillServerInfo` (sgl-project#19195)
  [CI] Tiny enhance the dp attention load blance benchmark (sgl-project#19194)
  add new ci user (sgl-project#19133)
  [CI] fix the teardown output of disaggregation test (sgl-project#19193)
  [PD-Disagg] Support query dp rank from bootstrap server. (sgl-project#19168)
  [Kernel Slimming] Migrate AWQ marlin repack kernel to JIT (sgl-project#18949)
  [Diffusion] Match rotary_embedding module name style (sgl-project#19179)
  [Refactor] Split rotary_embedding.py into a modular package (sgl-project#19144)
  [NPU] bump sgl-kernel-npu to 2026.02.01.post2 (sgl-project#19178)
  Use single mma warp group for short q_len in FA to optimize decoding performance (sgl-project#18985)
  Reorganize topk logic to clean up code and expose logical experts (sgl-project#16945)
  [ROCm] Use unreg path for custom all-reduce during CUDA graph capture (sgl-project#19162)
  [diffusion] feat: detect Flux2 custom VAE path from component_paths (sgl-project#19170)
  [AMD] ENV flags tuning and cleanup (sgl-project#19176)
  Fix bench_one_batch_server by moving the print statements (sgl-project#19175)
  Update rocm7.2 Dockerfile to install amdsmi for QuickReduce Initialization (sgl-project#19091)
  Revert "Refactor graph input buffers (sgl-project#18991)" (sgl-project#19173)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants