[None][refactor] Centralize FMHA availability and support capability checks - #19008
Conversation
Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. WalkthroughThe FMHA interface now centralizes capability checks and delegates backend-specific availability and request support checks to private hooks. Backends, tests, fixtures, and the developer guide use the updated contract. ChangesFMHA hook contract
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant FMHAManager
participant Fmha
participant BackendHook
FMHAManager->>Fmha: Check availability
Fmha->>Fmha: Validate shared capabilities
Fmha->>BackendHook: Call _is_available()
BackendHook-->>Fmha: Return availability
FMHAManager->>Fmha: Check request support
Fmha->>BackendHook: Call _is_supported()
BackendHook-->>Fmha: Return support result
Merge Risk: ⚪ Minimal · up to FMHA capability validation is centralized behind shared public hooks with backend-specific private implementations. No current merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
|
/bot run --disable-fail-fast |
|
PR_Github #72685 [ run ] triggered by Bot. Commit: |
|
PR_Github #72685 [ run ] completed with state
|
yihwang-nv
left a comment
There was a problem hiding this comment.
Thanks, LGTM!
Do we want to strictly prohibit derived FMHA classes from overriding is_available and is_support? If yes, should we add a test to ensure those methods are absent from each registered FMHA lib in a separate PR?
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
|
/bot run --disable-fail-fast |
|
PR_Github #72746 [ run ] triggered by Bot. Commit: |
|
PR_Github #72746 [ run ] completed with state |
Dev Engineer Review
skip_correctionchecks inFmha.is_available().is_supported()from the_is_supported()implementation hook._is_available()and_is_supported().supports_skip_correctionwith a default ofFalse.QA Engineer Review
Per-File QA Perspective
tensorrt_llm/_torch/attention/ATTENTION_DEVELOPER_GUIDE.md: Documents hook behavior and cache requirements. Verify the guidance matches runtime behavior.tensorrt_llm/_torch/attention/backends/fmha/interface.py: Adds centralized capability gating and support delegation. Verify rejection ordering and argument forwarding.tensorrt_llm/_torch/attention/backends/fmha/cute_dsl_mla.py: Renames FMHA hooks. Verify selection behavior.tensorrt_llm/_torch/attention/backends/fmha/fallback.py: Renames fallback hooks. Verify fallback behavior.tensorrt_llm/_torch/attention/backends/fmha/flashinfer_sparse_mla.py: Removes local skip-correction gating. Verify base-class rejection and remaining MLA checks.tensorrt_llm/_torch/attention/backends/fmha/flashinfer_trtllm_gen.py: Renames hooks and removes local gating. Verify centralized checks and FlashInfer behavior.tensorrt_llm/_torch/attention/backends/fmha/msa_sparse_gqa.py: Changes_is_available()to require attention context. Verify correct context propagation.tensorrt_llm/_torch/attention/backends/fmha/prims_ts.py: Renames FMHA hooks. Verify existing selection constraints.tensorrt_llm/_torch/attention/backends/fmha/triton_custom_mask.py: Renames FMHA hooks. Verify custom-mask selection and support checks.tests/unittest/_torch/attention/fmha_test_utils.py: Updates fixtures and fake hooks. Covers interface compatibility; no integration test-list entry applies.tests/unittest/_torch/attention/test_fmha_interface.py: Covers capability gating, forwarding, defaults, and inheritance; no integration test-list entry applies.tests/unittest/_torch/attention/test_fmha_manager.py: Removes manager capability-construction coverage; no integration test-list entry applies.tests/unittest/_torch/attention/test_prims_ts_fmha.py: Updates skip-correction fixture state; no integration test-list entry applies.Description
FMHA capability checks were repeated in individual implementations, making it easy for a library to miss a newly introduced requirement. Centralize skip-correction gating in
Fmha.is_available()before any implementation-specific probe, and migrate every registered library to the_is_available()hook. Libraries opt in through declarations such assupports_skip_correction = True.Also split
is_supported()into a final base-class entry point and an_is_supported()implementation hook, preserving all request arguments and the phase keyword. This provides the shared entry point for future request capabilities, including the block-sparse check in #18815. The block-sparse gate itself belongs to that integration. Document capability lifetimes, cache-key requirements, and parent-hook delegation.Test Coverage
Before the test-only deletion in
67732df4ca, 165 tests passed on B200 with existing native build artifacts across the following suites:tests/unittest/_torch/attention/test_fmha_interface.pytests/unittest/_torch/attention/test_fmha_registry.pytests/unittest/_torch/attention/test_fmha_manager.pytests/unittest/_torch/attention/test_combined_fmha.pytests/unittest/_torch/attention/test_prims_ts_fmha.pytests/unittest/_torch/attention/test_attention_mla.py::test_attention_mla_skip_correction(BF16 and FP8 KV cache)The first five suites passed 163 cases. The two MLA cases initially failed to locate CUDA JIT headers; both passed after adding the test virtualenv's
piptoPATHso the JIT could resolve the editable installation. No source workaround was needed.The manager construction capability test was subsequently removed, leaving 164 previously validated cases. Runtime tests were not rerun for this test-only deletion. All commit hooks passed for the deletion, including lint/formatting, vendored-source verification, test-list validation, and DCO.
Coverage includes capability rejection before probing, availability result propagation for all registered libraries, request/phase forwarding, inherited defaults, and existing selection/cache/composition behavior.
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-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin 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.