TensorRT-LLM icon indicating copy to clipboard operation
TensorRT-LLM copied to clipboard

head_size 256 missing from the sm_120 e4m3 kernel enumeration disables fused FP8-KV context FMHA

Open StephenLReed opened this issue 3 months ago • 2 comments

System Info

  • TensorRT-LLM: 1.3.0rc23 (built from f20ea652); behaviour re-checked against main @ fbda11f5
  • GPU: NVIDIA GeForce RTX 5090 (sm_120), driver 595.71.05
  • PyTorch 2.11.0+cu130, CUDA 13.0, Python 3.12.13
  • Ubuntu 25.10, kernel 6.17.0-41-generic
  • Backend: PyTorch; single GPU, no TP/PP
  • Model where observed: Qwen3.6-35B-A3B-NVFP4 with FP8 KV cache (where model-specific)

Who can help?

No response

Reproduction

cpp/kernels/fmha_v2/setup.py enumerates sm_120 e4m3→bf16 kernels with head_sizes=[64, 128, 192, 576]. 256 is absent.

Models with GQA head_dim == 256 therefore have no fused FP8-KV paged-context FMHA kernel on sm_120, and the runtime falls back to an unfused dense context path. Because it is a build-time kernel-generation gap rather than a runtime error, it presents as "prefix caching does not work on this GPU" with no diagnostic.

Serving Qwen3.6-35B-A3B with FP8 KV on RTX 5090 (sm_120):

  • the unfused chunked-context path requested a ~626 GB workspace, i.e. KV block reuse was not merely slower but unusable on the card;
  • adding 256 to the enumeration made prefix reuse work — our reuse probe reached 4096/4181 blocks cached across two hosts.

Expected behavior

A GQA head_dim 256 model uses the fused FP8-KV paged-context FMHA kernel on sm_120, so KV block reuse works.

actual behavior

No such kernel is generated for sm_120, so the runtime silently falls back to an unfused dense context path. That path requested a ~626 GB workspace, making KV block reuse unusable on the card. No error is raised.

additional notes

Serving Qwen3.6-35B-A3B with FP8 KV on RTX 5090 (sm_120):

  • the unfused chunked-context path requested a ~626 GB workspace, i.e. KV block reuse was not merely slower but unusable on the card;
  • adding 256 to the enumeration made prefix reuse work — our reuse probe reached 4096/4181 blocks cached across two hosts.

Add 256 to that head_sizes list. This enlarges the generated sm_120 kernel set (build time and binary size) and changes no runtime behaviour for other head sizes.

Per CONTRIBUTING.md we are opening this Issue Request before submitting the one-line PR.

Questions for maintainers

  1. Was 256 omitted deliberately for sm_120 — binary-size budget, or an untested configuration?
  2. If the default sm_120 kernel set should not grow, would you prefer this behind a build flag?
  3. Is there an existing test that would have caught the silent fallback, or should one be added?

StephenLReed avatar Aug 18 '26 16:08 StephenLReed

Looks like runtime silently falls back to unfused dense context path causing ~626gb workspace request.

Use badgr doctor to diagnostic report identifying missing kernel enumeration and excessive memory allocation.

That should help confirm nvidia-smi memory usage during inference.

Run it now on Badgr →

carter-smalls avatar Aug 18 '26 17:08 carter-smalls

Thank you for reporting this. This is already fixed on main. The sm_120 e4m3_fp32 to bf16 enumeration at cpp/kernels/fmha_v2/setup.py:6813-6817 now reads head_sizes=[64, 128, 192, 256, 576], so 256 is generated and a GQA head_dim == 256 model on sm_120 gets the fused FP8-KV paged-context kernel rather than falling back. That is the one-line change you identified. Building from current main should give you the fused path without a local patch; if you rebuild and still see the unfused chunked-context path with its outsized workspace request on a head_dim 256 model, that would point at something other than the enumeration and is worth a separate report.

karljang avatar Sep 05 '26 23:09 karljang