Skip to content

Add user_vision_size in VLM's get_specializations for chunked embedding in vLLM v1 - #996

Merged
Rishin Raj (quic-rishinr) merged 6 commits into
qualcomm:release/v1.21.6from
quic-xiyushi:user_vision_size
Jun 2, 2026
Merged

Rishin Raj (quic-rishinr) merged 6 commits into
qualcomm:release/v1.21.6from
quic-xiyushi:user_vision_size

Conversation

@quic-xiyushi

Copy link
Copy Markdown
Contributor

Background

vLLM v1 introduces chunked prefill with encoder cache, where the model runner processes requests in scheduled token windows. For each window:

  • Overlap detection determines which multimodal embeddings are required

  • Only the relevant sub-tensors are gathered and used

From a QEfficient perspective, this is analogous to:

  • Identifying the image indices for the current chunk, and
  • Gathering the corresponding vision embeddings accordingly

Additionally, v1 eliminates the strict prefill/decode distinction, allowing:

  • Prefill chunks of one request to be interleaved with decode steps of other requests

However, if we reuse the full vision embedding for every prefill chunk, which is what currently QEfficient supports, this:

  • Breaks the intended vLLM v1 design
  • Introduces unnecessary overhead due to repeated large set_buffer calls

Proposal

This PR proposes adding user_vision_size to get_specializations for VLM models, with the following scope:

✅ Apply to all current VLM models
❌ Exclude mllama due to it's cross attention
❌ Exclude molmo (not yet supported in vLLM on QAIC, not sure about how the team is going to support it)

For models onboarded by QEfficient in the future, it should also follow the same way to enable user_vision_size.

Benefits

This change enables:

✅ In vLLM v1, align vision embedding size with prefill sequence length and enable efficient chunked prefill for multimodal inputs
✅ Better alignment with vLLM v1 scheduling model
✅ Reduced overhead from repeated large buffer updates
✅ Easier support for multi-resolution input and multiple images per request

Release Plan

🚫 Not intended for 1.21 release
✅ Target release: 1.22

This draft PR is currently based on the 1.21.6 branch because multi-resolution and multi-frame support for Qwen2.5-VL / Qwen3-VL is only available in that branch, and these features are prerequisites for this change

Next Steps

Once multi-resolution and multi-frame support are available in the QEfficient main branch, this PR will be rebased and migrated to the main branch.

… in vLLM v1

Signed-off-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
@quic-xiyushi
Xiyue Shi (quic-xiyushi) marked this pull request as draft May 18, 2026 18:53
@quic-xiyushi
Xiyue Shi (quic-xiyushi) marked this pull request as ready for review May 22, 2026 15:22
@quic-rishinr Rishin Raj (quic-rishinr) added the 1.22 Release 1.22 candidate label May 25, 2026
mm_tokens_per_image = getattr(self.config, "mm_tokens_per_image", 256)
user_vision_size = compiler_options.pop("vision_size", None)
if user_vision_size:
assert user_vision_size < ctx_len, "vision_size must be less than ctx_len"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: raise an exception instead of assert in all modelling changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done for all models

assert user_vision_size < ctx_len, "vision_size must be less than ctx_len"
vision_size = user_vision_size
else:
vision_size = getattr(self.config, "mm_tokens_per_image", 256)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a warning mm_tokens_per_image will be deprecated in the next release. Having two input arguments for a single input introduces ambiguity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done

f"vision_size={user_vision_size}. Please adjust the image resolution or "
"increase the vision_size."
)
if vision_size * f >= user_vision_size:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Do we want the warning to be raised even if vision_size * f == user_vision_size? I think we should raise the warning only when the user_vision_size is strictly less than the calculated size.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, thanks for pointing it out. Fixed the bug for Qwen2.5-VL, Qwen3-VL, and Qwen3-VL MoE.

…ion_size

Signed-off-by: sanising <sanising@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>

@quic-rishinr Rishin Raj (quic-rishinr) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!! Approved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@quic-rishinr
Rishin Raj (quic-rishinr) merged commit a2266a7 into qualcomm:release/v1.21.6 Jun 2, 2026
4 checks passed
Rishin Raj (quic-rishinr) added a commit that referenced this pull request Jun 2, 2026
… embedding in vLLM v1" (#1022)

Reverts #996

Signed-off-by: Rishin Raj <rishinr@qti.qualcomm.com>
@quic-sanising
Sanidhya Singal (quic-sanising) deleted the user_vision_size branch June 10, 2026 01:13
Rishin Raj (quic-rishinr) pushed a commit to quic-sanising/efficient-transformers that referenced this pull request Jun 10, 2026
…ng in vLLM v1 (qualcomm#996)

vLLM v1 introduces chunked prefill with encoder cache, where the model
runner processes requests in scheduled token windows. For each window:

- Overlap detection determines which multimodal embeddings are required

- Only the relevant sub-tensors are gathered and used

From a QEfficient perspective, this is analogous to:

- Identifying the image indices for the current chunk, and
- Gathering the corresponding vision embeddings accordingly

Additionally, v1 eliminates the strict prefill/decode distinction,
allowing:

- Prefill chunks of one request to be interleaved with decode steps of
other requests

However, if we reuse the full vision embedding for every prefill chunk,
which is what currently QEfficient supports, this:

- Breaks the intended vLLM v1 design
- Introduces unnecessary overhead due to repeated large set_buffer calls

This PR proposes adding user_vision_size to get_specializations for VLM
models, with the following scope:

✅ Apply to all current VLM models
❌ Exclude mllama due to it's cross attention
❌ Exclude molmo (not yet supported in vLLM on QAIC, not sure about how
the team is going to support it)

For models onboarded by QEfficient in the future, it should also follow
the same way to enable user_vision_size.

This change enables:

✅ In vLLM v1, align vision embedding size with prefill sequence length
and enable efficient chunked prefill for multimodal inputs
✅ Better alignment with vLLM v1 scheduling model
✅ Reduced overhead from repeated large buffer updates
✅ Easier support for multi-resolution input and multiple images per
request

🚫 Not intended for 1.21 release
✅ Target release: 1.22

This draft PR is currently based on the 1.21.6 branch because
multi-resolution and multi-frame support for Qwen2.5-VL / Qwen3-VL is
only available in that branch, and these features are prerequisites for
this change

Once multi-resolution and multi-frame support are available in the
QEfficient main branch, this PR will be rebased and migrated to the main
branch.

---------

Signed-off-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Co-authored-by: sanising <sanising@qti.qualcomm.com>
Rishin Raj (quic-rishinr) pushed a commit that referenced this pull request Jun 10, 2026
…ng in vLLM v1 (#1059)

Same as described in #996 

> ### Background
> vLLM v1 introduces chunked prefill with encoder cache, where the model
runner processes requests in scheduled token windows. For each window:
> 
> * Overlap detection determines which multimodal embeddings are
required
> * Only the relevant sub-tensors are gathered and used
> 
> From a QEfficient perspective, this is analogous to:
> 
> * Identifying the image indices for the current chunk, and
> * Gathering the corresponding vision embeddings accordingly
> 
> Additionally, v1 eliminates the strict prefill/decode distinction,
allowing:
> 
> * Prefill chunks of one request to be interleaved with decode steps of
other requests
> 
> However, if we reuse the full vision embedding for every prefill
chunk, which is what currently QEfficient supports, this:
> 
> * Breaks the intended vLLM v1 design
> * Introduces unnecessary overhead due to repeated large set_buffer
calls
> 
> ### Proposal
> This PR proposes adding user_vision_size to get_specializations for
VLM models, with the following scope:
> 
> ✅ Apply to all current VLM models ❌ Exclude mllama due to it's cross
attention ❌ Exclude molmo (not yet supported in vLLM on QAIC, not sure
about how the team is going to support it)
> 
> For models onboarded by QEfficient in the future, it should also
follow the same way to enable user_vision_size.
> 
> ### Benefits
> This change enables:
> 
> ✅ In vLLM v1, align vision embedding size with prefill sequence length
and enable efficient chunked prefill for multimodal inputs ✅ Better
alignment with vLLM v1 scheduling model ✅ Reduced overhead from repeated
large buffer updates ✅ Easier support for multi-resolution input and
multiple images per request
> 
> ### Release Plan
> 🚫 Not intended for 1.21 release ✅ Target release: 1.22
> 
> This draft PR is currently based on the 1.21.6 branch because
multi-resolution and multi-frame support for Qwen2.5-VL / Qwen3-VL is
only available in that branch, and these features are prerequisites for
this change
> 
> ### Next Steps
> Once multi-resolution and multi-frame support are available in the
QEfficient main branch, this PR will be rebased and migrated to the main
branch.

---------

Signed-off-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Co-authored-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Rishin Raj (quic-rishinr) pushed a commit that referenced this pull request Jun 10, 2026
…ng in vLLM v1 (#1059)

Same as described in #996

> ### Background
> vLLM v1 introduces chunked prefill with encoder cache, where the model
runner processes requests in scheduled token windows. For each window:
>
> * Overlap detection determines which multimodal embeddings are
required
> * Only the relevant sub-tensors are gathered and used
>
> From a QEfficient perspective, this is analogous to:
>
> * Identifying the image indices for the current chunk, and
> * Gathering the corresponding vision embeddings accordingly
>
> Additionally, v1 eliminates the strict prefill/decode distinction,
allowing:
>
> * Prefill chunks of one request to be interleaved with decode steps of
other requests
>
> However, if we reuse the full vision embedding for every prefill
chunk, which is what currently QEfficient supports, this:
>
> * Breaks the intended vLLM v1 design
> * Introduces unnecessary overhead due to repeated large set_buffer
calls
>
> ### Proposal
> This PR proposes adding user_vision_size to get_specializations for
VLM models, with the following scope:
>
> ✅ Apply to all current VLM models ❌ Exclude mllama due to it's cross
attention ❌ Exclude molmo (not yet supported in vLLM on QAIC, not sure
about how the team is going to support it)
>
> For models onboarded by QEfficient in the future, it should also
follow the same way to enable user_vision_size.
>
> ### Benefits
> This change enables:
>
> ✅ In vLLM v1, align vision embedding size with prefill sequence length
and enable efficient chunked prefill for multimodal inputs ✅ Better
alignment with vLLM v1 scheduling model ✅ Reduced overhead from repeated
large buffer updates ✅ Easier support for multi-resolution input and
multiple images per request
>
> ### Release Plan
> 🚫 Not intended for 1.21 release ✅ Target release: 1.22
>
> This draft PR is currently based on the 1.21.6 branch because
multi-resolution and multi-frame support for Qwen2.5-VL / Qwen3-VL is
only available in that branch, and these features are prerequisites for
this change
>
> ### Next Steps
> Once multi-resolution and multi-frame support are available in the
QEfficient main branch, this PR will be rebased and migrated to the main
branch.

---------

Signed-off-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Co-authored-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: Rishin Raj <rishinr@qti.qualcomm.com>
Rishin Raj (quic-rishinr) pushed a commit that referenced this pull request Jun 10, 2026
…ng in vLLM v1 (#1059)

Same as described in #996

> ### Background
> vLLM v1 introduces chunked prefill with encoder cache, where the model
runner processes requests in scheduled token windows. For each window:
>
> * Overlap detection determines which multimodal embeddings are
required
> * Only the relevant sub-tensors are gathered and used
>
> From a QEfficient perspective, this is analogous to:
>
> * Identifying the image indices for the current chunk, and
> * Gathering the corresponding vision embeddings accordingly
>
> Additionally, v1 eliminates the strict prefill/decode distinction,
allowing:
>
> * Prefill chunks of one request to be interleaved with decode steps of
other requests
>
> However, if we reuse the full vision embedding for every prefill
chunk, which is what currently QEfficient supports, this:
>
> * Breaks the intended vLLM v1 design
> * Introduces unnecessary overhead due to repeated large set_buffer
calls
>
> ### Proposal
> This PR proposes adding user_vision_size to get_specializations for
VLM models, with the following scope:
>
> ✅ Apply to all current VLM models ❌ Exclude mllama due to it's cross
attention ❌ Exclude molmo (not yet supported in vLLM on QAIC, not sure
about how the team is going to support it)
>
> For models onboarded by QEfficient in the future, it should also
follow the same way to enable user_vision_size.
>
> ### Benefits
> This change enables:
>
> ✅ In vLLM v1, align vision embedding size with prefill sequence length
and enable efficient chunked prefill for multimodal inputs ✅ Better
alignment with vLLM v1 scheduling model ✅ Reduced overhead from repeated
large buffer updates ✅ Easier support for multi-resolution input and
multiple images per request
>
> ### Release Plan
> 🚫 Not intended for 1.21 release ✅ Target release: 1.22
>
> This draft PR is currently based on the 1.21.6 branch because
multi-resolution and multi-frame support for Qwen2.5-VL / Qwen3-VL is
only available in that branch, and these features are prerequisites for
this change
>
> ### Next Steps
> Once multi-resolution and multi-frame support are available in the
QEfficient main branch, this PR will be rebased and migrated to the main
branch.

---------

Signed-off-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Co-authored-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: Rishin Raj <rishinr@qti.qualcomm.com>
Rishin Raj (quic-rishinr) pushed a commit that referenced this pull request Jun 10, 2026
…ng in vLLM v1 (#1059)

Same as described in #996

> ### Background
> vLLM v1 introduces chunked prefill with encoder cache, where the model
runner processes requests in scheduled token windows. For each window:
>
> * Overlap detection determines which multimodal embeddings are
required
> * Only the relevant sub-tensors are gathered and used
>
> From a QEfficient perspective, this is analogous to:
>
> * Identifying the image indices for the current chunk, and
> * Gathering the corresponding vision embeddings accordingly
>
> Additionally, v1 eliminates the strict prefill/decode distinction,
allowing:
>
> * Prefill chunks of one request to be interleaved with decode steps of
other requests
>
> However, if we reuse the full vision embedding for every prefill
chunk, which is what currently QEfficient supports, this:
>
> * Breaks the intended vLLM v1 design
> * Introduces unnecessary overhead due to repeated large set_buffer
calls
>
> ### Proposal
> This PR proposes adding user_vision_size to get_specializations for
VLM models, with the following scope:
>
> ✅ Apply to all current VLM models ❌ Exclude mllama due to it's cross
attention ❌ Exclude molmo (not yet supported in vLLM on QAIC, not sure
about how the team is going to support it)
>
> For models onboarded by QEfficient in the future, it should also
follow the same way to enable user_vision_size.
>
> ### Benefits
> This change enables:
>
> ✅ In vLLM v1, align vision embedding size with prefill sequence length
and enable efficient chunked prefill for multimodal inputs ✅ Better
alignment with vLLM v1 scheduling model ✅ Reduced overhead from repeated
large buffer updates ✅ Easier support for multi-resolution input and
multiple images per request
>
> ### Release Plan
> 🚫 Not intended for 1.21 release ✅ Target release: 1.22
>
> This draft PR is currently based on the 1.21.6 branch because
multi-resolution and multi-frame support for Qwen2.5-VL / Qwen3-VL is
only available in that branch, and these features are prerequisites for
this change
>
> ### Next Steps
> Once multi-resolution and multi-frame support are available in the
QEfficient main branch, this PR will be rebased and migrated to the main
branch.

---------

Signed-off-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: sanising <sanising@qti.qualcomm.com>
Co-authored-by: quic-xiyushi <xiyushi@qti.qualcomm.com>
Signed-off-by: Rishin Raj <rishinr@qti.qualcomm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.22 Release 1.22 candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants