[Bug]: trtllm-gen FMHA CudaArchDecl.h numbers Sm107a as 4, but the prebuilt libTrtLlmGen archives use 4 for 105a and 5 for 107a

オープン 初心者向け
#20,507 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lucifer1004 がすでに取り組んでいます。

2026年10月18日 から。

  • #20518 @lucifer1004 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp

調査の方向性

cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/trtllmGen_fmha_export/trtllm/gen/CudaArchDecl.hを読み、そのCudaArchの値をビルド済みFMHAアーカイブと比較してください。まず、リポジトリのルートからissueにあるCPUのみの再現手順を実行してください。ヘッダーのSm107aの値がアーカイブと一致し、再現手順で105aとして扱われなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Customized kernels
System Info
  • TensorRT-LLM main @ e88d19ca3b
  • Affects SM107 builds (the trtllm-gen FMHA target is compiled with TLLM_RUBIN_FEATURES, see cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/CMakeLists.txt). The reproduction below is CPU-only and uses the checked-in prebuilt archives, on both x86_64 and aarch64.
Who can help?

Related: #18518 and #19038 (enable TLLM_RUBIN_FEATURES for the FMHA target and refresh the archives), #18758 (maps SM107 to Sm100f for NVRTC), #20054 (latest archive update).

Reproduction

cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/trtllmGen_fmha_export/trtllm/gen/CudaArchDecl.h declares:

enum class CudaArch {
  Sm90a = 0,  // 0
  Sm100a,     // 1
  Sm100f,     // 2
  Sm103a,     // 3
#ifdef TLLM_RUBIN_FEATURES
  Sm107a,     // 4
#endif
};

The prebuilt fmha/lib/<arch>/libTrtLlmGen.a and libTrtLlmGenFmhaLib.a were compiled with an enum that also has 105a. Value 4 is 105a there, and 107a is 5:

  • strings libTrtLlmGen.a contains 90a 100a 100f 103a 105a 107a.
  • In the archive's trtllm::gen::cudaArchToString, the jump table covers 0..5.
  • In the archive's trtllm::gen::getMaxNumTmemCols, values 1..3 return 512, 5 returns 576, and anything else goes to the "unsupported" error path.

Minimal CPU-only reproduction, from the repository root:

// repro.cpp
#include "CudaArchDecl.h"
#include <cstdio>
#include <exception>
namespace trtllm { namespace gen { int getMaxNumTmemCols(CudaArch); } }
using trtllm::gen::CudaArch;
int main() {
  std::printf("header: Sm103a=%d Sm107a=%d\n", int(CudaArch::Sm103a), int(CudaArch::Sm107a));
  for (int v : {1, 2, 3, 5})
    std::printf("libTrtLlmGen getMaxNumTmemCols(%d) = %d\n", v, trtllm::gen::getMaxNumTmemCols(CudaArch(v)));
  try {
    std::printf("getMaxNumTmemCols(CudaArch::Sm107a) = %d\n", trtllm::gen::getMaxNumTmemCols(CudaArch::Sm107a));
  } catch (std::exception const& e) {
    std::printf("getMaxNumTmemCols(CudaArch::Sm107a) threw: %s\n", e.what());
  }
}
D=cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha
g++ -std=c++17 -DTLLM_RUBIN_FEATURES -I$D/trtllmGen_fmha_export/trtllm/gen repro.cpp \
    $D/lib/$(uname -m)-linux-gnu/libTrtLlmGen.a -o repro && ./repro

Output (identical on x86_64 and aarch64):

header: Sm103a=3 Sm107a=4
libTrtLlmGen getMaxNumTmemCols(1) = 512
libTrtLlmGen getMaxNumTmemCols(2) = 512
libTrtLlmGen getMaxNumTmemCols(3) = 512
libTrtLlmGen getMaxNumTmemCols(5) = 576
getMaxNumTmemCols(CudaArch::Sm107a) threw: Unsupported CUDA arch: 105a
[E] [TmemTile.cpp:46]: Unsupported CUDA arch: 105a

So CudaArch::Sm107a, as compiled into TensorRT-LLM, is 105a to the archive.

Expected behavior

CudaArch values passed across the boundary to the prebuilt archives mean the same architecture on both sides.

Actual behavior

On SM107, TllmGenFmhaKernel sets options.mCudaArch = intToCudaArch(107) = Sm107a (4) in checkIfKernelExist, warmupOneKernel and run (fmha/fmhaKernels.h). It then hands those FmhaOptions to archive code that reads mCudaArch:

  • fmha::FmhaAutoTuner::selectKernel() (through selectKernelAutotuned), on every path;
  • fmha::FmhaInterface::generateAndCompileKernel(), on the NVRTC path.

run() rewrites mCudaArch to Sm100f before NVRTC compilation for non-spcompress kernels (added in #18518). warmupOneKernel() does not. So the JIT warmup path, and every autotuner call, gives the archive 105a instead of 107a. Any SM107-specific branches in the archive are therefore not taken, and the archive's TMEM limit lookup for that value is the error path shown above.

Additional notes

Suggested fix: make the header match the archives. The smallest change is:

#ifdef TLLM_RUBIN_FEATURES
  // SM107. 4 is Sm105a in the prebuilt trtllm-gen archives.
  Sm107a = 5,
#endif

A more robust alternative is to export the archive's value (or the enum header itself) together with the archives, and add a CPU-only check. Something like the reproduction above, run as a unit test, would catch the next drift when the archives are refreshed.

The other CudaArchDecl.h copies (batchedGemm/trtllm/gen/, batchedGemm/trtllmGen_bmm_export/trtllm/gen/) also number Sm107a as 4. As far as I can tell, they do not pass the value into a prebuilt archive.

What is verified: the reproduction above, on x86_64 and aarch64 against the archives at e88d19ca3b, and the code paths listed under "Actual behavior". Our SM107 builds carry Sm107a = 5. I have not run an SM107 build with the unpatched value end to end, so I cannot say exactly which kernel selections change with 4.

I have the one-line fix and can open a PR.

主要言語
Python
スター
15.1k
フォーク
3k
平均マージ
3日 1時間
マージ済み PR(30日)
474

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/TensorRT-LLM のほかの issue

NVIDIA/TensorRT-LLM の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。