vllm - ✅(Solved) Fix [Performance]: Add warning log for FP8 KV cache without prefill query quantization [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#39751Fetched 2026-04-15 06:20:33
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
mentioned ×2subscribed ×2closed ×1cross-referenced ×1

When using --kv-cache-dtype fp8 with MLA models (e.g. DeepSeek-R1), the prefill FMHA kernel dispatches QkvBfloat16 by default. the FP8 variant (QkvE4m3) requires explicitly setting use_prefill_query_quantization=true in --attention-config, which is not easy discoverable.

Per PR #31195 by @pavanimajety, this was intentionally gated because at short sequence lengths, the BF16 to FP8 cast overhead slight degrades end-to-end performance despite ~1.5x kernel-level improvement.

However, for long-context prefill (128K+), the kernel time dominates and the FP8 path is significantly faster. Our profiling on GB300 (DeepSeek-R1-FP4, PP=4, ISL=128K) shows:

Kernel VariantAvg Latency
fmhaSm103aKernel_QkvBfloat16... (default)287 ms
fmhaSm103aKernel_QkvE4m3... (FP8)225 ms

This is a 1.28x speedup that users silently miss.

Root Cause

Per PR #31195 by @pavanimajety, this was intentionally gated because at short sequence lengths, the BF16 to FP8 cast overhead slight degrades end-to-end performance despite ~1.5x kernel-level improvement.

Fix Action

Fix / Workaround

When using --kv-cache-dtype fp8 with MLA models (e.g. DeepSeek-R1), the prefill FMHA kernel dispatches QkvBfloat16 by default. the FP8 variant (QkvE4m3) requires explicitly setting use_prefill_query_quantization=true in --attention-config, which is not easy discoverable.

PR fix notes

PR #39752: add warning when FP8 KV cache misses prefill query quantization

Description (problem / solution / changelog)

Purpose

add a startup warning log when FP8 KV cache is enabled (--kv-cache-dtype fp8) but use_prefill_query_quantization is not set, so users are aware of the FP8 prefill attention option.

Resolves #39751

Background: Per PR #31195 by @pavanimajety, FP8 prefill query quantization was intentionally gated behind use_prefill_query_quantization=true because it regresses short-sequence performance (~20% at ISL=1024). However, for long-context workloads (ISL >= 4K), the FP8 FMHA kernel is significantly faster (up to 1.4x at 128K). Currently, users with --kv-cache-dtype fp8 silently get BF16 prefill attention with no indication that a faster path exists.

This PR adds a warning_once log in determine_prefill_query_data_type() for the case where FP8 KV cache is active and the backend supports FP8 prefill, but the user has not enabled it. The warning includes the exact --attention-config flag.

no default behavior is changed.

Test Plan

  1. Start vLLM with FP8 KV cache but without the flag:
vllm serve <model> --kv-cache-dtype fp8

Verify the warning appears in startup logs:

WARNING: FP8 KV cache is enabled but prefill queries are not quantized to FP8. 
For long-context workloads (ISL >= 4K), enabling FP8 prefill attention can 
significantly improve prefill latency. To enable, add: 
--attention-config '{"use_prefill_query_quantization": true}'
  1. Start with the flag enabled — verify no warning, and the existing info log appears instead:
vllm serve <model> --kv-cache-dtype fp8 \
  --attention-config '{"use_prefill_query_quantization": true}'

Expected: INFO: FP8 prefill attention enabled: query data type is FP8

  1. Start without FP8 KV cache — verify no warning:
vllm serve <model>

Test Result

Profiling results on GB300 (DeepSeek-R1-FP4, DP=4, ISL=128K) showing the speedup users miss without this flag:

Kernel VariantAvg Latency
fmhaSm103aKernel_QkvBfloat16 (default)287 ms
fmhaSm103aKernel_QkvE4m3 (with flag)225 ms
Speedup1.28x

Short-Seq Benchmark

To verify whether the cast overhead has improved since the original analysis (Dec 2025), we ran end-to-end benchmarks on GB300 with the following setup:

  • Model: DeepSeek-R1-0528-FP4
  • Parallelism: DP=4 (matching Pavani's PR #31195 config, but we used max-model-len=34816 to also test ISL=4096)
  • KV cache: fp8
  • Platform: GB300
ISLBF16 Throughput (tok/s)FP8 Throughput (tok/s)FP8 / BF16Mean TTFT (BF16)Mean TTFT (FP8)
102415,80312,56279.5%24.8 s38.2 s
409680,86183,799103.6%5.25 s5.16 s

Findings:

  • ISL=1024: FP8 prefill still regresses ~20% in throughput, confirming the current default is correct.
  • ISL=4096: Crossover point — FP8 is ~3.6% faster.

Changed files

  • vllm/model_executor/layers/attention/mla_attention.py (modified, +13/-0)

Code Example

WARNING: FP8 KV cache detected but prefill uses BF16 attention. For long-context
workloads (ISL >= 4K), consider setting use_prefill_query_quantization=true in
--attention-config for better prefill performance.

---

The output of `python collect_env.py`
RAW_BUFFERClick to expand / collapse

Context

When using --kv-cache-dtype fp8 with MLA models (e.g. DeepSeek-R1), the prefill FMHA kernel dispatches QkvBfloat16 by default. the FP8 variant (QkvE4m3) requires explicitly setting use_prefill_query_quantization=true in --attention-config, which is not easy discoverable.

Per PR #31195 by @pavanimajety, this was intentionally gated because at short sequence lengths, the BF16 to FP8 cast overhead slight degrades end-to-end performance despite ~1.5x kernel-level improvement.

However, for long-context prefill (128K+), the kernel time dominates and the FP8 path is significantly faster. Our profiling on GB300 (DeepSeek-R1-FP4, PP=4, ISL=128K) shows:

Kernel VariantAvg Latency
fmhaSm103aKernel_QkvBfloat16... (default)287 ms
fmhaSm103aKernel_QkvE4m3... (FP8)225 ms

This is a 1.28x speedup that users silently miss.

Short-Seq Benchmark

To verify whether the cast overhead has improved since the original analysis (Dec 2025), we ran end-to-end benchmarks on GB300 with the following setup:

  • Model: DeepSeek-R1-0528-FP4
  • Parallelism: DP=4 (matching Pavani's PR #31195 config, but we used max-model-len=34816 to also test ISL=4096)
  • KV cache: fp8
  • Platform: GB300
ISLBF16 Throughput (tok/s)FP8 Throughput (tok/s)FP8 / BF16Mean TTFT (BF16)Mean TTFT (FP8)
102415,80312,56279.5%24.8 s38.2 s
409680,86183,799103.6%5.25 s5.16 s

Findings:

  • ISL=1024: FP8 prefill still regresses ~20% in throughput, confirming the current default is correct.
  • ISL=4096: FP8 is ~3.6% faster.

Proposal

Since flipping the default would regress short-context workloads, we propose adding a startup warning log when kv-cache-dtype=fp8 and use_prefill_query_quantization is not explicitly set:

WARNING: FP8 KV cache detected but prefill uses BF16 attention. For long-context
workloads (ISL >= 4K), consider setting use_prefill_query_quantization=true in
--attention-config for better prefill performance.

this makes the hidden flag discoverable without changing default behavior.

cc @benchislett

Report of performance regression

No response

Misc discussion on performance

No response

Your current environment (if you think it is necessary)

The output of `python collect_env.py`

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

TL;DR

To potentially improve prefill performance for long-context workloads with FP8 KV cache, consider setting use_prefill_query_quantization=true in --attention-config.

Guidance

  • For long-context prefill (ISL >= 4K), setting use_prefill_query_quantization=true may provide a significant speedup (up to 1.28x) by using the FP8 path instead of the default BF16 path.
  • To verify the effectiveness of this setting, run end-to-end benchmarks with and without use_prefill_query_quantization=true and compare the throughput and latency results.
  • Be aware that this setting may regress short-context workloads (ISL < 4K), so it's essential to test and evaluate the performance impact for your specific use case.
  • Look for a proposed startup warning log that will be added to notify users about the potential performance improvement for long-context workloads when using FP8 KV cache.

Example

No code snippet is provided as the issue does not require a specific code change, but rather a configuration adjustment.

Notes

The proposed solution only applies to long-context prefill workloads (ISL >= 4K) and may not be beneficial for short-context workloads. The performance impact of setting use_prefill_query_quantization=true should be evaluated on a case-by-case basis.

Recommendation

Apply the workaround by setting use_prefill_query_quantization=true in --attention-config for long-context prefill workloads, as it may provide a significant performance improvement without changing the default behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

vllm - ✅(Solved) Fix [Performance]: Add warning log for FP8 KV cache without prefill query quantization [1 pull requests, 1 participants]