[Bug]: SM100 weight-only GEMM: no proxy fence between the transform warps' shared-memory reads and the TMA refill of the same stage
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- backend, performance
Direzione di ricerca
Start with the transform loop in cpp/tensorrt_llm/cutlass_extensions/include/cutlass_extensions/gemm/collective/sm100_mma_warpspecialized_mixed_input.hpp, especially lines 974–981, and review the PTX proxy-fence requirements cited in the issue. Check generated SASS with cuobjdump to see whether transform-thread LDS results are first used after the stage-release arrive. Done means every transform thread's reads are ordered before the producer's TMA refill, with the stated B200 performance impact checked.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
System Info
- Source:
cpp/tensorrt_llm/cutlass_extensions/include/cutlass_extensions/gemm/collective/sm100_mma_warpspecialized_mixed_input.hppat main10e44bbf. - Binary: the 1.3.0rc26 wheel (
tensorrt_llm-1.3.0rc26-cp312-cp312-manylinux_2_28_x86_64.whl). The affected kernels are in the cubinslibth_common.2024–2027.sm_100.cubininsidetensorrt_llm/libs/libth_common.so, built by ptxas 13.2 (V13.2.78). - Measurements: B200, driver 595.58.03.
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
We found this by reading the source and the SASS of the shipped wheel. We have not reproduced a wrong result on hardware (see "actual behavior").
The problem is in the transform loop of CollectiveMmaSm100WeightOnly (lines 974–981):
- The 128 transform threads read A and the scales/zeros of stage
swith ordinary shared-memory loads (lines 975 and 977). - They sync on
transform_bar(980). Then one elected thread releasesswithconsumer_release(981), which is an mbarrier arrive. - The producer refills
swith TMA for a later K tile.
The loads in step 1 go through the generic proxy, and TMA writes through the async proxy. There is no fence.proxy.async between them. The fence_view_async_shared() at line 996 comes after the release; it orders the writes of the dequantized A, not these reads.
The comment at line 979 says the loads are done. In SASS they are not: neither BAR.SYNC nor the arrive waits for outstanding LDS.
Below is the bf16 × int4 (scale only) kernel with a 64×128×64 tile, from libth_common.2027.sm_100.cubin, with unrelated instructions left out. The three loads are first used after the arrive:
/*05050*/ LDS.U16 R33, [R14+0x4908]
/*05080*/ LDS.U16 R32, [R30+0x31800]
/*050a0*/ LDS.U16 R30, [R30+0x31810]
/*050b0*/ BAR.SYNC.DEFER_BLOCKING 0x3, 0x80 // transform_bar.sync()
... 9 PRMT/SHF instructions, none of which reads R30, R32 or R33 ...
/*05150*/ @!P3 SYNCS.ARRIVE.TRANS64.RED.A1T0 RZ, [R31+URZ], RZ // consumer_release
The wheel has 22 instantiations of this collective, all with cluster 1×1×1. In 12 of them, loads of the stage are still in flight at the arrive:
| Activation × weight, tile | Loads in flight at the arrive |
|---|---|
| fp16 × int4/int8, 128×128 and 64×128 | 8 of 8 |
| bf16 × int4/int8, 64×128 | 2 of 3 (in one, only in the other warps) |
| fp8 × int4 with zero points, 128×128 | 2 of 2 |
| bf16 128×128 (3), fp8 128×128 without zero points (2), fp8 64×128 (4) | 0 of 9 |
To check a build:
- Run
cuobjdump -xelf all libth_common.so. - In each
CollectiveMmaSm100WeightOnlykernel, find theSYNCS.ARRIVEthat followsBAR.SYNC 0x3, 0x80. - See whether any earlier
LDSresult is first used after it.
Expected behavior
The TMA refill of a stage is ordered after every transform thread's reads of that stage.
PTX requires a proxy fence for this (PTX ISA 9.5, §8.6 "Proxies" and §9.7.10.28.2 "Async Proxy"). §9.7.10.28.2 states: "Accessing the same memory location across multiple proxies needs a cross-proxy fence." The mbarrier handoff alone does not provide that fence.
actual behavior
There is no fence. Under the PTX memory model, the refill may overwrite the stage before the reads complete. The transform would then dequantize data from a later K tile and report no error.
We have not seen this happen. On B200 we launched the wheel's own cubins through the driver API, filled D with NaN before each launch, and checked it against a float reference. Two of the kernels above (fp16 × int4 128×128 and bf16 × int4 64×128) ran 4.8×10¹¹ stage releases at M×N×K = 4096×5120×4096, with no wrong output. As a positive control, the same kernels with the loads moved after the release failed in 42% and 91% of launches.
Our explanation: these kernels fit only one CTA per SM (182–207 KB of shared memory). At that occupancy, 99.9% of refills took at least 261 ns after the release, which is longer than the loads take to finish.
A standalone litmus test with the same pattern (same-CTA arrive with loads in flight, no proxy fence, bulk-copy overwrite) does fail on B200 at 4 or more CTAs per SM: 239 stale reads in 7.9×10¹¹. With the fence it gives 0.
additional notes
Suggested fix: every transform thread calls fence_view_async_shared() before transform_bar.sync(). The barrier then orders all the fences before the single arrive. NVIDIA/cutlass#3974 uses the same placement for the SM120 blockwise-scaling mainloop.
Utils::copy_scale_zeros_for_transform(partitioned_extra_info, load2transform_consumer_index);
- // Loads from SMEM are done. Signal the mainloop load as early as possible
+ // Order this thread's reads of the stage before the producer's TMA refill
+ cutlass::arch::fence_view_async_shared();
transform_bar.sync();
load2transform_pipeline.consumer_release(curr_load2transform_pipeline_consumer_state);
Cost on B200 (bf16 × int4, group 64, 128×128×64 tile; GEMM time only):
| M×N×K | Change |
|---|---|
| 4096×5120×4096 | −0.2% |
| 16×5120×4096 | +0.9% |
| 128×16384×16384 | +0.4% |
Whether a given build has loads in flight here depends on ptxas scheduling, not on the source. The bf16 × int4 128×128 instantiation is closed in the wheel, which was built with ptxas 13.2. The same PTX compiled with ptxas 13.3–13.5 is open. The other two instantiations we rebuilt changed in other ways between 13.2 and 13.5: one stayed open, and the other's window narrowed. A toolchain update can therefore open this window without any source change.
Upstream CUTLASS has the same loop in include/cutlass/gemm/collective/sm100_mma_warpspecialized_mixed_input.hpp. We will report it there and link the issue below.
Before submitting a new issue...
- Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
- 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