Skip to content

Make the Transformers modeling backend as fast as native vLLM - #47187

Merged
hmellor merged 37 commits into
vllm-project:mainfrom
hmellor:transformers-fusions
Jul 6, 2026
Merged

hmellor merged 37 commits into
vllm-project:mainfrom
hmellor:transformers-fusions

Conversation

@hmellor

@hmellor hmellor commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Introduction

For the Transformers modelling backend this PR:

  • enables the use of MergedColumnParallelLinear and QKVParallelLinear
  • fully leverages MoERunner to enable:
    • async shared experts
    • DBO
    • Sequence parallel
  • tp_plan becomes optional because the fusion passes know correct the TP orientations of the resulting fusions
  • pp_plan becomes optional because vLLM now checks for the nn.ModuleList in the text model and splits that
  • Fixes a TP bug with OLMoE style models by adding gather/scatter around full width norms

It does this by using torch.fx to detect patterns in the original model and then editing the model instance in place using ast so nothing gets baked in for downstream torch.compile calls.

Logs indicate when and where these graph manipulations are happening, e.g.:

INFO [moe.py:281] Fused: gate + experts (Qwen3MoeSparseMoeBlock) -> FusedMoE (internal routing)
...
INFO [base.py:505] Fused: q_proj + k_proj + v_proj (self_attn: Qwen3MoeAttention) -> qkv_proj (QKVParallelLinear)
INFO [base.py:505] Fused: q_norm (Qwen3MoeRMSNorm) -> RMSNorm (CustomOp)
INFO [base.py:505] Fused: k_norm (Qwen3MoeRMSNorm) -> RMSNorm (CustomOp)
INFO [base.py:505] Fused: input_layernorm (Qwen3MoeRMSNorm) -> RMSNorm (CustomOp)
INFO [base.py:505] Fused: post_attention_layernorm (Qwen3MoeRMSNorm) -> RMSNorm (CustomOp)
INFO [base.py:505] Fused: norm (Qwen3MoeRMSNorm) -> RMSNorm (CustomOp)

Benchmarks

The Transformers modelling backend is now as fast or faster than vLLM implementations for dense/sliding attention and MoE models across all concurrencies tested.

Hybrid full/sliding attention

Run on 1xH100

vllm serve google/gemma-2-2b-it
image

FP8 MoE

Run on 8xH100

vllm serve Qwen/Qwen3-235B-A22B-Instruct-2507-FP8 --enable-expert-parallel --tensor-parallel-size 8
image

Future work

  • Identify low-medium usage models which can be migrated to the Transformers modelling backend to reduce maintenance burden for vLLM
  • MLA

hmellor added 5 commits June 30, 2026 15:41
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>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
hmellor added 2 commits July 1, 2026 09:15
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@mergify mergify Bot added the ci/build label Jul 1, 2026
hmellor added 4 commits July 1, 2026 13:47
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 hmellor changed the title Enable merged linear layers in the Transformers modeling backend Make the Transformers modeling backend as fast as native vLLM Jul 1, 2026
hmellor added 4 commits July 1, 2026 19:52
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>
@mergify

mergify Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--47187.org.readthedocs.build/en/47187/

@mergify mergify Bot added the documentation Improvements or additions to documentation label Jul 2, 2026
hmellor added 8 commits July 2, 2026 10:30
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>
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>

@Isotr0py Isotr0py left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great idea about layer fusion through fx graph!

Comment thread tests/models/transformers/fusers/test_linear.py
Comment thread vllm/model_executor/models/transformers/fusers/qkv.py
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@hmellor
hmellor marked this pull request as ready for review July 3, 2026 13:05

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@Isotr0py Isotr0py added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 4, 2026
mergify Bot and others added 4 commits July 4, 2026 02:28
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@hmellor
hmellor merged commit 5bce653 into vllm-project:main Jul 6, 2026
81 checks passed
@hmellor
hmellor deleted the transformers-fusions branch July 6, 2026 15:59
NickLucche pushed a commit to NickLucche/vllm that referenced this pull request Jul 15, 2026
…roject#47187)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
philippesic pushed a commit to philippesic/vllm-semantic-cache that referenced this pull request Jul 19, 2026
…roject#47187)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build documentation Improvements or additions to documentation ready ONLY add when PR is ready to merge/full CI is needed

Projects

Development

Successfully merging this pull request may close these issues.

2 participants