Skip to content

Conversation

@sarckk
Copy link
Collaborator

@sarckk sarckk commented Jul 25, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

To support YOCO prefill skip for cross-decoder layers in #19719, we need to propagate logits_indices that has been padded to align with cudagraph captured batch sizes as well as size of the original logits_indices.

To do this, we can identify which layers are eligible, store these layer names in truncated_prefill_eligible_layers and dynamically build a subclass of attention metadata for these layers that inherit from the original attn metadata class but adds two new fields: logits_indices_padded and num_logits_indices.

Test Plan

unit test:

pytest tests/v1/e2e/test_kv_sharing_fast_prefill.py::test_kv_sharing_fast_prefill

run with new flag:

vllm serve google/gemma-3n-E2B-it --disable-log-requests --kv-sharing-fast-prefill

Test Result

Unit tests pass

See new warning msg:

WARNING 07-29 14:06:05 [config.py:1739] --kv-sharing-fast-prefill is currently work in progress and not functional yet (i.e. no prefill savings)

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the v1 label Jul 25, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an option to compute and propagate padded logits_indices to the model's forward pass, controlled by the VLLM_COMPUTE_PADDED_LOGITS_INDICES environment variable. The changes span environment variable handling, forward context management, and the GPU model runner logic. My review found a critical typo in the environment variable name that would prevent the feature from working, and a potential IndexError when handling an empty logits_indices tensor. Both issues include code suggestions for fixes.

sarckk added 2 commits July 24, 2025 23:11
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

I'm thinking of adding the final flag enable_kv_sharing_truncated_prefill to this PR instead of introducing a temporary environment variable. We can add a warning to show that this feature is WIP.

I think a better granularity to split PRs is to compute a real gen_indices_padded in this PR.
Then you can test it with Gemma-3n which has YOCO. Can you add a simple test based on this model and update it gradually during implementing more small PRs? For this PR, I think we can run the model as normal, and returns a tensor with

second_hidden_states =  hidden_states[gen_indices_padded],
second_residual = residual[gen_indices_padded],
hidden_states = torch.randn()
residual = torch.randn()
hidden_states[gen_indices] = second_hidden_states[:num_gen_indices]
residual[gen_indices] = second_residual[:num_gen_indices]

@sarckk sarckk marked this pull request as draft July 28, 2025 16:27
@mergify mergify bot added the frontend label Jul 28, 2025
@sarckk sarckk changed the title Add option to propagate padded logits_indices to model Support expanded attention metadata for YOCO cross-decoder layers Jul 28, 2025
…ndices

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
sarckk added 3 commits July 28, 2025 12:11
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

Thanks for your update. Do we need to pass the args via LLM class? Other comments are some small nits.

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
@sarckk
Copy link
Collaborator Author

sarckk commented Jul 29, 2025

Do we need to pass the args via LLM class?

You're right, we don't need it. Updated to address comments.

Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you very much.

@heheda12345 heheda12345 enabled auto-merge (squash) July 29, 2025 20:35
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 29, 2025
@sarckk sarckk changed the title Override attention metadata for fast prefill for KV sharing Override attention metadata for fast prefill in some KV sharing setups Jul 29, 2025
@vllm-bot vllm-bot merged commit ad51030 into vllm-project:main Jul 30, 2025
83 of 85 checks passed
liuyumoye pushed a commit to liuyumoye/vllm that referenced this pull request Jul 31, 2025
@DarkLight1337
Copy link
Member

test_kv_sharing_fast_prefill is failing on main, can you look into it?

@sarckk
Copy link
Collaborator Author

sarckk commented Jul 31, 2025

test_kv_sharing_fast_prefill is failing on main, can you look into it?

taking a look now (EDIT: seems test is flaky, partial fix in #22038)

vadiklyutiy pushed a commit to CentML/vllm that referenced this pull request Aug 5, 2025
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
vllm-project#21590)

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: x22x22 <wadeking@qq.com>
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
vllm-project#21590)

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
noamgat pushed a commit to noamgat/vllm that referenced this pull request Aug 9, 2025
vllm-project#21590)

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Noam Gat <noamgat@gmail.com>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
vllm-project#21590)

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Paul Pak <paulpak58@gmail.com>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
vllm-project#21590)

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Diego-Castan <diego.castan@ibm.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants