{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-07-08-native-speed-vllm-transformers-modeling-backend/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "**TL;DR**: The transformers vLLM backend is now as fast (or faster) than custom vLLM implementations for many LLM architectures. Model authors can automatically leverage their transformers implementations to get ultra fast vLLM inference, for free.\n\n```bash\n# Upgrade the vllm pip package\nuv pip install --upgrade vllm --torch-backend auto\n```\n\nThe transformers library has become the **reference modeling library** for Machine Learning. It supports 450+ architectures through consistent APIs, and is designed with the main goal that model implementations are *self contained* and *easy to understand*. Going through transformers code makes it easy for contributors to learn how an architecture works, and then port it to other frameworks such as vLLM, SGLang, MLX, llama.cpp, and many others.\n\nWe have fully embraced this role in the ecosystem and are investing a lot of effort to make it easier. A big step in this direction was the integration last year of transformers as a modeling backend in vLLM. This has been allowing model authors to run transformers models (LLMs and VLMs alike) inside vLLM, without having to port anything. Transformers provides the modeling code, and vLLM provides extremely optimized inference techniques such as continuous batching and custom attention kernels.\n\nThis integration gets better now 🚀!\n\n## Showcase\n\nWe put the transformers modeling backend for vLLM head to head with vLLM's hand written native implementations across three very different Qwen3 models:\n\n- 4B dense model on a single GPU\n- 32B dense model on tensor parallelism\n- 235B-parameter FP8 Mixture-of-Experts on data + expert parallelism on the same 8×H100 node\n\n| [![Pre and Post PR benchmarks with trasnformers vllm backend](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/pre-post-pr.png)](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/pre-post-pr.png) |\n| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| The result: the transformers modeling backend now **meets or beats** native throughput on every one of them.                                                                                                                                                                                      |\n\nRunning any\\* Hugging Face model through the transformers modeling backend is a single flag — `--model-impl transformers`. It composes with the usual parallelism options, so nothing about your serving setup changes:\n\n```bash\n# Qwen3-4B dense, single GPU\nvllm serve Qwen/Qwen3-4B --model-impl transformers\n\n# Qwen3-32B dense, tensor-parallel across 2 GPUs\nvllm serve Qwen/Qwen3-32B --model-impl transformers --tensor-parallel-size 2\n\n# Qwen3-235B-A22B-FP8 MoE, data-parallel + expert-parallel across 8 GPUs\nvllm serve Qwen/Qwen3-235B-A22B-FP8 --model-impl transformers --data-parallel-size 8 --enable-expert-parallel\n# add --max-model-len 8192 if your node is memory constrained\n```\n\n*\\*Models that use linear attention are not currently supported, but they will be soon! Custom models where the code lives in a Hub repo are unlikely to work as they will not have been written compliantly.*\n\n### How we measured\n\nEach model is compared under three conditions that are identical in every way except the code path:\n\n1. **native** — `--model-impl vllm`, vLLM's hand-written model (the bar to match)\n2. **after** — `--model-impl transformers` *with* the PR\n3. **before** — `--model-impl transformers` *without* the PR\n\nThe full, reproducible runner is available as a gist: [`benchmark.sh`](https://huggingface.co/datasets/ariG23498/useful-scripts/blob/main/transformers-backend-vllm-benchmark.sh)\n\n## So, what's new?\n\nThe transformers modeling backend for vLLM used to focus on *attention* as the bottleneck for inference. By plugging vLLM’s attention implementation at runtime, we could make a transformers model run efficiently inside the vLLM engine. But there are many dimensions to deployments that only a custom port can target to extract maximum inference performance. Parallelization across GPUs, compilation, fused kernels, and many more, all contribute to leveraging your hardware to achieve ultra-fast inference.\n\n| [![New model integration to transformers and vLLM](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/previous-pipeline.png)](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/previous-pipeline.png) |\n| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| A new model used to be integrated once for transformers, and once for vLLM with custom optimizations                                                                                                                                                                                               |\n\nWhen model authors wanted the absolute best performance, they were still writing custom vLLM implementations.\n\n| [![New model integrates to transformers, and is immediately available to vLLM](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/current-pipeline.png)](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/current-pipeline.png) |\n| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| A new model once integrated to transformers, can now be immediately used in vLLM with native vLLM implementation speed                                                                                                                                                                                                       |\n\nThe latest iteration of the transformers modeling backend for vLLM dynamically applies inference specific layer fusions at runtime to match the speed of custom code implementations, for compatible architectures.\n\n## How does it work?\n\nThe transformers modeling backend for vLLM now uses `torch.fx` to perform static analysis on the model’s graph. This process searches for known patterns that can be optimised. After any patterns have been identified, it uses ast (abstract syntax tree) to manipulate the source code and rewrite some of the operations in place.\n\n**What can we achieve with this?**\n\n- Fused operations that are many-to-one mapped to (ultra) optimized vLLM kernels, such as the ones used for Expert Parallelization (EP) in Mixture-of-Experts (MoE) models.\n- The main other fused operations are vLLM's `MergedColumnParallelLinear` and `QKVParallelLinear`. These blocks allow us to infer parallel plans for TP (tensor-parallel). PP (pipeline-parallel) plans can also be inferred if the decoder block list is easily identifiable.\n- The manipulated models are still fully (torch) compilable, being passed through `torch.compile` and CUDA Graphs, just the same as a dedicated vLLM model implementation.\n- Unlike vLLM model implementations, Transformers model implementations can be used in **training**. So you can use the same model code for training/evals/RL rollouts.\n\nAs shown above, this results in native vLLM inference speed for compatible models, without having to write a single line of code to optimize the model for inference.\n\n> We are in the process of writing a detailed blog post to dive deep inside these optimized inference methods and explain in detail how we manipulate the model to adapt to them.\n\n## Resources\n\n- [Transformers model definition](https://huggingface.co/blog/transformers-model-definition#a-model-definition-library)\n- [Transformers modeling backend in vLLM](https://vllm.ai/blog/2025-04-11-transformers-backend)\n- [Large scale serving](https://vllm.ai/blog/2025-12-17-large-scale-serving)\n- [Torch FX](https://docs.pytorch.org/docs/2.12/fx.html)\n- [Abstract syntax tree](https://docs.python.org/3/library/ast.html)\n",
  "authors": [],
  "captured_at": "2026-10-19T01:26:53.998049939+00:00",
  "category": "ai",
  "content_html": "<p><strong>TL;DR</strong>: The transformers vLLM backend is now as fast (or faster) than custom vLLM implementations for many LLM architectures. Model authors can automatically leverage their transformers implementations to get ultra fast vLLM inference, for free.</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Upgrade the vllm pip package</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">uv</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> pip install<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>upgrade</span> vllm<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>torch-backend</span> auto</span>\n</span></span></code></pre>\n<p>The transformers library has become the <strong>reference modeling library</strong> for Machine Learning. It supports 450+ architectures through consistent APIs, and is designed with the main goal that model implementations are <em>self contained</em> and <em>easy to understand</em>. Going through transformers code makes it easy for contributors to learn how an architecture works, and then port it to other frameworks such as vLLM, SGLang, MLX, llama.cpp, and many others.</p>\n<p>We have fully embraced this role in the ecosystem and are investing a lot of effort to make it easier. A big step in this direction was the integration last year of transformers as a modeling backend in vLLM. This has been allowing model authors to run transformers models (LLMs and VLMs alike) inside vLLM, without having to port anything. Transformers provides the modeling code, and vLLM provides extremely optimized inference techniques such as continuous batching and custom attention kernels.</p>\n<p>This integration gets better now 🚀!</p>\n<h2>Showcase</h2>\n<p>We put the transformers modeling backend for vLLM head to head with vLLM's hand written native implementations across three very different Qwen3 models:</p>\n<ul>\n<li>4B dense model on a single GPU</li>\n<li>32B dense model on tensor parallelism</li>\n<li>235B-parameter FP8 Mixture-of-Experts on data + expert parallelism on the same 8×H100 node</li>\n</ul>\n<table>\n<thead>\n<tr>\n<th><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/pre-post-pr.png\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/pre-post-pr.png\" alt=\"Pre and Post PR benchmarks with trasnformers vllm backend\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>The result: the transformers modeling backend now <strong>meets or beats</strong> native throughput on every one of them.</td>\n</tr>\n</tbody>\n</table>\n<p>Running any* Hugging Face model through the transformers modeling backend is a single flag — <code>--model-impl transformers</code>. It composes with the usual parallelism options, so nothing about your serving setup changes:</p>\n<pre><code class=\"language-bash\"><span class=\"code-snippet\" data-language=\"Shell\"><span class=\"syntax-source syntax-shell syntax-bash\"><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Qwen3-4B dense, single GPU</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">vllm</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> serve Qwen/Qwen3-4B<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>model-impl</span> transformers</span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Qwen3-32B dense, tensor-parallel across 2 GPUs</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">vllm</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> serve Qwen/Qwen3-32B<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>model-impl</span> transformers<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>tensor-parallel-size</span> 2</span>\n\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> Qwen3-235B-A22B-FP8 MoE, data-parallel + expert-parallel across 8 GPUs</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span><span class=\"syntax-meta syntax-function-call syntax-shell\"><span class=\"syntax-variable syntax-function syntax-shell\">vllm</span></span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-shell\"> serve Qwen/Qwen3-235B-A22B-FP8<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>model-impl</span> transformers<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>data-parallel-size</span> 8<span class=\"syntax-variable syntax-parameter syntax-option syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-parameter syntax-shell\"> --</span>enable-expert-parallel</span></span>\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell\">#</span></span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\"> add --max-model-len 8192 if your node is memory constrained</span><span class=\"syntax-comment syntax-line syntax-number-sign syntax-shell\">\n</span></span></span></code></pre>\n<p><em>*Models that use linear attention are not currently supported, but they will be soon! Custom models where the code lives in a Hub repo are unlikely to work as they will not have been written compliantly.</em></p>\n<h3>How we measured</h3>\n<p>Each model is compared under three conditions that are identical in every way except the code path:</p>\n<ol>\n<li><strong>native</strong> — <code>--model-impl vllm</code>, vLLM's hand-written model (the bar to match)</li>\n<li><strong>after</strong> — <code>--model-impl transformers</code> <em>with</em> the PR</li>\n<li><strong>before</strong> — <code>--model-impl transformers</code> <em>without</em> the PR</li>\n</ol>\n<p>The full, reproducible runner is available as a gist: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/datasets/ariG23498/useful-scripts/blob/main/transformers-backend-vllm-benchmark.sh\"><code>benchmark.sh</code></a></p>\n<h2>So, what's new?</h2>\n<p>The transformers modeling backend for vLLM used to focus on <em>attention</em> as the bottleneck for inference. By plugging vLLM’s attention implementation at runtime, we could make a transformers model run efficiently inside the vLLM engine. But there are many dimensions to deployments that only a custom port can target to extract maximum inference performance. Parallelization across GPUs, compilation, fused kernels, and many more, all contribute to leveraging your hardware to achieve ultra-fast inference.</p>\n<table>\n<thead>\n<tr>\n<th><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/previous-pipeline.png\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/previous-pipeline.png\" alt=\"New model integration to transformers and vLLM\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>A new model used to be integrated once for transformers, and once for vLLM with custom optimizations</td>\n</tr>\n</tbody>\n</table>\n<p>When model authors wanted the absolute best performance, they were still writing custom vLLM implementations.</p>\n<table>\n<thead>\n<tr>\n<th><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/current-pipeline.png\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/current-pipeline.png\" alt=\"New model integrates to transformers, and is immediately available to vLLM\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>A new model once integrated to transformers, can now be immediately used in vLLM with native vLLM implementation speed</td>\n</tr>\n</tbody>\n</table>\n<p>The latest iteration of the transformers modeling backend for vLLM dynamically applies inference specific layer fusions at runtime to match the speed of custom code implementations, for compatible architectures.</p>\n<h2>How does it work?</h2>\n<p>The transformers modeling backend for vLLM now uses <code>torch.fx</code> to perform static analysis on the model’s graph. This process searches for known patterns that can be optimised. After any patterns have been identified, it uses ast (abstract syntax tree) to manipulate the source code and rewrite some of the operations in place.</p>\n<p><strong>What can we achieve with this?</strong></p>\n<ul>\n<li>Fused operations that are many-to-one mapped to (ultra) optimized vLLM kernels, such as the ones used for Expert Parallelization (EP) in Mixture-of-Experts (MoE) models.</li>\n<li>The main other fused operations are vLLM's <code>MergedColumnParallelLinear</code> and <code>QKVParallelLinear</code>. These blocks allow us to infer parallel plans for TP (tensor-parallel). PP (pipeline-parallel) plans can also be inferred if the decoder block list is easily identifiable.</li>\n<li>The manipulated models are still fully (torch) compilable, being passed through <code>torch.compile</code> and CUDA Graphs, just the same as a dedicated vLLM model implementation.</li>\n<li>Unlike vLLM model implementations, Transformers model implementations can be used in <strong>training</strong>. So you can use the same model code for training/evals/RL rollouts.</li>\n</ul>\n<p>As shown above, this results in native vLLM inference speed for compatible models, without having to write a single line of code to optimize the model for inference.</p>\n<blockquote>\n<p>We are in the process of writing a detailed blog post to dive deep inside these optimized inference methods and explain in detail how we manipulate the model to adapt to them.</p>\n</blockquote>\n<h2>Resources</h2>\n<ul>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/blog/transformers-model-definition#a-model-definition-library\">Transformers model definition</a></li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://vllm.ai/blog/2025-04-11-transformers-backend\">Transformers modeling backend in vLLM</a></li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://vllm.ai/blog/2025-12-17-large-scale-serving\">Large scale serving</a></li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://docs.pytorch.org/docs/2.12/fx.html\">Torch FX</a></li>\n<li><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://docs.python.org/3/library/ast.html\">Abstract syntax tree</a></li>\n</ul>\n",
  "content_markdown": "**TL;DR**: The transformers vLLM backend is now as fast (or faster) than custom vLLM implementations for many LLM architectures. Model authors can automatically leverage their transformers implementations to get ultra fast vLLM inference, for free.\n\n```bash\n# Upgrade the vllm pip package\nuv pip install --upgrade vllm --torch-backend auto\n```\n\nThe transformers library has become the **reference modeling library** for Machine Learning. It supports 450+ architectures through consistent APIs, and is designed with the main goal that model implementations are *self contained* and *easy to understand*. Going through transformers code makes it easy for contributors to learn how an architecture works, and then port it to other frameworks such as vLLM, SGLang, MLX, llama.cpp, and many others.\n\nWe have fully embraced this role in the ecosystem and are investing a lot of effort to make it easier. A big step in this direction was the integration last year of transformers as a modeling backend in vLLM. This has been allowing model authors to run transformers models (LLMs and VLMs alike) inside vLLM, without having to port anything. Transformers provides the modeling code, and vLLM provides extremely optimized inference techniques such as continuous batching and custom attention kernels.\n\nThis integration gets better now 🚀!\n\n## Showcase\n\nWe put the transformers modeling backend for vLLM head to head with vLLM's hand written native implementations across three very different Qwen3 models:\n\n- 4B dense model on a single GPU\n- 32B dense model on tensor parallelism\n- 235B-parameter FP8 Mixture-of-Experts on data + expert parallelism on the same 8×H100 node\n\n| [![Pre and Post PR benchmarks with trasnformers vllm backend](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/pre-post-pr.png)](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/pre-post-pr.png) |\n| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| The result: the transformers modeling backend now **meets or beats** native throughput on every one of them.                                                                                                                                                                                      |\n\nRunning any\\* Hugging Face model through the transformers modeling backend is a single flag — `--model-impl transformers`. It composes with the usual parallelism options, so nothing about your serving setup changes:\n\n```bash\n# Qwen3-4B dense, single GPU\nvllm serve Qwen/Qwen3-4B --model-impl transformers\n\n# Qwen3-32B dense, tensor-parallel across 2 GPUs\nvllm serve Qwen/Qwen3-32B --model-impl transformers --tensor-parallel-size 2\n\n# Qwen3-235B-A22B-FP8 MoE, data-parallel + expert-parallel across 8 GPUs\nvllm serve Qwen/Qwen3-235B-A22B-FP8 --model-impl transformers --data-parallel-size 8 --enable-expert-parallel\n# add --max-model-len 8192 if your node is memory constrained\n```\n\n*\\*Models that use linear attention are not currently supported, but they will be soon! Custom models where the code lives in a Hub repo are unlikely to work as they will not have been written compliantly.*\n\n### How we measured\n\nEach model is compared under three conditions that are identical in every way except the code path:\n\n1. **native** — `--model-impl vllm`, vLLM's hand-written model (the bar to match)\n2. **after** — `--model-impl transformers` *with* the PR\n3. **before** — `--model-impl transformers` *without* the PR\n\nThe full, reproducible runner is available as a gist: [`benchmark.sh`](https://huggingface.co/datasets/ariG23498/useful-scripts/blob/main/transformers-backend-vllm-benchmark.sh)\n\n## So, what's new?\n\nThe transformers modeling backend for vLLM used to focus on *attention* as the bottleneck for inference. By plugging vLLM’s attention implementation at runtime, we could make a transformers model run efficiently inside the vLLM engine. But there are many dimensions to deployments that only a custom port can target to extract maximum inference performance. Parallelization across GPUs, compilation, fused kernels, and many more, all contribute to leveraging your hardware to achieve ultra-fast inference.\n\n| [![New model integration to transformers and vLLM](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/previous-pipeline.png)](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/previous-pipeline.png) |\n| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| A new model used to be integrated once for transformers, and once for vLLM with custom optimizations                                                                                                                                                                                               |\n\nWhen model authors wanted the absolute best performance, they were still writing custom vLLM implementations.\n\n| [![New model integrates to transformers, and is immediately available to vLLM](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/current-pipeline.png)](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/vllm-backend/current-pipeline.png) |\n| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| A new model once integrated to transformers, can now be immediately used in vLLM with native vLLM implementation speed                                                                                                                                                                                                       |\n\nThe latest iteration of the transformers modeling backend for vLLM dynamically applies inference specific layer fusions at runtime to match the speed of custom code implementations, for compatible architectures.\n\n## How does it work?\n\nThe transformers modeling backend for vLLM now uses `torch.fx` to perform static analysis on the model’s graph. This process searches for known patterns that can be optimised. After any patterns have been identified, it uses ast (abstract syntax tree) to manipulate the source code and rewrite some of the operations in place.\n\n**What can we achieve with this?**\n\n- Fused operations that are many-to-one mapped to (ultra) optimized vLLM kernels, such as the ones used for Expert Parallelization (EP) in Mixture-of-Experts (MoE) models.\n- The main other fused operations are vLLM's `MergedColumnParallelLinear` and `QKVParallelLinear`. These blocks allow us to infer parallel plans for TP (tensor-parallel). PP (pipeline-parallel) plans can also be inferred if the decoder block list is easily identifiable.\n- The manipulated models are still fully (torch) compilable, being passed through `torch.compile` and CUDA Graphs, just the same as a dedicated vLLM model implementation.\n- Unlike vLLM model implementations, Transformers model implementations can be used in **training**. So you can use the same model code for training/evals/RL rollouts.\n\nAs shown above, this results in native vLLM inference speed for compatible models, without having to write a single line of code to optimize the model for inference.\n\n> We are in the process of writing a detailed blog post to dive deep inside these optimized inference methods and explain in detail how we manipulate the model to adapt to them.\n\n## Resources\n\n- [Transformers model definition](https://huggingface.co/blog/transformers-model-definition#a-model-definition-library)\n- [Transformers modeling backend in vLLM](https://vllm.ai/blog/2025-04-11-transformers-backend)\n- [Large scale serving](https://vllm.ai/blog/2025-12-17-large-scale-serving)\n- [Torch FX](https://docs.pytorch.org/docs/2.12/fx.html)\n- [Abstract syntax tree](https://docs.python.org/3/library/ast.html)\n",
  "dateCreated": "2026-10-19T01:26:53.998049939+00:00",
  "date_created": "2026-07-08T00:00:00+00:00",
  "date_modified": "2026-07-08T00:00:00+00:00",
  "date_published": "2026-07-08T00:00:00+00:00",
  "description": "TL;DR: The transformers vLLM backend is now as fast (or faster) than custom vLLM implementations for many LLM architectures. Model authors can automatically leverage their transformers implementations to get ultra fast vLLM inference, for…",
  "external_url": "https://huggingface.co/blog/native-speed-vllm-transformers-backend",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/huggingface-co/2026/07/2026-07-08-native-speed-vllm-transformers-modeling-backend.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/huggingface-co/2026/07/2026-07-08-native-speed-vllm-transformers-modeling-backend.md"
  },
  "id": "urn:aggr:item:edfb1d8d57c5ef3b51b4e41364dbd58968a4492a",
  "isBasedOn": {
    "@id": "https://huggingface.co/blog/native-speed-vllm-transformers-backend"
  },
  "mainEntity": {
    "@id": "https://huggingface.co/blog/native-speed-vllm-transformers-backend",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-07-08-native-speed-vllm-transformers-modeling-backend/#webpage"
    },
    "dateModified": "2026-07-08T00:00:00+00:00",
    "datePublished": "2026-07-08T00:00:00+00:00",
    "headline": "Native-speed vLLM transformers modeling backend",
    "image": {
      "@type": "ImageObject",
      "caption": null,
      "height": 90,
      "url": "https://huggingface.co/blog/assets/native-speed-vllm-transformers-backend/thumbnail.png",
      "width": 160
    },
    "timeRequired": "PT4M",
    "url": "https://huggingface.co/blog/native-speed-vllm-transformers-backend",
    "wordCount": 878
  },
  "name": "Archived snapshot: Native-speed vLLM transformers modeling backend",
  "preview": {
    "alt": null,
    "color": null,
    "height": 90,
    "placeholder": {
      "data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
      "hash": ""
    },
    "url": "https://huggingface.co/blog/assets/native-speed-vllm-transformers-backend/thumbnail.png",
    "width": 160
  },
  "reading_minutes": 4,
  "replicated_at": null,
  "source": "huggingface-co",
  "source_name": "Hugging Face - Blog",
  "summary": null,
  "tags": [],
  "temporalCoverage": "2026-10-19T01:26:53.998049939+00:00",
  "title": "Native-speed vLLM transformers modeling backend",
  "url": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-07-08-native-speed-vllm-transformers-modeling-backend/",
  "word_count": 878
}