Skip to content

[None][fix] Make trtllm-gen FMHA wait for the PDL predecessor before reading sequence lengths - #22089

Merged
Kefeng-Duan merged 2 commits into
NVIDIA:mainfrom
Ethkuil:user/zhixinl/fmha-pdl-wait-fix
Nov 18, 2026
Merged

Kefeng-Duan merged 2 commits into
NVIDIA:mainfrom
Ethkuil:user/zhixinl/fmha-pdl-wait-fix

Conversation

@Ethkuil

@Ethkuil Ethkuil commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Description

When launched with PDL, the trtllm-gen context FMHA kernels read the cumulative sequence lengths before griddepcontrol.wait, so they can see stale lengths written by the preceding kernel. This can hang the persistent context kernel or corrupt its output. It is most likely when the length-writing kernel runs directly before the FMHA, as in the BF16-KV MLA context path.

  • Update the trtllm-gen FMHA artifacts. The kernels now execute griddepcontrol.wait before reading the sequence lengths or any other predecessor output. The update also brings in new FP8-Q / NVFP4-KV grouped kernels for sm100a, sm103a and sm107a.
  • Revert [None][fix] Add a static tile scheduler override for context FMHA #19873 (TRTLLM_GEN_FMHA_CONTEXT_STATIC_TILE_SCHEDULER). It was added as a workaround for this hang but did not fix it. The switch is off by default, so removing it does not change behavior.

Test Coverage

Validated manually:

  • SASS check of every exported cubin: none issues a global or TMA load before its first griddepcontrol.wait. Before this change, the sm107a MLA context kernels read the sequence lengths before the wait.

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.

Dev Engineer Review

  • The change updates 8,798 FMHA cubin archives and generated kernel metadata. The kernels now wait before reading predecessor output.
  • The change adds grouped FP8-Q/NVFP4-KV kernels for sm100a, sm103a, and sm107a.
  • fmhaDispatcher.cpp now uses TileScheduler::Persistent for both support probing and execution.
  • The static scheduler environment override and its envUtils API are removed. The old environment variable no longer changes scheduler selection.
  • kernelMetaInfo.h updates the generated version and exports many new kernel symbols. CudaArchDecl.h pins Sm107a to value 5 to match prebuilt archives.
  • The four regenerated static libraries must remain compatible with the updated metadata and cubins. CI results are not available.

QA Engineer Review

No test changes.

Per-File QA Perspective

  • cpp/tensorrt_llm/common/envUtils.cpp: Verify builds after removing the static scheduler environment helper.
  • cpp/tensorrt_llm/common/envUtils.h: Verify downstream code does not use the removed declaration.
  • cpp/tensorrt_llm/kernels/fmhaDispatcher.cpp: Verify support probing and execution select the persistent scheduler consistently.
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/kernelMetaInfo.h: Verify the generated version and exported symbols match the packaged cubins.
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/trtllmGen_fmha_export/KernelParams.h: Verify the documented packed MLA stride fallback matches caller layouts.
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/trtllmGen_fmha_export/trtllm/gen/CudaArchDecl.h: Verify the pinned Sm107a enum value matches archive metadata and host selection.
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/lib/aarch64-linux-gnu/libTrtLlmGen.a and libTrtLlmGenFmhaLib.a: Verify the regenerated ARM libraries link and load correctly.
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/lib/x86_64-linux-gnu/libTrtLlmGen.a and libTrtLlmGenFmhaLib.a: Verify the regenerated x86-64 libraries link and load correctly.
  • FMHA .cubin.tar.zst archives: Verify every exported cubin waits before its first global or TMA load, including the new grouped FP8-Q/NVFP4-KV variants.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The context FMHA dispatcher now uses the persistent tile scheduler for support checks and execution. The environment helper and declaration for selecting the static scheduler were removed.

Changes

Context FMHA scheduler

Layer / File(s) Summary
Use the persistent tile scheduler
cpp/tensorrt_llm/common/envUtils.h, cpp/tensorrt_llm/common/envUtils.cpp, cpp/tensorrt_llm/kernels/fmhaDispatcher.cpp
The static-scheduler environment helper and declaration were removed. Support checks and execution now use the persistent tile scheduler.

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

Change: Bug fix

Merge Risk: Minimal · previous review 84f5f

The change makes context FMHA always use the persistent tile scheduler and removes the environment option for the static scheduler. No concrete merge-blocking defect was found in the supplied context.

Architecture risk: Low · up to 84f5f

The change affects 1 system.

Changed systems: cpp

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — cpp (service) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in cpp/tensorrt_llm/common/envUtils.cpp: Removed getEnvUseStaticTileSchedulerForTrtllmGenContextFmha, which read TRTLLM_GEN_FMHA_CONTEXT_STATIC_TILE_SCHEDULER and returned whether it was exactly "1".
  • observed — Modified behavior in cpp/tensorrt_llm/common/envUtils.h: Removed the declaration of getEnvUseStaticTileSchedulerForTrtllmGenContextFmha() and its comment describing the static tile scheduler option for trtllm-gen context FMHA.
  • observed — Modified behavior in cpp/tensorrt_llm/kernels/fmhaDispatcher.cpp: Removed the envUtils.h include and contextTileScheduler() helper, which selected Static when the context static-scheduler environment setting was enabled and Persistent otherwise.
  • observed — Modified behavior in cpp/tensorrt_llm/kernels/fmhaDispatcher.cpp: The support-check parameters now always use the persistent tile scheduler instead of consulting contextTileScheduler().
Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: the trtllm-gen FMHA kernels now wait for the PDL predecessor before reading sequence lengths. It follows the required template with the [None][fix] tag. The title does…
Description check Passed The description explains the problem (stale cumulative sequence lengths read before griddepcontrol.wait under PDL) and the solution (updated FMHA artifacts that wait before reading predecessor output,…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Title check

Explanation

The title names the main change: the trtllm-gen FMHA kernels now wait for the PDL predecessor before reading sequence lengths. It follows the required template with the [None][fix] tag. The title does not mention the removal of the static tile scheduler override, but that is a secondary change.

Full details: Description check

Explanation

The description explains the problem (stale cumulative sequence lengths read before griddepcontrol.wait under PDL) and the solution (updated FMHA artifacts that wait before reading predecessor output, plus new FP8-Q/NVFP4-KV grouped kernels). It also covers the revert of #19873 and gives a manual SASS validation under Test Coverage. It does not name any automated test added to the repository, and the Test Coverage section lists only a manual check. The template's checklist is ticked. The description is mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@Ethkuil

Ethkuil commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

/bot run

@yuxianq

yuxianq commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

@PerkzZheng, could you help to review this PR as trt-llm-torch-attention-devs? Thanks~

Assignment explanation
Componentskernels/trtllm-gen (80%); fmha/orchestration (20%)
Tagsphase:prefill (70%); phase:decode (30%); features:quantization (60%); features:paged-kv (40%)
PR effort8 points — Review requires deep reasoning about predecessor synchronization, persistent scheduling, archive compatibility, and added quantized kernel variants. Missing kernel instructions and regression evidence increase validation effort; the thousands of generated artifacts do not independently justify the score.
ImportanceImportant — Unconditional persistent scheduling changes behavior for users of the removed override, and Sm107a = 5 corrects an archive/header compatibility contract. Together with the reported predecessor-ordering fix, these are sensitive attention correctness and performance changes; the synchronization implementation is unavailable.
Affinity (0–1)0.687 component/tag match; 0.515 after PIC preference
Outstanding points at selection42 → 42 (+0)
Points already reserved on this PR8
Effective weight1
Completed review points (preceding 168 hours)31
Combined points after assignment73
Demand-derived target61.00 points (soft share)
Additional fair share before assignment0.00 points
Share explanationWhole PR / qualification or coverage constraint exceeds a soft share; assignment is allowed.
Selection ruleaffinity with 0.3-share guard
Assignment scope (PerkzZheng)all

Affinity and workload are snapshots at selection, not live counters. Existing reservations on this PR are counted once.

@yuxianq
yuxianq removed the request for review from heyuhhh November 11, 2026 07:57
@hanjingtian

Copy link
Copy Markdown
Collaborator

Could you please rebase this branch onto the latest upstream main to include the CI hang fix in #22101 (6edbe383497a)? The current branch still contains the regression that can cause pipelines to hang for an extended period and worsen CI queueing

@mikeiovine mikeiovine 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.

Stamp on behalf of runtime devs, delegating proper review to @NVIDIA/trt-llm-torch-attention-devs

@github-actions

Copy link
Copy Markdown

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.

The FMHA kernels now execute griddepcontrol.wait before reading the
sequence lengths or any other output of the preceding kernel. Before,
under PDL they could read stale lengths, which could hang the persistent
context kernel or corrupt its output.

Signed-off-by: zhixinl <[email protected]>
This reverts commit 8f973fb (NVIDIA#19873). The override was added as a
workaround for a context FMHA hang, but it did not fix the hang; the
previous commit fixes it in the kernels. The override is off by default,
so removing it does not change behavior.

Signed-off-by: Zhixin Lin <[email protected]>
@Ethkuil
Ethkuil force-pushed the user/zhixinl/fmha-pdl-wait-fix branch from 84f5fd9 to ce8b200 Compare November 16, 2026 02:39
@Ethkuil

Ethkuil commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Could you please rebase this branch onto the latest upstream main to include the CI hang fix in #22101 (6edbe383497a)? The current branch still contains the regression that can cause pipelines to hang for an extended period and worsen CI queueing

Rebased onto the latest branch (includes #22101 ). Re-triggering CI.

@Ethkuil

Ethkuil commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85065 [ run ] triggered by Bot. Commit: ce8b200 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@Ethkuil

Ethkuil commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

After including the CI hang fix in #22101, CI didn't hang but it still failed.

CI Agent Failure Analysis says:

  • PR likely to blame?: No — PR [None][fix] Make trtllm-gen FMHA wait for the PDL predecessor before reading sequence lengths #22089 changes trtllm-gen/FMHA generated kernels and metadata, while the hard failure is in an unrelated FLUX.2 visual generation test failing during DiffusionClient IPC startup.
  • Failure category: Test failure — one x86_64 B200 pytest failed; SBSA and other branches were aborted/blocked as downstream fail-fast fallout.
  • Action for PR author: Re-run CI or ask owners of visual generation tests to inspect the DiffusionClient: IPC init failed: Address already in use failure; no evidence points to the FMHA changes in this PR.

@Ethkuil

Ethkuil commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

I have reported the issue to @NVIDIA/trt-llm-torch-visual-gen-devs . This might be an occasional issue — I’ll try rerunning CI first.

/bot run

@Ethkuil

Ethkuil commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85329 [ run ] triggered by Bot. Commit: ce8b200 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85329 [ run ] completed with state SUCCESS. Commit: ce8b200
/LLM/main/L0_MergeRequest_PR pipeline #70640 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

Link to invocation

@Kefeng-Duan
Kefeng-Duan merged commit fd094e7 into NVIDIA:main Nov 18, 2026
8 checks passed
@Ethkuil
Ethkuil deleted the user/zhixinl/fmha-pdl-wait-fix branch November 18, 2026 03:17
@github-actions

Copy link
Copy Markdown

✅ LFS objects already in storage (8802 files) — no sync needed.

These LFS-tracked files are already present in this repository's LFS storage:

  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm100aKernel_QE4m3KvE2m1OBfloat16H128PagedKvCausalP32MultiCtasKvCgaVarSeqQ128Kv128StaticGroupedKeepsAbForGen.cubin.tar.zst
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm100aKernel_QE4m3KvE2m1OBfloat16H128PagedKvCausalP32MultiCtasKvCgaVarSeqQ16Kv128StaticGroupedSwapsAbForGen.cubin.tar.zst
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm100aKernel_QE4m3KvE2m1OBfloat16H128PagedKvCausalP32MultiCtasKvCgaVarSeqQ32Kv128StaticGroupedSwapsAbForGen.cubin.tar.zst
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm100aKernel_QE4m3KvE2m1OBfloat16H128PagedKvCausalP32MultiCtasKvCgaVarSeqQ64Kv128StaticGroupedKeepsAbForGen.cubin.tar.zst
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm100aKernel_QE4m3KvE2m1OBfloat16H128PagedKvCausalP32MultiCtasKvCgaVarSeqQ8Kv128StaticGroupedSwapsAbForGen.cubin.tar.zst
  • ...and 8797 more

yihwang-nv added a commit to yihwang-nv/TensorRT-LLM that referenced this pull request Nov 18, 2026
…FMHA libraries

- Register beam_shared_prefix ahead of the native libraries
- Keep the paged-prefill error inside the locality-domain partition loop
- Port NVIDIA#22089 (persistent context tile scheduler), NVIDIA#22216 (XQA multi-block
  for INT8 KV) and NVIDIA#20229 (locality-domain SM count for MLA trtllm-gen
  generation) into phasedFmha.cpp
- Point the DSV4 split-KV test at TrtllmGenFmha

Signed-off-by: Yihan Wang <[email protected]>
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.

8 participants