Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
dc3ef00 to
bce74cb
Compare
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Add compact-stride validation to the mixed-head split path so non-compact mixed pages are rejected instead of silently misread. Drop the single-side divisibility check: it is implied by the compact check for dims > 1, and it falsely rejected benign strides on size-1 dims that never affect addressing. Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 # Conflicts: # vllm/v1/worker/gpu/attn_utils.py # vllm/v1/worker/gpu_model_runner.py Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 # Conflicts: # vllm/v1/worker/gpu_model_runner.py Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 # Conflicts: # vllm/v1/worker/gpu_model_runner.py Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com> # Conflicts: # vllm/v1/worker/gpu_model_runner.py
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Route continuation-only prefills through native paged NVFP4 attention and preserve raw-KV FA2 output for first chunks. Keep ALiBi on the legacy dequant scratch path and leave unsupported geometries on their existing fallback. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com> # Conflicts: # vllm/utils/torch_utils.py # vllm/v1/attention/backends/flashinfer.py
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Preserve the shared KV cache shape and stride helper while incorporating upstream TurboQuant cache-mode handling. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
The NVFP4 4-over-6 scale search only exists in the trtllm-gen native store kernel, which is compiled for SM100/SM120 only. On other devices this backend stores KV through the FlashInfer slot-mapping writer, which always records plain max/6 scales, so an "nvfp4_4over6" request was silently served as plain "nvfp4". Gate the scale-search variants on trtllm-gen availability in supports_kv_cache_dtype so backend selection reports them as unsupported, and raise in FlashInferImpl when the native update path is unavailable at runtime. Plain "nvfp4" keeps running on pre-SM100 devices. Also match the V2 attention layout helper on the NVFP4 dtype prefix so mixed head-size shapes stay consistent with the KV cache spec. Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
b9f8b0e to
e505363
Compare
3bd2de7 to
3e70b1f
Compare
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…-kv-cache-20260624 # Conflicts: # tests/v1/worker/test_attn_utils.py Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…acts Upstream removed the module-level get_kv_cache_layout() (the impl reads its layout from cache_config through the kv_cache_layout property) and added a sinks check to the FA2 mixed-prefill gate; the partial impl mocks and layout patch points here predated both. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: lesj0610 <lesj0610@godoiksan.org> Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 # Conflicts: # vllm/v1/attention/backends/flashinfer.py Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 # Conflicts: # vllm/v1/attention/backends/flashinfer.py Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-cache-20260624 Three places needed a decision: - The forward docstring: keep upstream's note that key/value are None for a KV-sharing decoder layer, and this branch's description of the NVFP4 cache layouts. Both describe the same signature. - The DCP prefill call: keep this branch's dcp_kv_cache, which selects between the packed NVFP4 views and the regular tuple, with upstream's tightened key/value slice bound of num_actual_tokens. - Upstream now types key/value as optional for KV-sharing layers. The NVFP4 fa2 prefill path indexes them directly, so it fails the same way DCP prefill does and now raises NotImplementedError instead of a type error. Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Purpose
I wanted to use
--kv-cache-dtype nvfp4on my RTX 3090 setup, but it was only usable on the SM100 native path. This PR makes the pre-SM100 path use FlashInfer's slot-mapping API for NVFP4 paged KV appends, so Ampere and Hopper systems can use the smaller NVFP4 KV cache without relying on the Blackwell-only path.The main benefit is KV cache capacity. On the tested RTX 3090 setup, NVFP4 gives about 3x more KV cache tokens, with quality on par with the auto dtype in the MRCR runs below. The tables compare against auto and TurboQuant 4bit_nc; TurboQuant did not start for the Gemma4 models on this setup.
AI assistance: Codex and Claude Fable 5 were used during implementation and PR preparation; the submitter reviewed the changes.
Changes
nvfp4_quantize_append_paged_kv_cache_with_slot_mappingfor pre-SM100 NVFP4 KV cache updates.flash_attn_varlen_func. If the FlashInfer paged-dequant helper is unavailable, this path falls back.nvfp4branch, which that fix did not cover.KVQuantMode.NONEdefault to the unquantizedautolayout for shape calculation; TQ specs still use a packed layout, so they preserve the configuredturboquant_*cache dtype.Dependencies
No FlashInfer version bump is needed. Every API this PR uses is present in the
release vLLM already pins (
flashinfer-python==0.6.17,flashinfer-cubin==0.6.17inrequirements/cuda.txt):nvfp4_quantize_append_paged_kv_cache_with_slot_mapping— required, drives the pre-SM100 NVFP4 paged KV append.nvfp4_kv_dequantize_paged— optional; enables the FA2 prefill fast path. That path falls back when the helper is unavailable.Verified against the pinned release:
Gemma4 selector support: "[Model] Allow Gemma4 to use FlashInfer when FA4 is unavailable" allows Gemma4 to choose FlashInfer when FA4 is
unavailable.
Test Plan
Unit tests:
pytest tests/kernels/attention/test_flashinfer.py -q -k nvfp4 pytest tests/kernels/attention/test_flashinfer.py -q -k "q_dtype or q_quantization_disable" pytest tests/kernels/attention/test_flashinfer.py -q -k fa2_prefill_reservation pytest tests/v1/worker/test_attn_utils.py -q pytest tests/quantization/test_turboquant.py -q -k metadata_builderStatic checks:
Runtime smoke on RTX 3090 (SM86): Qwen3.6-27B GPTQ int4, TP=1,
--kv-cache-dtype nvfp4, withoutdisable_flashinfer_q_quantization.Benchmarks on RTX 3090 x 2, TP=2: KV cache capacity, MRCR quality (30 samples, 32K context), and
vllm bench serve(random 8K prompts, output length 64, 16 requests,max_num_seqs=64).Test Result
Unit tests on the current head after merging latest main: 23 passed (nvfp4), 5 passed (q dtype), 3 passed (reservation), 6 passed (attn_utils), 2 passed (TurboQuant metadata builder). Static checks passed.
Runtime smoke: resolved query dtypes logged as
prefill=torch.bfloat16,decode=torch.bfloat16,decode_backend=flashinfer-native; server ready;/v1/completionsreturned 200 OK.The TQ cache-dtype regression from the vllm-project#42890 merge is covered by
test_turboquant_spec_preserves_configured_cache_dtype_for_shape, which routes throughTurboQuantAttentionBackend.get_kv_cache_shape()and verifies the configuredturboquant_4bit_ncdtype is not converted toautoduring cache-shape calculation.The benchmarks below were measured on this branch before the latest main merge; the attention code paths are semantically unchanged by the merge. Gemma4 rows were measured with the Gemma4 FlashInfer selector change (vllm-project#47547) stacked locally.
KV Cache Capacity
* Gemma4 TQ 4bit_nc did not start on this setup.
Quality — MRCR
30 samples, 32K context.
NVFP4 was on par with auto in the Qwen runs. The Gemma4 results are from 30-sample runs with some metric movement: Gemma4-26B-A4B shows a higher overall match ratio (+0.06) and a lower n8 match ratio (-0.03) in this run.
Serving Benchmark
vllm bench serve, random 8K prompts, output length 64, 16 requests,max_num_seqs=64.Notes
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.