AIToday
Large Language ModelsHugging Face BlogPublished: Jul 9, 2026, 01:00 JST2 min read

vLLM transformers backend now matches hand-optimized speeds

vLLM transformers backend now matches hand-optimized speeds

Key takeaway

  • The transformers library's modeling backend for vLLM can now match the inference speed of custom vLLM implementations through dynamic layer fusions applied at runtime.

  • This means model authors can deploy transformers models directly in vLLM without writing custom optimization code, cutting development time and letting new models reach production-grade performance immediately.

3 Key Points

  1. What happened

    The transformers modeling backend for vLLM now achieves inference speed comparable to vLLM's custom hand-written implementations across multiple Qwen3 model sizes—from 4B dense models to 235B Mixture-of-Experts models—by using torch.fx and abstract syntax tree manipulation to apply layer fusions at runtime.

  2. Why it matters

    Model authors no longer need to write separate optimized code for vLLM; they can use their transformers implementations directly and automatically get native vLLM inference performance. This reduces duplicate engineering work and makes it easier for new models to reach production speed without custom porting.

  3. What to watch

    Models using linear attention are not currently supported but will be soon. The full optimization process uses torch.fx for static analysis to identify fusible patterns, then rewrites operations to map to vLLM's ultra-optimized kernels (MergedColumnParallelLinear, QKVParallelLinear, and expert-parallel kernels).

Ask the AI about this article →

Context & Analysis

The transformers library has established itself as the reference modeling standard for machine learning, supporting 450+ architectures through consistent APIs. Previously, achieving ultra-fast vLLM inference required model authors to write custom vLLM implementations in parallel with their transformers code—a duplicative and time-consuming process. The transformers backend for vLLM, integrated last year, allowed transformers models to run inside vLLM without porting, but performance still lagged because the focus was primarily on optimizing attention operations.

The new iteration solves this gap by dynamically applying inference-specific layer fusions at runtime, using torch.fx and abstract syntax tree manipulation to identify and rewrite fusible patterns. Testing across three different Qwen3 models—a 4B dense model, a 32B dense model with tensor parallelism, and a 235B Mixture-of-Experts model with data and expert parallelism—showed that the transformers backend now meets or exceeds the throughput of hand-written native vLLM implementations. This means a model author needs to integrate their architecture only once (in transformers) and can immediately leverage vLLM's full inference optimization suite without writing a single line of custom code.

The transformation is significant for the ML ecosystem: it lowers the barrier for new models to reach production-grade serving speed, reduces engineering duplication, and lets model code be reused across training and inference workflows. The one current limitation is that models using linear attention are not yet supported, though the article indicates this gap will be closed soon.

FAQ

How do I use the transformers backend in vLLM?
Add the flag --model-impl transformers to your vllm serve command, and it composes with standard parallelism options. For example: vllm serve Qwen/Qwen3-4B --model-impl transformers for a single-GPU model, or --tensor-parallel-size 2 for multi-GPU tensor parallelism.
What optimization techniques does the transformers backend use?
It uses torch.fx to perform static analysis on the model graph, searching for known optimization patterns, and then uses abstract syntax tree (ast) to rewrite operations in place. The result is fused operations mapped to vLLM's optimized kernels, including expert parallelization for Mixture-of-Experts models and tensor-parallel column/QKV linear operations.
Can I use the same model code for training and inference?
Yes. Unlike vLLM model implementations, transformers model implementations can be used for training, so you can use the same model code for training, evals, and reinforcement learning rollouts.
Hugging Face BlogRead Original Article

Get the latest Large Language Models news every morning

For example, today's edition would include:

  • CBTS launches Forge Agents for custom AI agentsSiliconANGLE AI · 1h ago
  • Imec CEO: AI era widens chip-model-CSP collaborationDIGITIMES Asia · 1h ago
  • Alphabet's AI Overviews reach 2.5B monthly usersYahoo Finance AI · 1h ago

AI-summarized, only the topics you pick — one digest a day via Email, Slack, or Discord.

Free · takes 30 seconds · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. Q&As are published on this page for other readers too.

Related Articles

Next articleJamf and Amazon Bedrock enable IT teams to manage AI apps on Mac fleets