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

Abierto Apto para principiantes
#20,507 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@lucifer1004 ya está trabajando en esto.

Desde el 18/10/2026.

  • #20518 de @lucifer1004 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp

Línea de trabajo

Lee cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/trtllmGen_fmha_export/trtllm/gen/CudaArchDecl.h y compara sus valores de CudaArch con los archivos FMHA precompilados. Empieza ejecutando la reproducción solo con CPU del issue desde la raíz del repositorio. Se considera terminado cuando el valor Sm107a del encabezado coincide con el archivo, de modo que la reproducción ya no lo trate como 105a.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
15.1k
Forks
3k
Merge medio
3 d 1 h
PR fusionados (30 d)
474

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/TensorRT-LLM

Todos los issues de NVIDIA/TensorRT-LLM

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.