跳到主内容
@wquguru
精选88PyTorch 博客(RSS)技巧与观点

PyTorch Helion集成vLLM线性后端:高性能与可移植性实践

Building a High-Performance and Portable vLLM Linear Backend with Helion

原文
发到 X
推荐理由

提供了一手的大模型推理引擎内核优化工程实践,包含具体的量化格式支持、算法变体处理及性能权衡分析,对从事AI Infra优化的开发者极具参考价值。

TL;DR

TL;DR(太长不看)

We integrated Helion into vLLM’s linear backend to explore how an autotuned, high-level kernel DSL can improve LLM inference performance while reducing kernel implementation complexity. A single Helion general matrix multiplication (GEMM) implementation can cover multiple algorithmic variants, including Standard GEMM, Split-K, and Swap-AB, with the best variant and config automatically selected through per-shape autotuning.

我们将 Helion 集成到 vLLM 的线性后端中,以探索经过自动调优的高级内核 DSL 如何在降低内核实现复杂度的同时提升大语言模型(LLM)的推理性能。单个 Helion 通用矩阵乘法(GEMM)实现可覆盖多种算法变体,包括标准 GEMM、Split-K 和 Swap-AB,并通过针对特定形状的自动调优自动选择最佳变体和配置。

On NVIDIA Hopper GPUs, the Helion linear backend combines per-shape tuning with hybrid dispatch to outperform the vLLM default CUTLASS and DeepGEMM backends across the evaluated models, delivering consistent end-to-end performance gains and more than 10% throughput improvement for some workloads.

在 NVIDIA Hopper GPU 上,Helion 线性后端结合逐形状调优与混合分发机制,在评估的模型上超越了 vLLM 默认的 CUTLASS 和 DeepGEMM 后端,实现了持续的整体性能提升,并在某些工作负载下带来了超过 10% 的吞吐量改进。

Brief Background on vLLM and Helion

vLLM 与 Helion 简要背景

vLLM is a high-performance inference and serving framework for large language models (LLMs). For quantized linear layers, such as FP8, INT8, INT4, and NVFP4, vLLM provides specialized linear backends that integrate hardware-optimized kernel implementations from libraries such as CUTLASS, DeepGEMM, and FlashInfer. These backends allow vLLM to use optimized kernels for different quantization formats and hardware platforms.

vLLM 是一个面向大语言模型(LLM)的高性能推理与服务框架。对于量化线性层(如 FP8、INT8、INT4 和 NVFP4),vLLM 提供了专用的线性后端,集成了来自 CUTLASS、DeepGEMM 和 FlashInfer 等库的硬件优化内核实现。这些后端使 vLLM 能够针对不同量化格式和硬件平台使用优化的内核。

Helion is a PyTorch-native hardware agnostic kernel DSL designed for writing high-performance kernels using a tile-programming model. Its high-level abstraction allows developers to express a kernel once in concise Pythonic code, while Helion generates specialized code for different workloads on different hardware platforms. Rather than manually specializing kernels for each workload and hardware target, Helion relies on ahead-of-time (AOT) autotuner to systematically explore a broad search space, from low-level memory layout and kernel scheduling to high-level algorithmic choices, and select the best-performing config. This combination of high-level abstraction and systematic autotuning enables a single kernel implementation to be optimized across diverse workloads and hardware. Helion also supports LLM-guided search to further improve tuning efficiency.

Helion 是一个原生支持 PyTorch、硬件无关的内核 DSL,旨在通过图块编程模型编写高性能内核。其高级抽象允许开发者用简洁的 Pythonic 代码一次性表达内核逻辑,而 Helion 则针对不同硬件平台上的不同工作负载生成专用代码。Helion 不依赖手动为每个工作负载和目标硬件专门化内核,而是依靠提前编译(AOT)自动调优器系统地探索广泛的搜索空间——从底层内存布局和内核调度到高层算法选择——并选出性能最佳的配置。这种高级抽象与系统化自动调优的结合,使得单个内核实现能够在多样化的工作负载和硬件上得到优化。Helion 还支持基于 LLM 的搜索,以进一步提升调优效率。

Helion Adoption Opportunities and Challenges

Helion 的采用机遇与挑战

This section summarizes the key opportunities and challenges of adopting Helion kernels in inference engines such as vLLM, providing a high-level overview of Helion’s value proposition and tradeoffs.

本节总结了在 vLLM 等推理引擎中采用 Helion 内核的关键机遇与挑战,概述了 Helion 的价值主张及其权衡取舍。

Opportunities

机遇

Performance: Our previous work demonstrated Helion’s potential to achieve SOTA performance for inference kernels across diverse workload patterns and hardware platforms through fine-grained tuning.

性能:我们之前的工作证明了 Helion 通过细粒度调优,在不同工作负载模式和硬件平台上实现推理内核 SOTA(当前最佳)性能的潜力。

Systematic Tuning Framework: Compared with more open-ended agentic approaches that iteratively generate, profile, and refine kernel implementations, Helion formulates kernel tuning as a structured numerical optimization problem over a well-defined search space. This makes the tuning process more robust and reliable while remaining competitive in tuning efficiency, without relying on profiling to guide the search. Helion further supports LLM-guided search, combining the reasoning capabilities of LLMs with systematic numerical optimization to efficiently navigate the search space.

系统化调优框架:与更开放的智能体方法相比,后者迭代地生成、分析并优化内核实现,Helion 将内核调优表述为在明确定义搜索空间上的结构化数值优化问题。这使得调优过程更加稳健可靠,同时在调优效率方面保持竞争力,且无需依赖分析数据来指导搜索。Helion 进一步支持由大语言模型(LLM)引导的搜索,结合 LLM 的推理能力与系统化数值优化,以高效导航搜索空间。

Portability and Abstraction: Helion is not only a portable DSL. It is possible to maintain a single kernel implementation while optimizing it for different workload patterns and hardware platforms.

可移植性与抽象性:Helion 不仅是一个可移植的领域特定语言(DSL)。它能够维持单一的内核实现,同时针对不同的工作负载模式和硬件平台对其进行优化。

Client-Side Kernel Optimization: Default kernels in inference engines such as vLLM are typically optimized for general workloads and commonly used models. With Helion, users can further tune kernel performance for their specific deployments without requiring specialized kernel expertise or significant engineering effort.

客户端内核优化:vLLM 等推理引擎中的默认内核通常针对通用工作负载和常用模型进行优化。借助 Helion,用户可以为其特定部署进一步调优内核性能,而无需具备专业的内核知识或投入大量工程精力。

Challenges

挑战

Helion still has some challenges integrating into inference engines, with ongoing work from the Helion team to address and mitigate them.

Helion 在集成到推理引擎时仍面临一些挑战,Helion 团队正在开展相关工作以解决和缓解这些问题。

Ahead-of-time kernel tuning overhead: Helion automates and systematizes kernel tuning, but fine-grained tuning can still take hours. This overhead comes primarily from the granularity of the tuning strategy rather than from Helion itself. Achieving the same level of workload-specific specialization with other kernel DSLs would incur comparable—or potentially greater—tuning costs.

提前编译(Ahead-of-time)内核调优开销:Helion 自动化并系统化内核调优流程,但细粒度调优仍可能耗时数小时。这种开销主要源于调优策略的粒度,而非 Helion 本身。使用其他内核 DSL 实现同等程度的工作负载特定专业化,也将产生相当甚至更高的调优成本。

Startup-time overhead: CUDA Graph capture during vLLM startup triggers Helion JIT compilation, increasing cold-start latency. This overhead can be largely eliminated on warm starts by caching compiled artifacts.

启动时间开销:vLLM 启动期间的 CUDA Graph 捕获会触发 Helion 的 JIT 编译,从而增加冷启动延迟。通过在热启动时缓存已编译产物,可以很大程度上消除这一开销。

Inference-runtime overhead: Outside the CUDA Graph capture range, Helion kernel dispatch and launch during inference can introduce additional CPU overhead, potentially offsetting the performance gains from fine-grained tuning. In practice, Helion is most effective when executed under CUDA Graphs to avoid this CPU overhead.

推理运行时开销:在 CUDA Graph 捕获范围之外,Helion 内核的分发和执行可能在推理过程中引入额外的 CPU 开销,从而抵消细粒度调优带来的性能提升。在实践中,当在 CUDA Graphs 下执行时,Helion 最为有效,可避免此类 CPU 开销。

Maintenance overhead: Shipping pre-tuned configs for popular models creates an ongoing upstream maintenance burden. Large config files are difficult to maintain and impractical to validate exhaustively through unit tests and CI.

维护开销:为流行模型提供预调优配置会在上游产生持续的维护负担。大型配置文件难以维护,且无法通过单元测试和 CI 进行穷尽式验证。

The Tradeoff Triangle

权衡三角

Fine-grained kernel tuning with Helion presents a tradeoff among performance, usability, and maintainability. This tradeoff is not specific to Helion, but is inherent to workload-specific kernel optimization: optimizing for two often comes at the expense of the third.

使用 Helion 进行细粒度内核调优在性能、可用性和可维护性之间存在权衡。这种权衡并非 Helion 特有,而是工作负载特定内核优化的固有特性:优化其中两项往往以牺牲第三项为代价。

Fig. 1: The Performance-Usability-Maintainability tradeoff triangle

图 1:性能-可用性-可维护性权衡三角

Higher performance generally requires more fine-grained config tuning. This either increases client-side autotuning overhead or requires maintainers to provide and maintain more pre-tuned configs upstream. The goal, therefore, is to strike the right balance for the target use case.

更高的性能通常需要更细粒度的配置调优。这要么增加客户端自动调优的开销,要么要求维护者在上游提供更多并维护更多预调优配置。因此,目标是为目标用例找到正确的平衡点。

Helion Linear Backend

Helion 线性后端

Scope

范围

This work adds a Helion linear backend to vLLM and focuses on NVIDIA Hopper GPUs using Helion’s Triton backend. FP8 and INT8 are the primary quantization formats for efficient inference on Hopper, so we target quantized GEMM with the following formats:

本研究向 vLLM 添加了 Helion 线性后端,并专注于使用 Helion Triton 后端的 NVIDIA Hopper GPU。FP8 和 INT8 是 Hopper 上高效推理的主要量化格式,因此我们针对以下格式的量化 GEMM:

  • FP8_Dynamic: FP8 per-token activation and per-channel weight scaling.
  • W8A8_INT8: INT8 per-token activation and per-channel weight scaling.
  • Block_FP8: FP8 with 1×128 activation scaling and 128×128 weight scaling.
  • FP8_Dynamic:每个 token 的激活值和每通道的权重缩放 FP8。
  • W8A8_INT8:每个 token 的激活值和每通道的权重缩放 INT8。
  • Block_FP8:具有 1×128 激活值缩放和 128×128 权重缩放的 FP8。

Initial results with Helion’s CuteDSL backend show competitive GEMM performance on NVIDIA Blackwell GPUs. As the CuteDSL backend matures, this work can be extended to support Blackwell.

使用 Helion CuteDSL 后端的初步结果显示,在 NVIDIA Blackwell GPU 上具有竞争力的 GEMM 性能。随着 CuteDSL 后端的成熟,本研究可扩展以支持 Blackwell。

Kernel Implementation

内核实现

Several GEMM algorithm variants can improve performance for specific input shapes. In particular:

几种 GEMM 算法变体可以改善特定输入形状的性能。特别是:

  • Split-K: Partitions the K dimension across multiple thread blocks to increase parallelism when the M and/or N dimensions are too small.
  • Swap-AB: Rewrites A@B as ([email protected]).T to improve performance for shapes with a small M dimension by enabling more favorable tiling and better GPU utilization.
  • Split-K:将 K 维度跨多个线程块分区,当 M 和/或 N 维度太小时增加并行度。
  • Swap-AB:将 A@B 重写为 ([email protected]).T,以便通过启用更有利的分块和提高 GPU 利用率来改善具有小 M 维度的形状的性能。

Traditionally, kernel authors need to implement multiple GEMM variants, benchmark the standard GEMM against these specialized variants, and develop heuristics to determine which implementation to dispatch to based on the input shape. For example, vLLM’s current Block_FP8 linear backend dispatches to the Swap-AB variant when M < 32 on Hopper. Such heuristics are typically designed to perform well in general, but may not be optimal for every model or workload.

传统上,内核作者需要实现多种 GEMM 变体,将标准 GEMM 与这些专用变体进行基准测试,并开发启发式规则以确定基于输入形状应分发到哪个实现。例如,vLLM 当前的 Block_FP8 线性后端在 Hopper 上当 M < 32 时分发至 Swap-AB 变体。此类启发式规则通常旨在通用情况下表现良好,但可能并非对每个模型或工作负载都是最优的。

With Helion, a single unified GEMM implementation can cover all three variants—Standard, Split-K, and Swap-AB. Instead of implementing separate kernels and manually designing dispatch heuristics, the algorithmic choices are exposed as tunable parameters. The AOT autotuner can then automatically select the best variant along with the low-level kernel config for each workload.

借助 Helion,单个统一的 GEMM 实现即可覆盖所有三种变体——Standard、Split-K 和 Swap-AB。无需分别实现独立的内核并手动设计分发启发式算法,而是将算法选择暴露为可调参数。随后,AOT 自动调优器(autotuner)可以为每个工作负载自动选择最佳变体以及底层内核配置。

For simplicity, we use a basic matrix multiplication kernel below to illustrate the approach. The quantized GEMM kernels used in this work follow the same structure, with additional quantization and scaling logic.

为简化说明,下文使用一个基础矩阵乘法内核来展示该方法。本工作中使用的量化 GEMM 内核遵循相同的结构,并包含额外的量化与缩放逻辑。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件