Skip to content

fix: use vision_size for Gemma4 specializations to support chunked embedding in vLLM v1 (#1135) - #1146

Merged
Rishin Raj (quic-rishinr) merged 1 commit into
qualcomm:release/v1.22.0from
quic-gthiruko:cherry-pick/vision-size-gemma4-v1.22.0
Jul 6, 2026
Merged

Rishin Raj (quic-rishinr) merged 1 commit into
qualcomm:release/v1.22.0from
quic-gthiruko:cherry-pick/vision-size-gemma4-v1.22.0

Conversation

@quic-gthiruko

Copy link
Copy Markdown
Contributor

Cherry-pick of commit 1f16d42 (PR #1135) from main onto release/v1.22.0.

Summary

To keep Gemma4 consistent with the other VLMs, use vision_size instead of mm_tokens_per_image for the number of vision tokens when building specializations. This allows chunked embedding in vLLM v1.

Follows the same pattern introduced in PR #1059 (quic-sanising) for gemma3, llava, internvl, qwen2_5_vl, etc.

Changes

  • Pop vision_size from compiler_options (same as all other VLMs)
  • If user provides vision_size, validate it (vision_size < ctx_len) and use it as the vision token count in specializations
  • Otherwise fall back to mm_tokens_per_image (default 256 for Gemma4)
  • Replace mm_tokens_per_image with vision_size in build_lang_prefill_spec and build_lang_decode_spec

Testing

Tested with vLLM flow for the following models:

  • google/gemma-4-E2B-it & google/gemma-4-E4B-it → 2 QPC (Dense)
  • google/gemma-4-26B-A4B-it → 3 QPC (MoE)

@quic-gthiruko

Copy link
Copy Markdown
Contributor Author

Tested with vLLM flow for the following models:

server_logs_gemma-4-26B-A4B-it_text_vision
server_logs_gemma-4-31B-it_text_vision
server_logs_gemma-4-E2B-it_text_vision
server_logs_gemma-4-E4B-it_text_vision

Corresponding logs files have been attached to jira.

…bedding in vLLM v1 (qualcomm#1135)

## Summary

To keep Gemma4 consistent with the other VLMs, use `vision_size` instead
of `mm_tokens_per_image` for the number of vision tokens when building
specializations. This allows chunked embedding in vLLM v1.

Follows the same pattern introduced in PR qualcomm#1059 (quic-sanising) for
gemma3, llava, internvl, qwen2_5_vl, etc.

## Changes

- Pop `vision_size` from `compiler_options` (same as all other VLMs)
- If user provides `vision_size`, validate it (`vision_size < ctx_len`)
and use it as the vision token count in specializations
- Otherwise fall back to `mm_tokens_per_image` (default 256 for Gemma4)
- Replace `mm_tokens_per_image` with `vision_size` in
`build_lang_prefill_spec` and `build_lang_decode_spec`

## Testing

Tested with vLLM flow for the following models:
- google/gemma-4-E2B-it & google/gemma-4-E4B-it → 2 QPC (Dense)
- google/gemma-4-26B-A4B-it → 3 QPC (MoE)

Signed-off-by: Gokkulnath Thirukonda Srinivasan
<gthiruko@qti.qualcomm.com>

---------

Signed-off-by: Gokkulnath Thirukonda Srinivasan <gthiruko@qti.qualcomm.com>
@quic-rishinr
Rishin Raj (quic-rishinr) force-pushed the cherry-pick/vision-size-gemma4-v1.22.0 branch from ae674c3 to 436763b Compare July 6, 2026 05:03
@quic-rishinr
Rishin Raj (quic-rishinr) merged commit 5b7fa7a into qualcomm:release/v1.22.0 Jul 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants