[Bug]: mergeAttnWithSoftmaxKernel in-place merge races on the softmax stats (no warp sync between the stats load and store)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 54/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- backend, performance
Línea de trabajo
Start with cpp/tensorrt_llm/kernels/mlaChunkedPrefill.cu, especially the stats load near line 200 and store near line 280, then read the in-place call in cpp/tensorrt_llm/thop/mlaPreprocessOp.cpp near line 102. Reproduce with python3 external/ptx/verify.py TensorRT-LLM -k mla_merge --build and inspect the verifier cases cited in the issue. Done when the in-place merge orders each token group's stats loads before its store under independent lane scheduling, and the reported bf16 and f32 cases pass.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
We found this with Volta, a verifier we develop for PTX kernels: it symbolically executes a kernel's compiled PTX for a concrete launch and checks the recorded execution for data races, synchronization errors and PTX ISA rule violations. This report comes from that analysis of the sm_100a PTX at main 3babde6, not from a wrong result observed on a GPU.
System Info
- Static analysis, no GPU run.
- TensorRT-LLM
mainat3babde6b1b88168220fa60567403a7e2b37fb352;cpp/tensorrt_llm/kernels/mlaChunkedPrefill.cucompiled withnvcc -ptx -arch=sm_100a -O3(CUDA 13.2.1,nvidia/cuda:13.2.1-devel-ubuntu24.04).
Who can help?
No response
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - My own task or dataset (give details below)
Reproduction
mergeChunkedAttentionForMLAHelper runs the merge in place: it passes merged_softmax_stats_ptr as both merged_softmax_stats and pre_softmax_stats (mlaPreprocessOp.cpp:102).
In mergeAttnWithSoftmaxKernel, the kVecPerHead lanes that handle one token all load the token's pre stats (:200). Then only the lane with head_dim_idx == 0 stores the merged stats to the same address (:280). Nothing orders the other lanes' loads before that store.
The kernel relies on the lanes running in lockstep, as its own comment says (:41-42):
// All readers of aliased softmax stats must stay in the same warp as their writer.
static_assert(kVecPerHead <= 32, "In-place softmax stats require at most one warp per head");
Being in the same warp is not enough. Since independent thread scheduling (Volta and later), lanes of a warp are not guaranteed to run in lockstep without __syncwarp(). Under the PTX memory model this store and those loads are a data race. In the compiled PTX, the loads are ld.global.v2.b32 {%r54, %r55}, [%rd36] and the store is st.global.v2.b32 [%rd39], {%r12, %r13} on the same address, with no bar.warp.sync between them.
Volta reports this conflict for the bf16 and f32 in-place merges (merge_op == 1). It reports none for the separate-buffer merges or for the copy op. To reproduce with Volta (--build compiles the PTX in Docker):
python3 external/ptx/verify.py TensorRT-LLM -k mla_merge --build
The cases, with their launches and the expected verdicts, are at cases.py:1054-1075.
Expected behavior
Every lane of a token reads the token's pre stats before any lane overwrites them, regardless of how the warp's lanes are scheduled.
actual behavior
The read and the write are ordered only by the lanes running in lockstep, which CUDA does not guarantee since Volta. If the writing lane runs ahead, other lanes read the merged stats instead of the pre stats, and that token's merged attention is wrong.
additional notes
This is latent: we have not seen it produce a wrong output on hardware. A possible fix is to sync the token's lane group after the stats load and before the store, for example:
auto const group = cooperative_groups::tiled_partition<KT::kVecPerHead>(cooperative_groups::this_thread_block());
...
float2 pre_stats = loadMergeNormalizer<IsLse>(pre_softmax_stats, global_softmax_stats_offset);
group.sync();
A full-warp __syncwarp() would not be safe here. Token groups of one warp can run different numbers of loop iterations (local_token_idx < curr_q_len), so the sync has to cover only the token's own lanes.
- Lenguaje dominante
- Python
- Estrellas
- 15.2k
- Forks
- 3k
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 477
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NVIDIA/TensorRT-LLM
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xPosiblemente ocupada @NimaVaziri la tomó hoy. AbiertoPytorch
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA/TensorRT-LLM#23406 ·
Los mantenedores suelen responder en 1 día
-
Inference runtime Windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NVIDIA/TensorRT-LLM#23394 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: MMLU subsampling changes when evaluators are interleavedPosiblemente ocupada @LeNeLeNeWo la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NVIDIA/TensorRT-LLM#23273 ·
Los mantenedores suelen responder en 1 día
-
Trace-replay Pareto window includes the drain when sessions finish out of admission orderPosiblemente ocupada @sbeierle la tomó hace 3 días. AbiertoTesting
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
NVIDIA/TensorRT-LLM#23077 ·
Los mantenedores suelen responder en 1 día
-
LongBench V2 blog command breaks on inline comments after continuationsPosiblemente ocupada @ddlw la tomó hace 25 días. AbiertoDoc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
NVIDIA/TensorRT-LLM#21879 ·
Los mantenedores suelen responder en 1 día
Todos los issues de NVIDIA/TensorRT-LLM
Issues similares
-
[Resource]: SpaicelyAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
hesreallyhim/awesome-claude-code#3875 · 1 comentario ·
-
[Bug]: Ajax Pro login issueAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
bvis/aegis-hass#725 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
Los mantenedores suelen responder en 1 día