[Bug]: apply_per_channel_scale reads and writes past the last row when rows % kProcessRows != 0
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- backend, performance
Direzione di ricerca
Start with cpp/tensorrt_llm/kernels/preQuantScaleKernel.cu, especially the row guards and processing loop at lines 52–59, then check the launcher configuration at lines 128–145. Reproduce with the per_channel_scale_4rows_tail case using the Volta command in the issue. Done means the kernel accesses no rows beyond rows or num_valid_tokens_ptr; verify both the per-channel and per-expert launchers.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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, out-of-bounds accesses 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/preQuantScaleKernel.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
Once rows * cols >= 2048 * 2048, apply_per_channel_scale_kernel_launcher (and the _per_expert_ launcher) uses kProcessRows = 4, 8 or 16 rows per block (preQuantScaleKernel.cu:128-145), with a grid of ceil(rows / kProcessRows) blocks. The kernel's guards test only the block's first row:
if (col_offset * kElems >= cols || row_offset * kProcessRows >= rows)
return;
if (num_valid_tokens_ptr && (row_offset * kProcessRows >= *num_valid_tokens_ptr))
return;
...
for (int i = 0; i < kProcessRows; ++i)
{
... act + i * cols ... // read
... smoothed_act + i * cols ... // write
(:52-59). When rows % kProcessRows != 0, the last block therefore reads act and writes smoothed_act up to kProcessRows - 1 rows past rows. It likewise processes rows past *num_valid_tokens_ptr.
Volta reports this for rows = 4097, cols = 1024 (kProcessRows = 4, block 1024 covers rows 4096-4099): an out-of-bounds global read of act row 4097, one past the end. To reproduce with Volta (--build compiles the PTX in Docker):
python3 external/ptx/verify.py TensorRT-LLM -k per_channel_scale --build
The case is per_channel_scale_4rows_tail (cases.py:1356-1364).
Expected behavior
The kernel touches only rows < rows (and < *num_valid_tokens_ptr, when given).
actual behavior
The last block reads and writes up to kProcessRows - 1 rows past the end of act and smoothed_act.
additional notes
In the one caller we found, CutlassMoeFCRunner::applyPrequantScale (moe_kernels.cu:3724), the extra rows appear to stay inside the MoE workspace: smoothed_act is sized at twice max(permuted_elems, interbuf_elems). So this looks latent there, but the launchers are a public API (preQuantScaleKernel.h) and nothing documents that requirement on the buffers.
A possible fix is to bound the loop per row:
int const row_end = min(kProcessRows, rows - row_offset * kProcessRows);
int const valid_end = num_valid_tokens_ptr
? min<int64_t>(row_end, *num_valid_tokens_ptr - row_offset * kProcessRows) : row_end;
for (int i = 0; i < valid_end; ++i)
- Lingua principale
- Python
- Stelle
- 15.2k
- Fork
- 3k
- Merge medio
- 2g 21h
- PR unite (30g)
- 477
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NVIDIA/TensorRT-LLM
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xForse già presa @NimaVaziri l’ha presa oggi. ApertaPytorch
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA/TensorRT-LLM#23406 ·
I maintainer di solito rispondono entro 1 giorno
-
Inference runtime Windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
NVIDIA/TensorRT-LLM#23394 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: MMLU subsampling changes when evaluators are interleavedForse già presa @LeNeLeNeWo l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NVIDIA/TensorRT-LLM#23273 ·
I maintainer di solito rispondono entro 1 giorno
-
Trace-replay Pareto window includes the drain when sessions finish out of admission orderForse già presa @sbeierle l’ha presa 3 giorni fa. ApertaTesting
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
NVIDIA/TensorRT-LLM#23077 ·
I maintainer di solito rispondono entro 1 giorno
-
LongBench V2 blog command breaks on inline comments after continuationsForse già presa @ddlw l’ha presa 25 giorni fa. ApertaDoc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
NVIDIA/TensorRT-LLM#21879 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di NVIDIA/TensorRT-LLM
Issue simili
-
[Resource]: SpaicelyApertaresource-submission validation-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
hesreallyhim/awesome-claude-code#3875 · 1 commento ·
-
[Bug]: Ajax Pro login issueApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
bvis/aegis-hass#725 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
I maintainer di solito rispondono entro 1 giorno