Skip to content

Commit c2ea6bc

Browse files
authored
[None][feat] StairCase: GLM-5.2 NVFP4 Rubin high-throughput target (#21585)
Signed-off-by: Dongfeng Yu <dongfengy@nvidia.com>
1 parent 4737591 commit c2ea6bc

80 files changed

Lines changed: 31313 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/CODEOWNERS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@
523523
# GLM SM107 target and its native kernels/bindings
524524
/tensorrt_llm/_torch/_experimental/modeling_v2/models/glm_moe_dsa/glm_5_2_nvfp4__sm_107__low_latency @dongfengy @Tabrizian @xwang233
525525
/tests/unittest/_torch/modeling_v2/models/glm_moe_dsa/glm_5_2_nvfp4__sm_107__low_latency @dongfengy @Tabrizian @xwang233
526+
/tensorrt_llm/_torch/_experimental/modeling_v2/models/glm_moe_dsa/glm_5_2_nvfp4__sm_107__high_throughput/ @dongfengy @Tabrizian @xwang233
527+
/tests/unittest/_torch/modeling_v2/models/glm_moe_dsa/glm_5_2_nvfp4__sm_107__high_throughput/ @dongfengy @Tabrizian @xwang233
526528

527529
# GLM-5.3-Flash (glm5_next)
528530
/tensorrt_llm/_torch/_experimental/modeling_v2/models/glm5_next @zhaoyangwang-nvidia

‎cpp/tensorrt_llm/kernels/mlaKernels.cu‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,12 +1866,15 @@ void invokeMLAContextFp8Quantize(MlaParams<T>& params, int total_kv_len, cudaStr
18661866
// Convert Q to FP8 in absorption mode.
18671867
if (params.absorption_mode)
18681868
{
1869+
// Q-sized grids can reduce idle blocks but also useful CTA parallelism.
1870+
static bool const useQLenForQuantGrid = getBoolEnv("TRTLLM_MLA_Q_QUANT_GRID_USE_Q_LEN");
1871+
int const quantGridLen = useQLenForQuantGrid ? params.acc_q_len : total_kv_len;
18691872

18701873
if (params.meta.rope_append)
18711874
{
18721875
constexpr int threads_per_block = 288;
18731876
constexpr int num_tokens_per_block = threads_per_block * 16 / 576 * sizeof(T);
1874-
dim3 grid(int(tensorrt_llm::common::divUp(total_kv_len, num_tokens_per_block)), 1, params.head_num);
1877+
dim3 grid(int(tensorrt_llm::common::divUp(quantGridLen, num_tokens_per_block)), 1, params.head_num);
18751878

18761879
TLLM_LOG_DEBUG(
18771880
"Launching quantizeCopyInputToFp8Kernel with grid_size: (%d, %d, %d), threads_per_block: %d, "
@@ -1890,7 +1893,7 @@ void invokeMLAContextFp8Quantize(MlaParams<T>& params, int total_kv_len, cudaStr
18901893
{
18911894
constexpr int threads_per_block = 256;
18921895
constexpr int num_tokens_per_block = threads_per_block * 16 / 512 * sizeof(T);
1893-
dim3 grid(int(tensorrt_llm::common::divUp(total_kv_len, num_tokens_per_block)), 1, params.head_num);
1896+
dim3 grid(int(tensorrt_llm::common::divUp(quantGridLen, num_tokens_per_block)), 1, params.head_num);
18941897

18951898
TLLM_LOG_DEBUG(
18961899
"Launching quantizeCopyInputToFp8Kernel with grid_size: (%d, %d, %d), threads_per_block: %d, "

‎cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,11 @@ class TllmGenFmhaKernel
13071307
{
13081308
// Basic dimensions
13091309
options.mBatchSize = params.mBatchSize;
1310+
// Existing dispatchers zero-initialize this carrier with memset.
1311+
if (params.mMaxNumCtasPerSeqKv > 0)
1312+
{
1313+
options.mMaxNumCtasPerSeqKv = params.mMaxNumCtasPerSeqKv;
1314+
}
13101315
options.mMaxSeqLenQ = params.mMaxSeqLenQ;
13111316
options.mMinSeqLenQ = params.mMaxSeqLenQ;
13121317
// For context self-attention without prior KV cache, TRT-LLM passes

‎cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaRunnerParams.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "tensorrt_llm/common/assert.h"
2020
#include "tensorrt_llm/common/config.h"
21+
#include <climits>
2122
#include <cstdint>
2223
#include <cuda_runtime.h>
2324

@@ -248,6 +249,8 @@ struct TllmGenFmhaRunnerParams
248249
TileScheduler mTileScheduler;
249250
// The multiCtasKvMode (i.e. multiBlockMode).
250251
bool mMultiCtasKvMode;
252+
// Optional caller limit; the default preserves autotuner selection.
253+
int32_t mMaxNumCtasPerSeqKv{INT_MAX};
251254
// Use block sparse attention.
252255
bool mUseBlockSparseAttention;
253256

‎cpp/tensorrt_llm/thop/attentionOp.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3778,6 +3778,12 @@ int MLA::enqueueGeneration(FmhaParams const& p, cudaStream_t stream)
37783778
if (useSparseMLA())
37793779
{
37803780
auto const& sparseParams = feature<torch_ext::SparseMlaFeature>().params();
3781+
if (auto const maxCtas = p.fwd.sparse_runtime_params.max_num_ctas_per_seq_kv; maxCtas.has_value())
3782+
{
3783+
TLLM_CHECK_WITH_INFO(*maxCtas > 0 && *maxCtas <= std::numeric_limits<int32_t>::max(),
3784+
"Sparse MLA max_num_ctas_per_seq_kv must be a positive int32, got %ld", *maxCtas);
3785+
tllmRunnerParams.mMaxNumCtasPerSeqKv = static_cast<int32_t>(*maxCtas);
3786+
}
37813787
bool const useDynamicSparseMLA = sparseParams.sparse_attn_kv_lens != nullptr;
37823788
tllmRunnerParams.mSparseAttention
37833789
= useDynamicSparseMLA ? SparseType::DynamicTokenSparse : SparseType::StaticTokenSparse;

‎tensorrt_llm/_torch/_experimental/modeling_v2/models/glm_moe_dsa/csrc/CMakeLists.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ add_modeling_v2_target(
6565
SOURCES *.cu *.cpp
6666
DEPS internal_cutlass trtllm_gen_fmha_interface
6767
REQUIRES MULTI_DEVICE)
68+
69+
add_modeling_v2_target(
70+
glm_moe_dsa glm_5_2_nvfp4__sm_107__high_throughput
71+
ARCHS 100f
72+
SOURCES *.cu *.cpp
73+
REQUIRES MULTI_DEVICE)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
"""Rubin high-throughput target and its native operator namespace."""
4+
5+
from tensorrt_llm._torch._experimental.modeling_v2._native import load_target_ops
6+
7+
native_ops = load_target_ops(__name__)

0 commit comments

Comments
 (0)