Skip to content

[WIP][Kernel] Enable GDN batch-invariant prefix caching - #55868

Open
quanliu1991 wants to merge 5 commits into
vllm-project:mainfrom
quanliu1991:gdn-bi-prefix-cache-align
Open

quanliu1991 wants to merge 5 commits into
vllm-project:mainfrom
quanliu1991:gdn-bi-prefix-cache-align

Conversation

@quanliu1991

Copy link
Copy Markdown
Contributor

Purpose

Enable VLLM_BATCH_INVARIANT=1 together with prefix caching on Qwen GDN hybrid models.

Today this fails at scheduler init (NotImplementedError: ... does not yet support Mamba cache alignment) because prefix cache puts GDN into mamba align mode while BIC needs a 64-token FLA grid.

This PR:

Related: #49827, #45819, #48613, #42960.

Test Plan

Set VLLM_GDN_PC_TEST_MODEL to a GDN checkpoint (e.g. Qwen3.5-35B-A3B). Tests skip without it.

export VLLM_BATCH_INVARIANT=1
export VLLM_GDN_PC_TEST_MODEL=/path/to/Qwen3.5-35B-A3B
export VLLM_TP_SIZE=2
export VLLM_ENABLE_V1_MULTIPROCESSING=0
pytest tests/v1/determinism/test_gdn_prefix_cache_batch_invariant.py -s -v

TTFT (start vllm serve with BI=1, then PC on / off):

BASE_URL=http://127.0.0.1:8000 TAG=on \
  bash tests/v1/determinism/run_gdn_prefix_cache_bench.sh

Hardware for the numbers below: 2× L20, TP=2, Qwen3.5-35B-A3B, vllm-openai:v0.28.0 overlay with the same changes.

Test Result

Before: engine does not start (NotImplementedError above).

After (bitwise): engine starts, block_size 1056 → 1088, alignment=1088. Same-path hit BS=1 vs BS=N is bitwise identical (prefix-1100 real hit; ragged-200 floors to 0). RESULT: PASS.

After (TTFT, shared 2000-token prefix, BI=1):

prefix cache c mean TTFT (ms) median TTFT (ms) mean TPOT (ms)
off 1 261 262 18.7
on 1 210 203 18.5
off 16 2154 2020 145.8
on 16 1670 1469 153.3

c=1 TTFT −19%, c=16 median TTFT −27%. TPOT unchanged. 2000 tokens only skip the first 1088-token page, so this is not decode-only TTFT.

quanliu1991 and others added 3 commits September 8, 2026 16:39
…vllm-project#45819).

Temporary port so CI can exercise Qwen GDN under VLLM_BATCH_INVARIANT.
Drop this commit when vllm-project#49827 (and the GDN BIC gate from vllm-project#45819) land on
main. Prefix-cache align mode still raises; the next commit replaces that
mutex with a shared FLA/mamba grid.

Co-authored-by: Charlie Masters <charlie.masters@hcompany.ai>
Co-authored-by: finetunej <82650881+finetunej@users.noreply.github.com>
Co-authored-by: Yuval Luria <yluria@redhat.com>
Signed-off-by: quanliu <18646313696@163.com>
Replace the BI vs align-mode mutex with lcm(FLA_CHUNK_SIZE, mamba_state_block_size),
floor prefix-cache hits onto that grid, and round hybrid block_size up to a
64-multiple so short prefixes can reuse.

Signed-off-by: quanliu <18646313696@163.com>
Manual GPU tests are skipped unless VLLM_GDN_PC_TEST_MODEL is set so default
CI does not load a 35B GDN checkpoint.

Signed-off-by: quanliu <18646313696@163.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@quanliu1991 quanliu1991 changed the title [WIP][Kernel] Enable GDN batch-invariant prefix caching (depends on #49827) [WIP][Kernel] Enable GDN batch-invariant prefix caching Sep 8, 2026
@quanliu1991

Copy link
Copy Markdown
Contributor Author

@claude review

Annotate step_logprobs, assert optional GDN conv metadata before use, and
match ruff-format wrapping so the manual-stage hooks pass.

Signed-off-by: quanliu <18646313696@163.com>
Verified locally with ruff format/check and tools/pre_commit/mypy.py 3.12 on
the changed files before pushing.

Signed-off-by: quanliu <18646313696@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant