跳到主内容
@wquguru
精选88PyTorch 博客(RSS)产品发布/更新

PyTorch加速工作组H1进展:CI中继与测试重构

PyTorch Hardware Enablement: Updates from the Acceleration Integration Working Group

原文
发到 X
推荐理由

PyTorch生态底层工程基建的重大更新,直接改善国产/异构芯片适配效率,做框架集成的同学必看。

TL;DR

The Accelerator Integration Working Group plays a vital role in standardizing how new hardware architectures connect to the open source AI ecosystem. As compute platforms diversify across cloud, edge, and specialized silicon, the Accelerator Integration Working Group establishes clear, vendor-neutral integration mechanisms that eliminate custom code patches and reduce ecosystem fragmentation. In this blog, we cover what the group achieved in H1 2026, including key infrastructure improvements, unified testing workflows, and reference backends across the entire PyTorch platform.

加速器集成工作组在标准化新硬件架构如何连接到开源 AI 生态系统中发挥着至关重要的作用。随着计算平台在云端、边缘端和专用硅芯片之间日益多样化,加速器集成工作组建立了清晰、厂商无关的集成机制,消除了自定义代码补丁并减少了生态系统碎片化。在本篇博客中,我们将介绍该工作组在 2026 年上半年取得的成果,包括关键的基础设施改进、统一的测试工作流以及整个 PyTorch 平台上的参考后端。

Introduction

引言

The PyTorch hardware ecosystem keeps diversifying, with a growing range of AI compute platforms adopting native framework integration. This expanding adoption creates a shared community challenge: streamlining integration paths, lowering complexity, standardizing integration mechanisms, and establishing reliable, unified validation infrastructure for heterogeneous compute platforms.

PyTorch 硬件生态系统持续多样化,越来越多的 AI 计算平台采用原生框架集成。这种不断扩大的采用率带来了一个共同的社区挑战:简化集成路径、降低复杂性、标准化集成机制,并为异构计算平台建立可靠、统一的验证基础设施。

That is the core mission of the Accelerator Integration Working Group. With a long‑term vision for a scalable, inclusive PyTorch hardware ecosystem, cross‑community contributors work on upstream framework improvements, shared tooling, and standardized reference implementations.

这正是加速器集成工作组的核心使命。凭借构建可扩展、包容性强的 PyTorch 硬件生态系统的长期愿景,跨社区的贡献者致力于上游框架改进、共享工具和标准化参考实现。

In 2026 H1, we made tangible progress across multiple core workstreams: refactored test suites for broader cross‑backend reuse, the Cross‑Repository CI Relay (CRCR) mechanism, profiling support for PrivateUse1‑based backends, ongoing maturation of OpenReg as the reference backend, distributed capability support, compiler backend integration, and enhanced CI infrastructure and visibility dashboards. This post outlines these major achievements and their impact on PyTorch integration for compute platforms across the broader ecosystem.

在 2026 年上半年,我们在多个核心工作流中取得了实质性进展:重构了测试套件以更广泛地跨后端复用、Cross-Repository CI Relay (CRCR) 机制、针对基于 PrivateUse1 的后端的分析支持、OpenReg 作为参考后端的持续成熟、分布式能力支持、编译器后端集成,以及增强的 CI 基础设施和可见性仪表板。本文概述了这些主要成就及其对整个生态系统中计算平台的 PyTorch 集成的影响。

Cross-Repository CI Relay

跨仓库 CI 中继

Authors: Subin George, Jiahao Chen, Jiahao Tan, Jiawei Li, Jewel K. M.

作者:Subin George, Jiahao Chen, Jiahao Tan, Jiawei Li, Jewel K. M.

Goals

目标

The PyTorch community has introduced Cross-Repository CI Relay (CRCR), a new system designed to close a long-standing visibility gap in its CI ecosystem. PyTorch sits at the center of a large network of dependent projects – accelerator like Intel XPU, AMD ROCm, Apple MPS, Qualcomm AI Engine and various accelerator integrated via PrivateUse1 mechanism, as well as ecosystem libraries such as vLLM, SGLang, and Hugging Face Transformers. While PyTorch’s own upstream CI is mature and extensive, it runs within pytorch/pytorch repo, leaving downstream repositories without a standard way to know when to test against upstream changes, report results back, or correlate failures across projects. This introduced a significant coordination challenge: PyTorch contributors could not tell whether their PRs would impact other backends prior to merge, and hardware maintainers could only offer feedback once changes had already been committed.

PyTorch 社区引入了跨仓库 CI 接力(Cross-Repository CI Relay,简称 CRCR),这是一个旨在解决其 CI 生态系统中长期存在的可见性空白的新系统。PyTorch 处于一个庞大依赖项目网络的中心——包括 Intel XPU、AMD ROCm、Apple MPS、Qualcomm AI Engine 等加速器,以及通过 PrivateUse1 机制集成的各种加速器,还有 vLLM、SGLang 和 Hugging Face Transformers 等生态系统库。尽管 PyTorch 自身的上游 CI 已经成熟且广泛,但它运行在 pytorch/pytorch 仓库内,导致下游仓库缺乏一种标准方式来知晓何时针对上游更改进行测试、将结果反馈回来,或在项目间关联失败情况。这带来了显著的协调挑战:PyTorch 贡献者在合并前无法判断其 PR 是否会影响其他后端,而硬件维护者只能在更改已提交后才能提供反馈。

Benefits

优势

CRCR solves this with a fully automated pipeline. When a PR is opened or a commit is pushed to pytorch/pytorch, a webhook triggers dispatch events to all registered downstream repositories in parallel.

CRCR 通过完全自动化的流水线解决了这一问题。当向 pytorch/pytorch 打开 PR 或推送提交时,Webhook 会并行触发所有已注册下游仓库的分发事件。

Figure 1: CRCR Architecture

图 1:CRCR 架构

Each repo runs its own CI workflow and reports status back via an authenticated callback, using a GitHub OIDC token that cryptographically verifies the calling repository’s identity. Results then flow into the PyTorch CI HUD (hud.pytorch.org/crcr) within seconds, giving maintainers a single dashboard for both in-tree and cross-repository CI health.

每个仓库运行其自己的 CI 工作流,并通过经过身份验证的回调报告状态,使用 GitHub OIDC 令牌对调用仓库的身份进行密码学验证。结果随后在几秒内流入 PyTorch CI HUD(hud.pytorch.org/crcr),为维护者提供一个统一的仪表板,用于监控树内和跨仓库 CI 的健康状况。

Figure 2: CRCR Hud Dashboard

图 2:CRCR HUD 仪表板

The system uses a tiered allowlist with four participation levels (L1–L4), letting downstream repos progress from simple dispatch notifications, to full HUD reporting, to non-blocking and eventually blocking check runs on upstream PRs. Security is enforced through five layers of validation – OIDC identity verification, allowlist authorization, rate limiting, state-machine checks, and strict separation of trusted versus self-reported data – ensuring that even a compromised downstream repo can only affect its own displayed CI status, not PyTorch’s actual build infrastructure or merge decisions. Onboarding requires minimal effort from downstream maintainers: Just an allowlist entry and a lightweight workflow file, with no custom authentication code needed.

该系统采用具有四个参与级别(L1–L4)的分层白名单,允许下游仓库从简单的分发通知逐步过渡到完整的 HUD 报告,再到非阻塞并最终成为上游 PR 上的阻塞检查运行。安全通过五层验证强制执行——OIDC 身份验证、白名单授权、速率限制、状态机检查和严格区分可信数据与自报数据——确保即使受 compromised 的下游仓库也只能影响其自身显示的 CI 状态,而不会影响 PyTorch 的实际构建基础设施或合并决策。下游维护者的接入工作几乎无需额外努力:只需在白名单中添加条目和一个轻量级的工作流文件,无需自定义身份验证代码。

Test Refactoring

测试重构

Authors: Riya Punia, Tanmay Kumar, Jiahao Chen, Jiahao Tan, Jiawei Li

作者:Riya Punia、Tanmay Kumar、Jiahao Chen、Jiahao Tan、Jiawei Li

Goals

目标

Validating a new accelerator backend against PyTorch’s existing test suite is one of the most effective ways to ensure implementation correctness and catch upstream changes early. PyTorch maintains over 600,000 test cases covering operators, autograd, profiling, distributed training, and more – a massive validation surface that, in principle, any backend should be able to leverage. In practice, however, many of these tests were written for a specific set of accelerators. Device strings, profiler activities, memory APIs, and skip decorators are hardcoded throughout, tightly coupling test logic to specific backends rather than expressing it in device-agnostic terms. Before this refactor, the only option was to maintain custom test cases via patches. Every PyTorch upgrade demanded significant manual effort, and this duplicated work was further exacerbated by PyTorch’s faster release cadence.

针对 PyTorch 现有的测试套件验证新的加速器后端,是确保实现正确性并尽早捕获上游变更的最有效方法之一。PyTorch 维护着超过 600,000 个测试用例,涵盖算子、自动微分(autograd)、性能分析(profiling)、分布式训练等——这是一个庞大的验证面,原则上任何后端都应能利用它。然而在实践中,许多这些测试是为特定的一组加速器编写的。设备字符串、性能分析活动、内存 API 和跳过装饰器在整个代码中都是硬编码的,这使得测试逻辑与特定后端紧密耦合,而不是以设备无关的方式表达。在此次重构之前,唯一的选项是通过补丁来维护自定义测试用例。每次 PyTorch 升级都需要大量手动工作,而 PyTorch 更快的发布周期进一步加剧了这种重复性工作。

In H1 2026, the working group launched a systematic effort to decouple PyTorch’s test suite from specific hardware. This work is tracked through a central tracking issue, an RFC on test case refactoring, and an RFC on test class classification, with 259 items tracked in the PyTorch Test Refactoring project.

在 2026 年上半年,工作组发起了一项系统性努力,旨在将 PyTorch 的测试套件与特定硬件解耦。这项工作通过一个中央跟踪问题、一个关于测试用例重构的 RFC 以及一个关于测试类分类的 RFC 进行跟踪,PyTorch 测试重构项目中跟踪了 259 个项目。

Figure 3: Test Refactoring Architecture

图 3:测试重构架构

The effort has three dimensions:

该努力包含三个维度:

Device-agnostic test migration: Replacing hardcoded device references (device=”cuda”, torch.cuda.synchronize(), @onlyCUDA) with parameterize equivalents (device=device, getattr(torch, device.type), instantiate_device_type_tests()). Each test class is classified as accelerator-unrelated (CPU-only, targeting generic features like the Dispatcher), accelerator-agnostic (device-parameterized, runs across all backends), or accelerator-specific (tied to a particular backend’s internal APIs). During H1, contributors migrated over 276 test files spanning dynamo, profiler, nn modules, linalg, optimizers, convolutions, serialization, multiprocessing, and dataloader.

设备无关的测试迁移:用参数化等效项替换硬编码的设备引用(device=”cuda”、torch.cuda.synchronize()、@onlyCUDA)(device=device、getattr(torch, device.type)、instantiate_device_type_tests())。每个测试类被分类为加速器不相关(仅 CPU,针对 Dispatcher 等通用功能)、加速器无关(设备参数化,在所有后端上运行)或加速器特定(绑定到特定后端的内部 API)。在上半年期间,贡献者迁移了超过 276 个测试文件,涵盖 dynamo、性能分析器、nn 模块、linalg、优化器、卷积、序列化、多处理和 dataloader。

Hardware classification metadata: Building on the test class classification proposed by Alban, the group implemented a hw_classification class attribute (GENERIC, DEVICE_GENERIC, CUDA, XPU, MPS) and a –hw-classification flag across all execution paths — unittest, pytest, subprocess, parallel, XML output, and run_test.py forwarding — enabling CI runners to select the correct test subset for their hardware automatically.

硬件分类元数据:基于 Alban 提出的测试类分类,工作组实现了 hw_classification 类属性(GENERIC、DEVICE_GENERIC、CUDA、XPU、MPS)以及贯穿所有执行路径的 –hw-classification 标志 —— unittest、pytest、subprocess、parallel、XML 输出和 run_test.py 转发 —— 使 CI 运行器能够根据其硬件自动选择正确的测试子集。

CI guardrails: A HW_CLASSIFICATION linter enforces that every new test class declares its classification. Existing unclassified files (1,191 at launch) are allowlisted and being driven to zero incrementally —matching the phased rollout agreed upon with PyTorch maintainers, with a future AI linter layer planned for more nuanced enforcement.

CI 护栏:HW_CLASSIFICATION linter 强制要求每个新测试类声明其分类。现有的未分类文件(启动时为 1,191 个)被列入白名单,并正逐步减少至零——这与与 PyTorch 维护者达成的分阶段推广计划相一致,未来还计划引入 AI linter 层以实现更细致的强制执行。

Benefits

益处

For accelerator developers, these changes fundamentally shift the onboarding experience. Instead of patching numerous test files to adapt them for their hardware, vendors can rely on instantiate_device_type_tests() to automatically generate test variants for their backend. Tests that were previously invisible to non-CUDA backends – because they were gated behind @onlyCUDA or hardcoded device=”cuda” – now run on any registered accelerator. A single device-agnostic test produces validated configurations across CUDA, MPS, XPU, ROCm, and PrivateUse1 backends simultaneously.

对于加速器开发者而言,这些变化从根本上改变了入职体验。供应商无需修补大量测试文件以适应其硬件,而是可以依赖 instantiate_device_type_tests() 自动为其后端生成测试变体。此前对非 CUDA 后端不可见的测试——因为它们被 @onlyCUDA 或硬编码 device=”cuda” 所限制——现在可以在任何已注册的加速器上运行。一个设备无关的测试可同时为 CUDA、MPS、XPU、ROCm 和 PrivateUse1 后端生成经过验证的配置。

更进一步:量化金融体系

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

进入量化体系 →

相似阅读

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