🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

[None][perf] Enable configurable MLA skip correction for TRT-LLM Gen FMHA - #18118

Merged
yunruis merged 1 commit into
NVIDIA:mainfrom
yunruis:user/yunruis/skip-correction
Sep 3, 2026
Merged

yunruis merged 1 commit into
NVIDIA:mainfrom
yunruis:user/yunruis/skip-correction

Conversation

@yunruis

@yunruis yunruis commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR exposes threshold-based skip correction for the TRT-LLM Gen MLA FMHA path through the TRT-LLM runtime and TorchLlmArgs. The optimization is opt-in and disabled by default, so existing inference behavior is unchanged unless users explicitly enable it.

The required TRT-LLM Gen kernel/export changes are already present on main through 6c1ce33e7fbb1730c3d85150e6ac73ebc1b76deb. This PR reuses those assets and contains only the TRT-LLM runtime, configuration, validation, and test integration needed to activate the feature.

Scope relative to main

This branch does not regenerate or modify the TRT-LLM Gen exported artifacts already available on main, including:

  • FMHA cubins and cubin metadata
  • FMHA static libraries
  • trtllmGen_fmha_export generated interfaces
  • generated cuda_ptx.h and kernelMetaInfo.h

The remaining changes under trtllmGenKernels/fmha are runtime glue: they pass the configured threshold into the existing generated kernels, validate it against the selected BMM2 dtype, and apply the correct softmax scale in the separate reduction path.

The PR is a single signed commit on top of the latest main.

User-facing configuration

  • enable_skip_correction: enables the optimization; defaults to False.
  • skip_correction_threshold: controls the base-2 row-max threshold; defaults to 8.0 and accepts values in (0, 32].
  • The selected kernel's BMM2 dtype further limits the runtime threshold to 8 for E4M3, 15 for FP16, and 32 for BF16.
  • Enabling the feature requires attn_backend="TRTLLM".
  • When disabled, TRT-LLM forwards an effective threshold of 0.0, preserving the existing FMHA behavior.

Example configuration:

attn_backend: TRTLLM
enable_skip_correction: true
skip_correction_threshold: 8.0
trtllm-serve /path/to/DeepSeek-V4-Flash \
  --backend pytorch \
  --config skip-correction.yaml

Omit skip_correction_threshold to use the default value of 8.0.

Implementation

  • Propagates the effective threshold through TorchLlmArgs, ModelConfig, MLA construction, FMHA backend selection, the Python/C++ attention operator, and the TRT-LLM Gen FMHA runner.
  • Adds an FMHA capability flag and selects only a backend that supports skip correction; currently this is FallbackFmha.
  • Validates the runtime threshold against the selected kernel's BMM2 dtype.
  • Passes the threshold-derived softmax scale to the separate multi-CTA reduction path.
  • Supports SM100 and SM103. Unsupported architectures disable the optimization with a one-time warning.
  • Adds opt-in DeepSeek-V4-Flash GSM8K L0 coverage on B200 and B300.
  • Updates the LLM-argument golden manifest and API stability reference for the additive configuration fields.

Impact and compatibility

  • API impact: additive and backward compatible.
  • Default runtime behavior: unchanged because skip correction is disabled by default.
  • Performance impact: limited to explicitly enabled MLA workloads on supported Blackwell architectures.
  • Numerical risk: bounded by architecture, FMHA-backend capability, and BMM2 dtype validation.
  • Dependencies: no new runtime dependencies.
  • Rubin support remains out of scope.

Test Coverage

Feature-path tests explicitly enable skip correction; existing tests continue to exercise the disabled/default behavior.

Added coverage

  • tests/unittest/llmapi/test_llm_args.py
    • configuration defaults and overrides
    • invalid threshold rejection
    • TRTLLM attention-backend requirement
    • YAML configuration loading
  • tests/unittest/_torch/attention/test_attention_mla.py
    • supported and unsupported SM behavior
    • non-positive runtime threshold disabling
    • FMHA capability and registry filtering
    • dense MLA correctness with BF16 and FP8 KV cache
  • tests/unittest/_torch/attention/sparse/test_sparse_mla_forward.py
    • sparse MLA correctness with BF16 and FP8 KV cache
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
    • DeepSeek-V4-Flash GSM8K with skip correction explicitly enabled
  • B200 and B300 L0 test-list registration

Validation results

  • Full SM100 build with warnings-as-errors: passed (--parallel 224).
  • Incremental C++ build including unit-test binaries: passed (make -j224).
  • LLM args and API stability: 379 passed.
  • Dense MLA skip-correction tests: 22 passed.
  • Sparse MLA skip-correction tests: 2 passed.
  • FMHA page-index tests: 30 passed.
  • LLM-argument manifest regeneration: no unexpected diff.
  • DeepSeek-V4-Flash GSM8K on B200: 95.262 accuracy versus 95.110 reference.
  • GitHub DCO, PR checks, base freshness, API compatibility, and pre-commit checks: passed.
  • Pre-push confidentiality scan: passed.

CI Failure Analysis

The previous L0_Test-x86_64-Multi-GPU failure was:

accuracy/test_disaggregated_serving.py::TestNemotron3Super120B::test_ctx_dp2_gen_tp4

This case does not use the MLA path changed by this PR, and skip correction is disabled by default. Recent CI history also shows the same accuracy-boundary failure on unrelated PRs, while post-merge runs passed. It is therefore classified as an existing flaky accuracy case rather than a regression from this change.

This PR does not add or modify any waiver for that test.

PR Checklist

  • Reuses the TRT-LLM Gen artifacts already merged to main.
  • Contains one signed feature commit without generated cubin/library churn.
  • New opt-in code paths have unit and E2E coverage.
  • Existing configurations preserve disabled/default behavior.
  • The LLM API change is additive and labeled api-compatible.
  • No new dependencies, ownership changes, or test waivers are introduced.
  • Rubin support is explicitly out of scope.

@yunruis
yunruis requested a review from a team as a code owner August 24, 2026 05:15
@coderabbitai

coderabbitai Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉


Walkthrough

The change adds a zero-default skip-correction threshold to attention configuration and FMHA runner parameters. AttentionOp serializes the value and forwards it to TRTLLM-Gen MLA and context FMHA execution paths.

Changes

Skip-correction threshold propagation

Layer / File(s) Summary
Threshold configuration and serialization
cpp/tensorrt_llm/common/attentionOp.h, cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fused_multihead_attention_common.h
Adds the threshold to AttentionOp and MHARunnerParams, documents its base-2 row-max behavior, and includes it in AttentionOp::data().
Execution-path threshold forwarding
cpp/tensorrt_llm/common/attentionOp.cpp, cpp/tensorrt_llm/kernels/fmhaDispatcher.cpp
Forwards the threshold to TRTLLM-Gen MLA, context FMHA, and TRTLLM-Gen FMHA parameters.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 66e11

The change adds an opt-in skip-correction optimization while preserving existing behavior by default; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: hchings, yuxianq

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

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

@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from fe18020 to 8771366 Compare August 24, 2026 06:03
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@yunruis yunruis changed the title User/yunruis/skip correction [None][perf] Enable configurable MLA skip correction for TRT-LLM Gen FMHA Aug 24, 2026
@yunruis yunruis added the api-compatible Accepted LLM API contract change that is backwards-compatible label Aug 24, 2026
@yunruis

yunruis commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fast

@yunruis

yunruis commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68717 Bot args parsing error: usage: /bot [-h]
{run,kill,skip,submit,reviewers,reuse-pipeline,reuse-review} ...
/bot: error: unrecognized arguments: --disable-fast

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68718 [ run ] triggered by Bot. Commit: 8771366 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68718 [ run ] completed with state SUCCESS. Commit: 8771366
/LLM/main/L0_MergeRequest_PR pipeline #56118 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

@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from 8771366 to 1cc52b2 Compare August 25, 2026 02:52
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from 1cc52b2 to f175030 Compare August 25, 2026 03:21
@yunruis

yunruis commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68983 [ run ] triggered by Bot. Commit: f175030 Link to invocation

Comment thread tensorrt_llm/_torch/attention_backend/trtllm.py Outdated
Comment thread tensorrt_llm/_torch/attention_backend/trtllm.py Outdated
Comment thread tensorrt_llm/llmapi/llm_args.py Outdated
@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from f175030 to 8afe4ad Compare August 25, 2026 05:08
@yunruis
yunruis requested review from a team, hchings, yihwang-nv and yuxianq and removed request for a team August 25, 2026 05:12

@kris1025 kris1025 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved for the cubins update.

Comment thread cpp/tensorrt_llm/thop/attentionOp.cpp Outdated
Comment thread cpp/tensorrt_llm/thop/attentionOp.cpp Outdated
Comment thread tensorrt_llm/_torch/attention_backend/fmha/fallback.py
Comment thread tensorrt_llm/_torch/attention_backend/fmha/fallback.py
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #68983 [ run ] completed with state FAILURE. Commit: f175030
/LLM/main/L0_MergeRequest_PR pipeline #56361 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ 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

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@schetlur-nv schetlur-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving for oss-compliance

@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from b7e3890 to 75677d1 Compare September 1, 2026 07:18
@yunruis

yunruis commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70625 [ run ] triggered by Bot. Commit: 75677d1 Link to invocation

@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from 75677d1 to 9027d28 Compare September 1, 2026 09:54
@yunruis

yunruis commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70667 [ run ] triggered by Bot. Commit: 9027d28 Link to invocation

@yunruis

yunruis commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from 9027d28 to 7492bf9 Compare September 1, 2026 10:02
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70625 [ run ] completed with state ABORTED. Commit: 75677d1

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70668 [ run ] triggered by Bot. Commit: 7492bf9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70667 [ run ] completed with state ABORTED. Commit: 9027d28

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70668 [ run ] completed with state SUCCESS. Commit: 7492bf9
/LLM/main/L0_MergeRequest_PR pipeline #57868 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: yunruis <205571022+yunruis@users.noreply.github.com>
@yunruis
yunruis force-pushed the user/yunruis/skip-correction branch from 7492bf9 to 25004c1 Compare September 2, 2026 02:20
@yunruis

yunruis commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70865 [ run ] triggered by Bot. Commit: 25004c1 Link to invocation

@yunruis
yunruis enabled auto-merge (squash) September 2, 2026 07:39
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #70865 [ run ] completed with state FAILURE. Commit: 25004c1
/LLM/main/L0_MergeRequest_PR pipeline #58039 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

@yunruis

yunruis commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71103 [ run ] triggered by Bot. Commit: 25004c1 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71103 [ run ] completed with state SUCCESS. Commit: 25004c1
/LLM/main/L0_MergeRequest_PR pipeline #58249 completed with status: 'SUCCESS'

CI Report

Link to invocation

@yunruis
yunruis merged commit 9362a56 into NVIDIA:main Sep 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-compatible Accepted LLM API contract change that is backwards-compatible ci: full pre-merge approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants