Skip to content

[TRTLLM-13445][test] Add SageAttention backend-routing and SAGE recip…#15746

Merged
yingguo-trt merged 1 commit into
NVIDIA:mainfrom
yingguo-trt:yiguo/TRTLLM-13445-sageattention-qa
Jul 3, 2026
Merged

[TRTLLM-13445][test] Add SageAttention backend-routing and SAGE recip…#15746
yingguo-trt merged 1 commit into
NVIDIA:mainfrom
yingguo-trt:yiguo/TRTLLM-13445-sageattention-qa

Conversation

@yingguo-trt

@yingguo-trt yingguo-trt commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

…e coverage

Add unit coverage for the SageAttention integration (dev epic TRTLLM-12126):

  • TestSageAttentionBackendRouting: verify TRTLLM+quant_attention_config routes self-attention (FUSE_QKV) to the SAGE path and that cross-attention (SEPARATE_QKV) falls back to VANILLA.
  • Parametrize the quant-config validator test over all five supported SAGE recipes.

Summary by CodeRabbit

  • Tests
    • Expanded coverage for attention backend routing to verify the correct backend is selected for self-attention and cross-attention scenarios.
    • Added broader validation of supported quantization settings with multiple configuration combinations.

Description

Test Coverage

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

@yingguo-trt yingguo-trt requested a review from a team as a code owner June 30, 2026 02:20
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a TestSageAttentionBackendRouting test class with a helper _build_sage_routed_attention to verify that self-attention (FUSE_QKV) routes to TrtllmAttention and cross-attention (SEPARATE_QKV) falls back to VanillaAttention. Also parameterizes test_supported_quant_config_sage over multiple QuantAttentionConfig combinations.

Changes

TRTLLM-SAGE Attention Test Coverage

Layer / File(s) Summary
Backend routing tests and quant config parameterization
tests/unittest/_torch/visual_gen/test_attention_integration.py, tests/unittest/_torch/visual_gen/test_visual_gen_args.py
Imports TrtllmAttention; adds _build_sage_routed_attention and TestSageAttentionBackendRouting asserting FUSE_QKV selects TrtllmAttention and SEPARATE_QKV selects VanillaAttention; refactors test_supported_quant_config_sage into a parameterized test over multiple (qk_dtype, q_block_size, k_block_size, v_block_size) inputs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description does not follow the required template sections and omits a clear Description, Test Coverage, and completed PR Checklist. Add the required Description, Test Coverage, and PR Checklist sections, and briefly explain the issue, solution, and the tests covering the new paths.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific and matches the PR's main change: SageAttention backend-routing and SAGE recipe test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
tests/unittest/_torch/visual_gen/test_visual_gen_args.py (1)

102-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Annotate the new parameterized test signature.

Line 102 adds a new test function without an explicit return type. Please add -> None here as well so the new test keeps the same typing bar as the rest of the repo.

As per coding guidelines, "Always annotate functions with return types (use None if the function does not return anything)."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/visual_gen/test_visual_gen_args.py` at line 102, The
new parameterized test function test_supported_quant_config_sage is missing an
explicit return type annotation; update its signature to include -> None so it
matches the repo’s typing conventions. Apply this change directly on the test
method definition and keep the existing parameters unchanged.

Source: Coding guidelines

tests/unittest/_torch/visual_gen/test_attention_integration.py (1)

296-330: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add return annotations to the new helper and test methods.

Lines 296-330 introduce three new Python functions without explicit return types. Please annotate _build_sage_routed_attention and both test methods so the new test code stays aligned with the repo's typing rules.

Suggested update
-def _build_sage_routed_attention(qkv_mode: QKVMode):
+def _build_sage_routed_attention(
+    qkv_mode: QKVMode,
+) -> tuple[Attention, QuantAttentionConfig]:
     """Build a TRTLLM-SAGE-configured Attention for backend-routing checks."""
@@
-class TestSageAttentionBackendRouting:
-    def test_self_attention_uses_trtllm_sage_backend(self):
+class TestSageAttentionBackendRouting:
+    def test_self_attention_uses_trtllm_sage_backend(self) -> None:
@@
-    def test_cross_attention_with_sage_config_falls_back_to_vanilla(self):
+    def test_cross_attention_with_sage_config_falls_back_to_vanilla(self) -> None:

As per coding guidelines, "Always annotate functions with return types (use None if the function does not return anything)."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/visual_gen/test_attention_integration.py` around lines
296 - 330, The new helper and test methods in TestSageAttentionBackendRouting
are missing explicit return annotations, which violates the repo’s typing rule.
Update _build_sage_routed_attention to declare its returned tuple type, and mark
both test_self_attention_uses_trtllm_sage_backend and
test_cross_attention_with_sage_config_falls_back_to_vanilla as returning None to
keep the test module consistent with the rest of the codebase.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/unittest/_torch/visual_gen/test_attention_integration.py`:
- Around line 296-330: The new helper and test methods in
TestSageAttentionBackendRouting are missing explicit return annotations, which
violates the repo’s typing rule. Update _build_sage_routed_attention to declare
its returned tuple type, and mark both
test_self_attention_uses_trtllm_sage_backend and
test_cross_attention_with_sage_config_falls_back_to_vanilla as returning None to
keep the test module consistent with the rest of the codebase.

In `@tests/unittest/_torch/visual_gen/test_visual_gen_args.py`:
- Line 102: The new parameterized test function test_supported_quant_config_sage
is missing an explicit return type annotation; update its signature to include
-> None so it matches the repo’s typing conventions. Apply this change directly
on the test method definition and keep the existing parameters unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9abf4225-205a-477e-beb5-903639125c54

📥 Commits

Reviewing files that changed from the base of the PR and between a9f5fc7 and 61400f9.

📒 Files selected for processing (2)
  • tests/unittest/_torch/visual_gen/test_attention_integration.py
  • tests/unittest/_torch/visual_gen/test_visual_gen_args.py

@yingguo-trt

Copy link
Copy Markdown
Collaborator Author

/bot run

1 similar comment
@yingguo-trt

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56589 [ run ] triggered by Bot. Commit: 61400f9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56589 [ run ] completed with state SUCCESS. Commit: 61400f9
/LLM/main/L0_MergeRequest_PR pipeline #45417 completed with status: 'SUCCESS'

CI Report

Link to invocation

@yingguo-trt yingguo-trt enabled auto-merge (squash) July 2, 2026 01:41
…e coverage

Add unit coverage for the SageAttention integration (dev epic TRTLLM-12126):
- TestSageAttentionBackendRouting: verify TRTLLM+quant_attention_config routes
  self-attention (FUSE_QKV) to the SAGE path and that cross-attention
  (SEPARATE_QKV) falls back to VANILLA.
- Parametrize the quant-config validator test over all five supported SAGE
  recipes.

Signed-off-by: Ying Guo <244492186+yingguo-trt@users.noreply.github.com>
@yingguo-trt yingguo-trt force-pushed the yiguo/TRTLLM-13445-sageattention-qa branch from 61400f9 to 0888939 Compare July 2, 2026 02:16
@yingguo-trt

Copy link
Copy Markdown
Collaborator Author

/bot run

1 similar comment
@yingguo-trt

Copy link
Copy Markdown
Collaborator Author

/bot run

@yingguo-trt

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57296 [ run ] triggered by Bot. Commit: 0888939 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57296 [ run ] completed with state FAILURE. Commit: 0888939
/LLM/main/L0_MergeRequest_PR pipeline #46056 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@yingguo-trt

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57413 [ run ] triggered by Bot. Commit: 0888939 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57413 [ run ] completed with state SUCCESS. Commit: 0888939
/LLM/main/L0_MergeRequest_PR pipeline #46157 completed with status: 'SUCCESS'

CI Report

Link to invocation

@yingguo-trt yingguo-trt merged commit 0ccc7ec into NVIDIA:main Jul 3, 2026
7 checks passed
BrianLi23 pushed a commit to BrianLi23/TensorRT-LLM that referenced this pull request Jul 9, 2026
NVIDIA#15746)

Signed-off-by: Ying Guo <244492186+yingguo-trt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants