Skip to content

[None][feat] skip-softmax on SM120: TMA-load + sync-MMA warp-specialized context FMHA for sm_120/sm_121 - #15163

Merged
DomBrown merged 6 commits into
NVIDIA:mainfrom
dcampora:dcampora/halfspec-sm120
Jun 15, 2026
Merged

[None][feat] skip-softmax on SM120: TMA-load + sync-MMA warp-specialized context FMHA for sm_120/sm_121#15163
DomBrown merged 6 commits into
NVIDIA:mainfrom
dcampora:dcampora/halfspec-sm120

Conversation

@dcampora

@dcampora dcampora commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds skip_softmax, a warp-specialized context (prefill) FMHA for the
sm_120 / sm_121 (consumer Blackwell) family. It is the sm_120 / sm_121 attention
path that implements the per-warp skip-softmax optimization (hence the name).

Only half of the Hopper warp-specialization recipe ports to consumer Blackwell:
the TMA-driven async loads survive, but async MMA does not (no wgmma.async),
so a single producer warp issues cp.async.bulk.tensor loads for Q/K/V into
granular shared-memory buffers via driver-API CUtensorMap descriptors, while
the consumer warps run BMM1 + softmax (+ per-warp skip-softmax) + BMM2 on
mma.sync, synchronized by an mbarrier producer/consumer handshake.

It is opt-in and activates when a SkipSoftmaxAttentionConfig is attached to
the attention layer (TrtllmAttention.use_skip_softmax_fmha). The C++ runner
restricts dispatch to the supported shapes — BF16 in/out,
head_dim == head_dim_v in {128, 256}, causal mask, packed QKV — and ignores
the flag everywhere else, so it is a no-op on other hardware and configs.

What's included:

  • Kernel (cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/): kernel_traits.h,
    dma_sync_mma.h (producer / TMA), compute_sync_mma.h (consumer), plus the
    entry header fused_multihead_flash_attention_kernel_ws_sm120.h and a design
    doc README.md. Compiled sm_120-only via the _context_attention_kernels_120
    CMake target, guarded by TLLM_ENABLE_SKIP_SOFTMAX_SM120.
  • In-engine bridges + dispatch: use_skip_softmax_fmha is plumbed from the
    thop.attention op → AttentionOpMHARunnerParamsLaunch_params
    FusedMultiHeadAttentionXMMAKernelV2::run, which routes the matching config to
    the run_skip_softmax_* bridges. Python property in
    tensorrt_llm/_torch/attention_backend/trtllm.py.
  • Batched-prefill correctness: the producer adds the per-request cumulative
    token offset (cu_q_seqlens[bidb]) to the Q/K/V TMA sequence coordinates;
    without it, multi-request prefill batches all returned request 0's result.

Verified on an RTX PRO 6000 Blackwell (sm_120).

Test Coverage

  • tests/unittest/_torch/attention/test_skip_softmax_sm120.py (new): forces the
    skip_softmax kernel via a SkipSoftmaxAttentionConfig with a tiny
    threshold_scale_factor (no tiles skipped ⇒ full softmax) and checks single-
    and multi-request causal prefill against both an fp32 reference and the default
    (non-skip_softmax) TRTLLM context kernel. Skips on non-sm_120/121 GPUs; the
    multi-request cases are the regression guard for the per-request TMA offset.
  • tests/unittest/_torch/attention_backend/test_attention_op_sync.py (existing):
    guards the use_skip_softmax_fmha kwarg plumbing across the thop.attention
    boundary.

PR Checklist

  • 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.

dcampora added 3 commits June 8, 2026 17:23
…el for sm_120/sm_121

Add the halfspec context FMHA kernel for the sm_120 family (sm_120/sm_121):
a dedicated producer warp drives Q/K/V loads with TMA
(cp.async.bulk.tensor + cuTensorMapEncodeTiled descriptors) into granular
smem buffers, while the consumer warps run a BMM1 + softmax + per-warp
skip-softmax + BMM2 body on mma.sync. sm_120/sm_121 have no wgmma.async, so
only the load side of the Hopper warp-specialization recipe is ported -- hence
'halfspec'.

The kernel reuses the existing LDGSTS Smem_tile_* types (their XOR swizzle is
byte-identical to the TMA 128B hardware swizzle) and re-tiles V into 64-wide DV
chunks so V smem rows stay 128 bytes (the only layout a TMA swizzle mode can
fill). This adds an ENABLE_SKIP_SOFTMAX template parameter to the shared
Kernel_traits_ so the halfspec traits can thread the skip-softmax knob through.

See cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/README.md for the full design
rationale.

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
…hind use_halfspec_fmha

Compile the halfspec translation unit into the _context_attention_kernels_120
CMake target only (it uses sm_120-only TMA + sync-MMA), and add the
TLLM_ENABLE_HALFSPEC_SM120 guard so the all-architecture dispatch TU references
the run_halfspec_* bridge symbols only on builds that include sm_120.

Plumb a use_halfspec_fmha opt-in flag end to end: the PyTorch attention op
(nanobind) -> AttentionOp -> MHARunnerParams -> Launch_params. When set and the
config matches (sm_120/sm_121, BF16 in/out, causal, head_dim == head_dim_v in
{128, 256}, PACKED_QKV), FusedMultiHeadAttentionXMMAKernelV2::run dispatches to
the halfspec kernel; the flag is a no-op everywhere else. The TrtllmAttention
backend opts in whenever skip-softmax is configured, since halfspec is the
sm_120/sm_121 kernel that implements skip-softmax.

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
…d prefill

The halfspec (TMA-load + sync-MMA warp-specialized) sm_120/sm_121 context FMHA
issued its Q/K/V TMA loads with request-local sequence coordinates and no
per-request token offset. Because the Q/K/V descriptors span the whole packed
[total_tokens, H, D] buffer with a single base pointer, every batch element
re-read request 0's tokens: single-request prefill was correct, but for batch
size B > 1 all B requests returned request 0's result.

Add the cumulative per-request token offset (binfo.sum_s == cu_q_seqlens[bidb])
to the Q/K/V seq coordinates in DMA::run. The KV offset reuses sum_s rather than
sum_s_kv: halfspec is PACKED_QKV-only, so K/V share each request's token range
with Q, and cu_kv_seqlens is null on the self-attention path (sum_s_kv would
dereference it unconditionally in the Single_cta ctor, faulting).

Add tests/unittest/_torch/attention/test_halfspec_sm120.py, which forces the
halfspec kernel via a skip-softmax config (tiny threshold => no actual skipping,
full softmax) and checks single- and multi-request batches against both an fp32
causal reference and the default TRTLLM context kernel. The multi-request cases
are the regression guard for this fix.

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
@dcampora
dcampora requested a review from a team as a code owner June 9, 2026 11:03
@dcampora
dcampora requested a review from yuxianq June 9, 2026 11:03
Trim the verbose comment block on the per-request TMA offset and the test's
module docstring / inline comments. No functional change.

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a warp-specialized "halfspec" fused multi-head flash attention kernel optimized for NVIDIA SM_120/SM_121. The implementation adds skip-softmax parameter support to kernel traits, defines SM120-specific producer-DMA and consumer-compute stages synchronized via mbarriers, integrates runtime dispatch conditioned on SM version and data format, and exposes the feature through Python binding and config flags.

Changes

SM120 Halfspec Flash Attention Implementation

Layer / File(s) Summary
Skip-softmax kernel traits parameter
cpp/kernels/fmha_v2/src/fmha/kernel_traits.h
Kernel_traits_ and its alias templates (Kernel_traits_v2*) now accept ENABLE_SKIP_SOFTMAX parameter (default false) and expose it as a compile-time member to enable skip-softmax behavior control.
SM120 halfspec kernel traits and shared memory
cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/kernel_traits.h
Defines Kernel_traits_halfspec_sm120 composing SM120 configuration with configurable RING_DEPTH, granular circular buffers (Q/K/V), re-tiled 64-wide DV chunks, named mbarrier IDs, and a Shared struct managing per-slot synchronization via bar_create.
SM120 producer DMA with TMA loads
cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/dma_sync_mma.h
Implements warp-specialized producer DMA<Kernel_traits> issuing 3D TMA loads (via utmaldg_3d_cta) from global memory into circular buffers; includes Host helper using cuTensorMapEncodeTiled to encode Q/K/V descriptors with swizzle selection based on leading-dimension byte size.
SM120 consumer compute with sync-MMA and skip-softmax
cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/compute_sync_mma.h
Implements consumer-side Compute<Kernel_traits>::run() performing BMM1/BMM2 with mbarrier handshake, optional per-warp skip-softmax decision using log-threshold, conditional MMA accumulation (do_bmm2), and output normalization with shared-memory tile store via named barriers.
SM120 warp-split device kernel wrapper
cpp/kernels/fmha_v2/src/fused_multihead_flash_attention_kernel_ws_sm120.h
Defines device_flash_attention_ws_sm120 splitting warp 0 (producer DMA) and remaining warps (consumer compute), with conditional setmaxnreg calls for SM_120/SM_121 register budget.
Runtime parameter structures
cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fused_multihead_attention_common.h, cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fmhaRunner.cpp
Adds useHalfspecFmha flag to MHARunnerParams and Launch_params; extends skip-softmax validation to permit on SM120/SM121 when halfspec FMHA is enabled.
Dispatch logic, CMake, and configuration
cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/CMakeLists.txt, cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fused_multihead_attention_v2.cpp, cpp/tensorrt_llm/common/attentionOp.h, cpp/tensorrt_llm/common/attentionOp.cpp
Adds halfspec dispatch in FusedMultiHeadAttentionXMMAKernelV2::run for BF16 causal configs (d=128 or 256); CMake excludes halfspec from generic sources and defines TLLM_ENABLE_HALFSPEC_SM120 for sm_120 builds; AttentionOp adds mUseHalfspecFmha config member propagated to fmhaParams.
Host-side launch, TMA setup, and Python binding
cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/halfspec_sm120/fused_multihead_flash_attention_ws_sm120.cu, cpp/tensorrt_llm/thop/attentionOp.h, cpp/tensorrt_llm/thop/attentionOp.cpp, cpp/tensorrt_llm/nanobind/thop/bindings.cpp, tensorrt_llm/_torch/attention_backend/trtllm.py
Implements launch_halfspec for kernel launch, run_halfspec_bf16_d{128,256}_causal_sm120 dispatch wrappers, C++ torch extension attention entry with use_halfspec_fmha parameter, and Python TrtllmAttention.use_halfspec_fmha property (enabled for SkipSoftmaxAttentionConfig).
Documentation and GPU correctness tests
cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/README.md, tests/unittest/_torch/attention/test_halfspec_sm120.py
Adds README covering halfspec design (TMA, smem swizzles, V re-tiling, SM_120 hardware constraints) and parametrized GPU test verifying halfspec output matches default and fp32 reference on multi-request causal attention.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • yuxianq
  • suyoggupta
  • yizhang-nv
  • QiJune
  • venkywonka
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.83% 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
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.
Title check ✅ Passed The title clearly and specifically describes the main feature: adding skip-softmax support on SM120 with TMA-load and sync-MMA warp-specialized context FMHA. It directly matches the PR objectives.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering the purpose, implementation details, test coverage, and checklist.

✏️ 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.

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

Actionable comments posted: 4

🧹 Nitpick comments (4)
cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/dma_sync_mma.h (2)

315-316: 💤 Low value

FP16 support may need format distinction.

When ELEMENT_BYTES == 2, this unconditionally uses CU_TENSOR_MAP_DATA_TYPE_BFLOAT16. For FP16 inputs, this should technically be CU_TENSOR_MAP_DATA_TYPE_FLOAT16. However, since CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE is used (line 333), the format field only affects out-of-bounds fill behavior which is disabled here. The TMA moves raw bytes regardless of the format, so this works correctly for both BF16 and FP16 data in practice.

Consider adding a comment clarifying this or accepting an explicit data type template parameter if FP16 support becomes a priority.

🤖 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 `@cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/dma_sync_mma.h` around lines 315
- 316, The conditional that sets CUtensorMapDataType based solely on
Kernel_traits::ELEMENT_BYTES currently maps 2-byte elements to
CU_TENSOR_MAP_DATA_TYPE_BFLOAT16 which is incorrect for FP16; update the code in
dma_sync_mma.h (around the CUtensorMapDataType fmt assignment) to either accept
an explicit data-type template parameter for true FP16 vs BF16 selection or, at
minimum, add a clear comment explaining that because
CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE is used the format only affects out-of-bounds
fill and TMA moves raw bytes so the current mapping is intentional and works for
both BF16 and FP16; reference Kernel_traits::ELEMENT_BYTES,
CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, CU_TENSOR_MAP_DATA_TYPE_FLOAT32 and
CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE in the comment or when introducing the
explicit type parameter.

334-343: 💤 Low value

Error reporting doesn't prevent undefined behavior.

When cuTensorMapEncodeTiled fails, this prints an error but continues execution. The kernel will likely crash or produce garbage with an uninitialized descriptor. For debug builds this is acceptable, but consider adding an assertion or a way to signal failure to the caller.

🤖 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 `@cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/dma_sync_mma.h` around lines 334
- 343, The current error handling after cuTensorMapEncodeTiled (checking res !=
CUDA_SUCCESS and only printing) can leave the tensor descriptor uninitialized
and lead to UB; update the handling by either asserting/aborting on failure or
propagating the error to the caller: inside the res != CUDA_SUCCESS branch
(where err is retrieved), call assert(false) or abort() for debug builds, and
for release builds set/return a failure code (e.g., return res or a bool/error
enum) so the caller can bail out; ensure the chosen approach consistently
prevents further use of the (uninitialized) descriptor created around the
cuTensorMapEncodeTiled call.
cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fmhaRunner.cpp (1)

509-521: ⚡ Quick win

Reuse the existing isSm120f variable instead of redeclaring it.

Line 509 redeclares isSm120f, which shadows the identical variable declared at Line 362 in the same function. While legal, this makes the code harder to maintain. Simply reuse the outer isSm120f and remove the redundant declaration here.

♻️ Suggested simplification
     mLaunchParams.enableSkipSoftmax = false;
     if (runnerParams.skipSoftmaxThresholdScaleFactor > 0)
     {
-        bool const isSm120f = (mSM == kSM_120 || mSM == kSM_121);
         bool const hopperWarpspec = isSm90 && mLaunchParams.warp_specialization;
         // The halfspec kernel is the only sm_120 / sm_121 FMHA that implements
         // skip-softmax, so skip-softmax there is only permitted with halfspec.
         bool const sm120Halfspec = isSm120f && mLaunchParams.useHalfspecFmha;
🤖 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 `@cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fmhaRunner.cpp`
around lines 509 - 521, The local variable isSm120f is being redeclared in the
block starting at the shown snippet; remove the redundant declaration and reuse
the previously declared isSm120f (the one referencing mSM and kSM_120 / kSM_121)
so the condition uses the outer isSm120f rather than shadowing it; update the
condition that computes sm120Halfspec (and any subsequent logic that references
isSm120f) to reference the existing isSm120f variable in fmhaRunner.cpp.
tests/unittest/_torch/attention/test_halfspec_sm120.py (1)

35-35: ⚡ Quick win

Prefer built-in list over typing.List for Python 3.10+ compatibility.

Per coding guidelines, use built-in types (list, dict, tuple) instead of legacy typing.List, typing.Dict, typing.Tuple in annotations. Since this codebase targets Python 3.10+, you can remove from typing import List and use list[int] directly in the function signature at line 58.

♻️ Suggested change
-from typing import List

Then update line 58:

-    seq_lens: List[int],
+    seq_lens: list[int],
🤖 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/attention/test_halfspec_sm120.py` at line 35, Remove
the legacy typing import and replace usages with built-in generics: delete the
line "from typing import List" and update any function/type annotations that use
"List" (notably the test function signature at line 58) to use the built-in form
"list[int]" (or the appropriate element type), e.g., change "List[int]" to
"list[int]" to conform to Python 3.10+ typing conventions.

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.

Inline comments:
In
`@cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/halfspec_sm120/fused_multihead_flash_attention_ws_sm120.cu`:
- Around line 163-165: The calls to ::launch_halfspec (e.g.,
::launch_halfspec<::fmha_halfspec::Halfspec_ktraits<256>>) currently ignore the
returned cuda error code; capture the return value (cudaError_t) from each
launch and propagate it instead of discarding it so that errors aren't masked by
the later cudaGetLastError() return in this function; update the function to
return the launch result (or if non-success, return that error immediately) for
both occurrences around the calls to ::launch_halfspec.

In `@tests/unittest/_torch/attention/test_halfspec_sm120.py`:
- Around line 129-132: Add a return type annotation to the test function
declaration for test_halfspec_context_matches_reference: update its signature to
include "-> None" so the function is explicitly typed as returning nothing,
ensuring compliance with the test suite coding guidelines and type checkers.
- Line 129: Update the pytest parameterization for the head_dim parameter so the
test covers both supported sizes: change the decorator argument from "head_dim",
[128] to "head_dim", [128, 256] (keeping the existing ids=lambda d:
f"head_dim_{d}") so the halfspec kernel is exercised for head_dim ∈ {128, 256}
in the test that uses the head_dim fixture/parameter.
- Around line 81-111: Add a return type annotation to _run_context indicating it
returns a tuple of (the attention layer instance, the Metadata object, and the
output tensor); e.g. annotate the function as returning Tuple[..., torch.Tensor]
and import/use typing.Tuple and typing.Any or a forward-reference to
AttentionCls.Metadata so the signature reflects: (layer instance from
AttentionCls, AttentionCls.Metadata, torch.Tensor) to make the return type
explicit for callers and linters.

---

Nitpick comments:
In `@cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/dma_sync_mma.h`:
- Around line 315-316: The conditional that sets CUtensorMapDataType based
solely on Kernel_traits::ELEMENT_BYTES currently maps 2-byte elements to
CU_TENSOR_MAP_DATA_TYPE_BFLOAT16 which is incorrect for FP16; update the code in
dma_sync_mma.h (around the CUtensorMapDataType fmt assignment) to either accept
an explicit data-type template parameter for true FP16 vs BF16 selection or, at
minimum, add a clear comment explaining that because
CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE is used the format only affects out-of-bounds
fill and TMA moves raw bytes so the current mapping is intentional and works for
both BF16 and FP16; reference Kernel_traits::ELEMENT_BYTES,
CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, CU_TENSOR_MAP_DATA_TYPE_FLOAT32 and
CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE in the comment or when introducing the
explicit type parameter.
- Around line 334-343: The current error handling after cuTensorMapEncodeTiled
(checking res != CUDA_SUCCESS and only printing) can leave the tensor descriptor
uninitialized and lead to UB; update the handling by either asserting/aborting
on failure or propagating the error to the caller: inside the res !=
CUDA_SUCCESS branch (where err is retrieved), call assert(false) or abort() for
debug builds, and for release builds set/return a failure code (e.g., return res
or a bool/error enum) so the caller can bail out; ensure the chosen approach
consistently prevents further use of the (uninitialized) descriptor created
around the cuTensorMapEncodeTiled call.

In `@cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fmhaRunner.cpp`:
- Around line 509-521: The local variable isSm120f is being redeclared in the
block starting at the shown snippet; remove the redundant declaration and reuse
the previously declared isSm120f (the one referencing mSM and kSM_120 / kSM_121)
so the condition uses the outer isSm120f rather than shadowing it; update the
condition that computes sm120Halfspec (and any subsequent logic that references
isSm120f) to reference the existing isSm120f variable in fmhaRunner.cpp.

In `@tests/unittest/_torch/attention/test_halfspec_sm120.py`:
- Line 35: Remove the legacy typing import and replace usages with built-in
generics: delete the line "from typing import List" and update any function/type
annotations that use "List" (notably the test function signature at line 58) to
use the built-in form "list[int]" (or the appropriate element type), e.g.,
change "List[int]" to "list[int]" to conform to Python 3.10+ typing conventions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 472f46e7-92ed-42ad-98e0-ba0a5dda1475

📥 Commits

Reviewing files that changed from the base of the PR and between 104b9d7 and 6469587.

📒 Files selected for processing (18)
  • cpp/kernels/fmha_v2/src/fmha/kernel_traits.h
  • cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/README.md
  • cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/compute_sync_mma.h
  • cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/dma_sync_mma.h
  • cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/kernel_traits.h
  • cpp/kernels/fmha_v2/src/fused_multihead_flash_attention_kernel_ws_sm120.h
  • cpp/tensorrt_llm/common/attentionOp.cpp
  • cpp/tensorrt_llm/common/attentionOp.h
  • cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/CMakeLists.txt
  • cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fmhaRunner.cpp
  • cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fused_multihead_attention_common.h
  • cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/fused_multihead_attention_v2.cpp
  • cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/halfspec_sm120/fused_multihead_flash_attention_ws_sm120.cu
  • cpp/tensorrt_llm/nanobind/thop/bindings.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.h
  • tensorrt_llm/_torch/attention_backend/trtllm.py
  • tests/unittest/_torch/attention/test_halfspec_sm120.py

Comment thread tests/unittest/_torch/attention/test_skip_softmax_sm120.py Outdated
Comment thread tests/unittest/_torch/attention/test_skip_softmax_sm120.py Outdated
Comment thread tests/unittest/_torch/attention/test_halfspec_sm120.py Outdated
The "halfspec" codename did not convey the kernel's purpose. Rename it to
skip_softmax to match the existing skip-softmax feature naming
(SkipSoftmaxAttentionConfig, skip_softmax_threshold_scale_factor,
enableSkipSoftmax). Mechanical rename across identifiers, the
TLLM_ENABLE_SKIP_SOFTMAX_SM120 build define, the use_skip_softmax_fmha dispatch
flag, namespaces/traits, the directory (skip_softmax_sm120/) and the test file
(test_skip_softmax_sm120.py). README/comment prose updated where the old "half
of the warp-spec recipe" etymology no longer applied. No behavior change.

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
@dcampora dcampora changed the title [None][feat] halfspec: TMA-load + sync-MMA warp-specialized context FMHA for sm_120/sm_121 [None][feat] skip-softmax on SM120: TMA-load + sync-MMA warp-specialized context FMHA for sm_120/sm_121 Jun 9, 2026
Comment thread cpp/tensorrt_llm/common/attentionOp.h Outdated
Comment thread cpp/kernels/fmha_v2/src/fmha/warpspec_sm120/kernel_traits.h Outdated
@dcampora
dcampora force-pushed the dcampora/halfspec-sm120 branch from f5bdeb5 to 417dc5f Compare June 12, 2026 07:18
…fault context kernel

The TMA-load + sync-MMA warp-specialized context FMHA is now the default
context attention path for sm_120 / sm_121 rather than an opt-in.

Skip-softmax is driven by the prefill threshold alone -- there is no separate
enable flag. The sm_120 / sm_121 bridges read
params.skip_softmax_threshold_scale_factor directly to select the
ENABLE_SKIP_SOFTMAX kernel variant: the false variant is a plain full-softmax
prefill (no skip-check overhead) and runs by default; the true variant runs when
a threshold is set. If a threshold is set but no skip-capable kernel matches the
config, skipping is simply not enabled and the request runs full softmax (no
error).

- Drop the use_skip_softmax_fmha / useSkipSoftmaxFmha / mUseSkipSoftmaxFmha opt-in
  end-to-end: the attention op + nanobind binding, MHARunnerParams / Launch_params,
  AttentionOp (incl. its data() identity tuple), fmhaRunner, and the Python
  TrtllmAttention property + call site.
- Launch_params::enableSkipSoftmax is now only the Hopper cubin-selection bit
  (threshold > 0 && warp_specialization && flash_attention); on sm_120 / sm_121 it
  stays false and the threshold drives the bridge directly.
- Dispatch every matching sm_120 / sm_121 prefill (BF16 in/out, causal, packed QKV,
  head_dim == head_dim_v in {128, 256}) to the kernel, with guards that fall back to
  the cubin path for features it does not implement: alibi (params.has_alibi),
  logit softcapping, sage attention, returning softmax stats
  (params.softmax_stats_ptr), and the interleaved layout.
- Propagate the launch_skip_softmax CUDA error from the bridges (it was dropped,
  which could clear/hide launch failures).
- Abort on a cuTensorMapEncodeTiled failure instead of continuing with an
  unencoded TMA descriptor (the prior print-and-continue left undefined behavior),
  and document the BF16-only descriptor data-type mapping.
- Remove the unused RING_DEPTH kernel-traits knob.
- Test: exercise both kernel variants (no-skip default + 1e-30 skip) against the
  fp32 reference across head_dim in {128, 256}; modernize annotations (return
  types and built-in list over typing.List).

TLLM_ENABLE_SKIP_SOFTMAX_SM120 is retained as a link-availability guard: it lets the
all-architecture dispatch TU reference the sm_120-only bridge symbols without an
undefined-symbol error on builds that exclude sm_120. It is not a feature gate.

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
@dcampora
dcampora force-pushed the dcampora/halfspec-sm120 branch from 417dc5f to fffc18c Compare June 12, 2026 12:28
@dcampora

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53887 [ run ] triggered by Bot. Commit: fffc18c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@dcampora

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53951 [ run ] triggered by Bot. Commit: fffc18c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53951 [ run ] completed with state SUCCESS. Commit: fffc18c
/LLM/main/L0_MergeRequest_PR pipeline #43042 completed with status: 'SUCCESS'

CI Report

Link to invocation

@DomBrown
DomBrown merged commit 20b6068 into NVIDIA:main Jun 15, 2026
7 checks passed
xinhe-nv pushed a commit to tensorrt-cicd/TensorRT-LLM that referenced this pull request Jun 23, 2026
…zed context FMHA for sm_120/sm_121 (NVIDIA#15163)

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
Signed-off-by: GitLab CI Bot <gitlab-ci@nvidia.com>
xinhe-nv pushed a commit to tensorrt-cicd/TensorRT-LLM that referenced this pull request Jun 24, 2026
…zed context FMHA for sm_120/sm_121 (NVIDIA#15163)

Signed-off-by: Daniel Campora <961215+dcampora@users.noreply.github.com>
Signed-off-by: GitLab CI Bot <gitlab-ci@nvidia.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