Skip to content

[Attention][4/n] Remove usage of deprecated seq_lens_cpu and num_computed_tokens_cpu CommonAttentionMetadata properties#32073

Open
LucasWilkinson wants to merge 13 commits intovllm-project:mainfrom
neuralmagic:lwilkinson/deprecate-properties
Open

[Attention][4/n] Remove usage of deprecated seq_lens_cpu and num_computed_tokens_cpu CommonAttentionMetadata properties#32073
LucasWilkinson wants to merge 13 commits intovllm-project:mainfrom
neuralmagic:lwilkinson/deprecate-properties

Conversation

@LucasWilkinson
Copy link
Collaborator

@LucasWilkinson LucasWilkinson commented Jan 10, 2026

Continue deprecating seq_lens_cpu and num_computed_tokens_cpu

Don't fully deprecate _seq_lens_cpu due to FlashInfer perf regressions, see: #33771

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 is part of a series to remove deprecated properties from CommonAttentionMetadata, specifically seq_lens_cpu and num_computed_tokens_cpu. The changes correctly replace direct access to these properties by deriving the values from other available metadata, often directly on the GPU to avoid device-to-host synchronization. This refactoring is applied consistently across various components, including attention backends and speculative decoding logic. The changes are correct, improve code clarity, and should lead to better performance. I have not found any issues of high or critical severity.

@mergify
Copy link

mergify bot commented Jan 13, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Jan 13, 2026
@LucasWilkinson LucasWilkinson force-pushed the lwilkinson/deprecate-properties branch from 9a68b38 to a75a466 Compare January 14, 2026 04:46
@mergify mergify bot removed the needs-rebase label Jan 14, 2026
@LucasWilkinson LucasWilkinson marked this pull request as ready for review January 14, 2026 05:47
@LucasWilkinson LucasWilkinson added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 14, 2026
@LucasWilkinson LucasWilkinson force-pushed the lwilkinson/deprecate-properties branch from 8bb7c1f to 1093c10 Compare January 16, 2026 05:08
Copy link
Collaborator

@benchislett benchislett left a comment

Choose a reason for hiding this comment

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

I don't understand why we're moving from .seq_lens_cpu to .seq_lens.cpu(). It feels like this would introduce more DtoH copies than would otherwise be necessary.

@@ -266,6 +266,7 @@ def build(
num_tokens = common_attn_metadata.num_actual_tokens

query_start_loc_cpu = common_attn_metadata.query_start_loc_cpu
seq_lens_cpu = common_attn_metadata.seq_lens.cpu()
Copy link
Collaborator

Choose a reason for hiding this comment

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

move this so it only happens when we has num_prefills > 0

Copy link
Collaborator

@benchislett benchislett left a comment

Choose a reason for hiding this comment

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

Given that this impacts only rare cases and will eventually be phased out entirely, I'm happy with this change. Just needs one line moved to avoid synchronizing on the decode codepath when it's not needed

@mergify
Copy link

mergify bot commented Jan 21, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Jan 21, 2026
@LucasWilkinson LucasWilkinson force-pushed the lwilkinson/deprecate-properties branch from 9b1ea04 to 36f2a9d Compare January 23, 2026 02:40
@mergify mergify bot removed the needs-rebase label Jan 23, 2026
@LucasWilkinson LucasWilkinson added the ready-run-all-tests Trigger CI with all tests for wide-ranging PRs label Jan 23, 2026
@LucasWilkinson LucasWilkinson force-pushed the lwilkinson/deprecate-properties branch 2 times, most recently from aa13fd0 to 27a5618 Compare January 25, 2026 05:51
@mergify
Copy link

mergify bot commented Jan 26, 2026

Hi @LucasWilkinson, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

@LucasWilkinson LucasWilkinson force-pushed the lwilkinson/deprecate-properties branch from 059a956 to b40c717 Compare February 4, 2026 02:49
@LucasWilkinson LucasWilkinson removed the ready-run-all-tests Trigger CI with all tests for wide-ranging PRs label Feb 4, 2026
@mergify
Copy link

mergify bot commented Feb 4, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Feb 4, 2026
LucasWilkinson and others added 12 commits February 11, 2026 23:18
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
@LucasWilkinson LucasWilkinson force-pushed the lwilkinson/deprecate-properties branch from b40c717 to e854658 Compare February 11, 2026 23:19
@mergify mergify bot removed the needs-rebase label Feb 11, 2026
@mergify
Copy link

mergify bot commented Feb 11, 2026

Hi @LucasWilkinson, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed speculative-decoding v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants