Skip to content

[TRTLLM-12982][feat] improve attention backend selection#14635

Merged
brb-nv merged 1 commit into
NVIDIA:mainfrom
ixlmar:feat/attention-backend-validation
May 28, 2026
Merged

[TRTLLM-12982][feat] improve attention backend selection#14635
brb-nv merged 1 commit into
NVIDIA:mainfrom
ixlmar:feat/attention-backend-validation

Conversation

@ixlmar
Copy link
Copy Markdown
Collaborator

@ixlmar ixlmar commented May 27, 2026

Description

Currently, attention backend selection is case-sensitive and features a silent fallback to the "TRTLLM" backend. With this change, passing e.g. attn_backend="flashinfer" selects the correct backend and invalid option values result in a warning.

Test Coverage

n/a

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.

Summary by CodeRabbit

  • Bug Fixes
    • Resolved backend selection issues by implementing case-insensitive backend name matching, preventing unexpected fallback behavior when backend names use different case formats.
    • Added warning notifications when falling back to the default attention backend, providing better visibility and feedback regarding backend selection outcomes.

Review Change Stack

@ixlmar ixlmar requested a review from a team as a code owner May 27, 2026 14:36
@ixlmar ixlmar requested a review from brb-nv May 27, 2026 14:36
@ixlmar ixlmar force-pushed the feat/attention-backend-validation branch from f333ab4 to 9de5296 Compare May 27, 2026 14:37
@ixlmar
Copy link
Copy Markdown
Collaborator Author

ixlmar commented May 27, 2026

/bot run

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3ed4979e-4295-46c0-9043-26ee28c564ff

📥 Commits

Reviewing files that changed from the base of the PR and between 09f5958 and f333ab4.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/attention_backend/utils.py

📝 Walkthrough

Walkthrough

tensorrt_llm/_torch/attention_backend/utils.py imports the project logger and normalizes backend_name to uppercase inside get_attention_backend, ensuring backend-selection comparisons are case-insensitive. When no supported backend matches, the function emits a warning before falling back to the TRTLLM attention backend.

Changes

Attention backend selection

Layer / File(s) Summary
Backend name normalization and fallback logging
tensorrt_llm/_torch/attention_backend/utils.py
Import logger, normalize backend_name to uppercase before string comparisons in get_attention_backend, and emit a warning when falling back to the TRTLLM attention backend.

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: making attention backend selection more robust by improving it to be case-insensitive and adding validation warnings.
Description check ✅ Passed The description covers the main issue (case-sensitive backend selection and silent fallbacks) and the solution (case-insensitive selection and warning on invalid values), following the required template structure.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50559 [ run ] triggered by Bot. Commit: 9de5296 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50559 [ run ] completed with state FAILURE. Commit: 9de5296
/LLM/main/L0_MergeRequest_PR pipeline #40058 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

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
@ixlmar ixlmar force-pushed the feat/attention-backend-validation branch from 9de5296 to ea5245a Compare May 28, 2026 06:34
@ixlmar
Copy link
Copy Markdown
Collaborator Author

ixlmar commented May 28, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50710 [ run ] triggered by Bot. Commit: ea5245a Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50710 [ run ] completed with state FAILURE. Commit: ea5245a
/LLM/main/L0_MergeRequest_PR pipeline #40194 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

@ixlmar
Copy link
Copy Markdown
Collaborator Author

ixlmar commented May 28, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50754 [ run ] triggered by Bot. Commit: ea5245a Link to invocation

@ixlmar
Copy link
Copy Markdown
Collaborator Author

ixlmar commented May 28, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50805 [ run ] triggered by Bot. Commit: ea5245a Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50754 [ run ] completed with state ABORTED. Commit: ea5245a

Link to invocation

Copy link
Copy Markdown
Collaborator

@brb-nv brb-nv left a comment

Choose a reason for hiding this comment

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

LGTM.

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50805 [ run ] completed with state SUCCESS. Commit: ea5245a
/LLM/main/L0_MergeRequest_PR pipeline #40277 completed with status: 'SUCCESS'

CI Report

Link to invocation

@brb-nv brb-nv merged commit f6ba936 into NVIDIA:main May 28, 2026
7 checks passed
@ixlmar ixlmar deleted the feat/attention-backend-validation branch May 29, 2026 07:36
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.

3 participants