Fix Transformers backend FP8 MoE and remove some boilerplate - #46820
Merged
Conversation
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
hmellor
requested review from
luccafong,
patrickvonplaten,
sighingnow,
tomeras91 and
vadiklyutiy
as code owners
June 26, 2026 10:23
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Member
Author
|
@abmfy could you please take a look at this from an EPLB perspective? I think my change should be a nice cleanup but you are more familiar with the mechanism |
Isotr0py
approved these changes
Jun 26, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
WindChimeRan
pushed a commit
to WindChimeRan/vllm
that referenced
this pull request
Jun 27, 2026
…oject#46820) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
1 task
Contributor
|
#46948 is caused by this PR, preventing Gemma4 Unified models from loading at all. |
Member
Author
|
Thanks for the report, I will forward fix this |
Member
Author
|
Fix is in #46956 |
jeejeelee
pushed a commit
that referenced
this pull request
Jun 29, 2026
wincent8
pushed a commit
to wincent8/vllm
that referenced
this pull request
Jun 29, 2026
…oject#46820) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
wincent8
pushed a commit
to wincent8/vllm
that referenced
this pull request
Jun 29, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
rjrock
pushed a commit
to rjrock/vllm
that referenced
this pull request
Jul 1, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Deepali1999
pushed a commit
to Deepali1999/vllm-cpu
that referenced
this pull request
Jul 7, 2026
## Summary ### 1. CVE-2026-41523: Replace assert with proper exceptions in pooling Cherry-pick fix for [CVE-2026-41523](GHSA-q8gq-377p-jq3r) (GHSA-q8gq-377p-jq3r, HIGH severity, CVSS 7.5). An `assert`-based security check in vLLM's activation function loading can be bypassed when Python runs in optimized mode (`python -O` or `PYTHONOPTIMIZE=1`), allowing arbitrary code execution via a malicious HuggingFace model. **Changes:** - `vllm/model_executor/layers/pooler/activations.py`: Replace `assert` with `ValueError` for activation function security check; replace `assert callable(act_fn)` with `TypeError` in `resolve_classifier_act_fn()` - `vllm/pooling_params.py`: Replace 3 `assert` statements with `ValueError` in `_merge_default_parameters()`, `_verify_valid_parameters()`, and `__post_init__()` **Upstream fix:** vllm-project/vllm@b3c7ffc #### Cherry-pick conflicts & resolution A direct `git cherry-pick 7fa2c781da` produced two conflicts, so the fix was applied manually: 1. **`vllm/model_executor/layers/pooler.py`** — **modify/delete conflict**: The upstream commit patched `get_cross_encoder_activation_function()` in this file, but it no longer exists on nm-vllm-ent `main`. The code was refactored into `vllm/model_executor/layers/pooler/activations.py` (function renamed to `get_act_fn()`). - **Resolution:** Applied the same `assert` → `if not … raise ValueError` fix to `vllm/model_executor/layers/pooler/activations.py` at the equivalent location. 2. **`vllm/pooling_params.py`** — **content conflict**: Surrounding code differences between upstream and nm-vllm-ent (e.g. different error message formatting, `self.task!r` quoting style). - **Resolution:** Manually replaced all 3 `assert` statements with proper `if … raise ValueError(...)`: - `_merge_default_parameters()`: `assert self.task is not None` - `_verify_valid_parameters()`: `assert self.task is not None` - `__post_init__()`: `assert self.output_kind == RequestOutputKind.FINAL_ONLY` 3. **`v1/pool/metadata.py`** — **not applicable**: The upstream commit also converted asserts in this file, but those are internal consistency checks (list length invariants, initialization guards), not security boundaries exploitable via malicious model configs. Skipped as not security-relevant. --- ### 2. INFERENG-8366: Auto-raise max_num_batched_tokens for prefix-LM multimodal models Cherry-pick upstream PR [#43051](vllm-project/vllm#43051) (commit `84e351555a`). Fixes Gemma4 12B-it crash on A100 where `max_tokens_per_mm_item` (2496) exceeds the default `max_num_batched_tokens` (2048) when `disable_chunked_mm_input` is forced `True` for prefix-LM multimodal models. The fix adds logic to `EngineArgs` to automatically detect when a prefix-LM multimodal model's largest modality item exceeds `max_num_batched_tokens`, and bumps it up to fit. **Changes:** - `vllm/engine/arg_utils.py`: Add `_get_min_mm_batched_tokens()` static method and auto-raise logic in `_set_default_max_num_seqs_and_batched_tokens_args()` - `tests/v1/engine/test_engine_args.py`: Add regression test `test_mm_prefix_lm_raises_batched_tokens_floor()` **JIRA:** [INFERENG-8366](https://redhat.atlassian.net/browse/INFERENG-8366) **Upstream PR:** vllm-project/vllm#43051 --- ### 3. INFERENG-8290: Bump tilelang 0.1.9 -> 0.1.11 tilelang 0.1.10+ includes PR [tile-ai/tilelang#2135](tile-ai/tilelang#2135) which disables Cython PEP-489 multi-phase init, fixing the `_xxsubinterpreters` `ModuleNotFoundError` on UBI Python 3.12 that crashes DeepSeek V4. **Changes:** - `requirements/cuda.txt`: Bump `tilelang` from `0.1.9` to `0.1.11` **JIRA:** [INFERENG-8290](https://redhat.atlassian.net/browse/INFERENG-8290) --- ### 4. Add recursive_replace_linear for Gemma4 vision tower quantization The Gemma4 Unified cherry-pick (`a248b45d05`) introduced calls to `recursive_replace_linear()` for replacing vision/audio tower `nn.Linear` layers with vLLM-native quantized equivalents. The function definition and import were missing, causing `NameError` on model load for all Gemma4 and Gemma4 FP8 models. Ports the function from upstream PR [#46820](vllm-project/vllm#46820) into `transformers/utils.py` and adds the import in `gemma4_mm.py`. **Changes:** - `vllm/model_executor/models/transformers/utils.py`: Add `recursive_replace_linear()` function - `vllm/model_executor/models/gemma4_mm.py`: Add missing import --- ## Test plan - [x] Verify `pre-commit run --all-files` passes - [x] Verify pooling/cross-encoder models still work (CVE fix) - [ ] Verify that loading a model with a non-`torch.nn.modules.*` activation function raises `ValueError` - [ ] Verify passing a non-callable to `resolve_classifier_act_fn` raises `TypeError` - [x] Verify Gemma4 12B-it starts successfully on A100 with default `max_num_batched_tokens` - [ ] Verify DeepSeek V4 loads without `_xxsubinterpreters` crash (tilelang bump) - [x] Verify Gemma4 / Gemma4 FP8 model load succeeds without `NameError` on `recursive_replace_linear` - [x] Run accept-sync CI with `google/gemma-4-12B-it` in model list [INFERENG-8366]: https://redhat.atlassian.net/browse/INFERENG-8366?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
noooop
pushed a commit
to noooop/vllm
that referenced
this pull request
Jul 9, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: wang.yuqi <yuqi.wang@daocloud.io>
Dao007forever
pushed a commit
to Dao007forever/vllm
that referenced
this pull request
Jul 18, 2026
…oject#46820) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Dao007forever
pushed a commit
to Dao007forever/vllm
that referenced
this pull request
Jul 18, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
philippesic
pushed a commit
to philippesic/vllm-semantic-cache
that referenced
this pull request
Jul 19, 2026
…oject#46820) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
philippesic
pushed a commit
to philippesic/vllm-semantic-cache
that referenced
this pull request
Jul 19, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
plasticchris
pushed a commit
to plasticchris/vllm
that referenced
this pull request
Jul 20, 2026
…oject#46820) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
plasticchris
pushed a commit
to plasticchris/vllm
that referenced
this pull request
Jul 20, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Transformers backend was eagerly storing
expert_weightsbefore quantization. This meant that when using FP8 models a stale reference to the unquantized expert weights was kept and the memory usage is higher than expected.This PR fixes the issue by removing the eager population of
self.expert_weightsand removing theset_eplb_statemethod now that an implementation has been added toMixtureOfExperts.self.expert_weightsis only set inset_eplb_stateso it's not necessary to instantiate an empty list in every model, we can just set it to an empty list at the start ofset_eplb_state.This PR removes
self.expert_weights = []from all models.This PR also updates the type hint of
MixtureOfExperts.moe_layerstoIterable[MoERunner]which is more specific and correct.