FlashAttention Triton Kernel Exceeds Shared Memory Limit on RTX 5090 (SM120)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend, machine-learning
Direzione di ricerca
Read lmdeploy/pytorch/kernels/cuda/flashattention.py, especially flash_attn_varlen_func() and _kernel_meta_sm12x; compare the SM120 configuration with the proposed _kernel_meta_sm86 settings. First reproduce the prefill warmup on an RTX 5090 with the reported model and versions. Done means initialization succeeds and the Triton shared memory error is gone; the report says long-context behavior, concurrency, correctness, and performance still need validation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
[Bug] FlashAttention Triton Kernel Exceeds Shared Memory Limit on RTX 5090 (SM120)
1. Environment
- GPU: NVIDIA GeForce RTX 5090
- GPU Architecture: Blackwell
- Compute Capability: 12.0 (SM120)
- LMDeploy: 0.18.0
- PyTorch: 2.11.0a0+eb65b36914.nv26.02
- Triton: 3.7.1
- Model: Intern-Decision-4B
- Backend: PyTorch Engine
2. Issue Description
When deploying Intern-Decision-4B with LMDeploy 0.18.0 on an NVIDIA RTX 5090, the PyTorch Engine fails during initialization.
The error occurs during the Prefill Warmup stage when executing the Triton FlashAttention kernel.
Error Log
triton.runtime.errors.OutOfResources:
out of resource: shared memory,
Required: 172032,
Hardware limit: 101376.
Reducing block sizes or `num_stages` may help.
This is a secondary error caused by the PyTorch Engine subprocess terminating after the Triton kernel failure.
2.1 Root Cause
The issue originates from the FlashAttention Triton kernel configuration selected for the SM120 architecture.
Relevant source file:
lmdeploy/pytorch/kernels/cuda/flashattention.py
The failure occurs when launching:
_flash_prefill_fwd_kernel[grid](...)
The RTX 5090 has a maximum opt-in shared memory limit of 101376 bytes per thread block, while the selected kernel configuration requires 172032 bytes.
- Required Shared Memory: 172032 Bytes (168 KiB)
- Hardware Limit: 101376 Bytes (99 KiB)
- Excess: 70656 Bytes (69 KiB)
This is a GPU shared memory limitation, not a GPU VRAM or system RAM exhaustion issue.
2.2 Original Kernel Configuration
The RTX 5090 (SM120) enters the following configuration function:
_kernel_meta_sm12x(BLOCK_DK, shared_kv)
For the affected configuration (BLOCK_DK=256), the selected parameters are:
BLOCK_M = 64BLOCK_N = 64num_warps = 8num_stages = 3
This configuration exceeds the available shared memory on the RTX 5090.
3. Proposed Workaround
A conservative kernel configuration can be used specifically for SM120 GPUs.
Modify the architecture dispatch logic in flash_attn_varlen_func().
Original code:
elif nv_cap[0] < 10:
BLOCK_M, BLOCK_N, num_warps, num_stages = _kernel_meta_sm9x(
BLOCK_DK, shared_kv
)
else:
BLOCK_M, BLOCK_N, num_warps, num_stages = _kernel_meta_sm12x(
BLOCK_DK, shared_kv
)
Modified code:
elif nv_cap[0] < 10:
BLOCK_M, BLOCK_N, num_warps, num_stages = _kernel_meta_sm9x(
BLOCK_DK, shared_kv
)
elif nv_cap[0] == 12 and nv_cap[1] == 0:
# RTX 5090 (SM120): conservative shared-memory configuration
BLOCK_M, BLOCK_N, num_warps, num_stages = _kernel_meta_sm86(
BLOCK_DK, shared_kv
)
else:
BLOCK_M, BLOCK_N, num_warps, num_stages = _kernel_meta_sm12x(
BLOCK_DK, shared_kv
)
For BLOCK_DK=256, the resulting configuration is:
BLOCK_M = 64BLOCK_N = 32num_warps = 4num_stages = 2
This reduces the tile size, number of warps, and pipeline stages, thereby reducing shared memory consumption.
4. Verification Results
After applying the modification:
- The Triton shared memory allocation error no longer prevents engine initialization.
- The PyTorch Engine starts successfully.
- The Intern-Decision-4B service can be launched on the RTX 5090.
Status: Startup issue resolved with the proposed workaround.
Notes
This workaround has been verified for the following setup:
- RTX 5090 (SM120)
- Intern-Decision-4B
- LMDeploy 0.18.0
- PyTorch Engine
Further validation is required for long-context inference, concurrent requests, numerical correctness, and performance.
The proposed configuration should be considered a compatibility workaround rather than a universally optimal SM120 configuration.
- Lingua principale
- Python
- Stelle
- 824
- Fork
- 31
- Merge medio
- 1h 56m
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 InternLM/Intern-Decision
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
InternLM/Intern-Decision#6 · 2 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 5/100
InternLM/Intern-Decision#5 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
InternLM/Intern-Decision#4 · 1 commento ·
-
lora finetuningAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
InternLM/Intern-Decision#3 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
InternLM/Intern-Decision#1 · 1 commento ·
Tutte le issue di InternLM/Intern-Decision
Issue simili
-
accepted
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
future-agi/future-agi#5908 ·
I maintainer di solito rispondono entro 1 giorno
-
Placeholder export disables HTML image input for picture descriptionForse già presa @cloudiful l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
docling-project/docling-serve#817 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
Techiebutler/freeframe#687 ·
I maintainer di solito rispondono entro 1 giorno
-
Parse truncated verbose GC logs up to the first XML errorForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug verbose GC
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
IBM/javacore-analyser#677 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 2 giorni