ONNX Runtime WebGPU PR Monitor

Last Updated: 04/01/2026, 07:04 PM | Total: 172 PRs

Showing 1-10 of 31 PRs
Page 1 of 4
👤 prathikr📅 Created: 04/01/2026
🤖 AI 摘要

## PR 主要改动总结 **核心改动:** 此 PR 从 `onnxruntime-foundry-nuget` 包中移除了 WebGPU 组件,仅修改了 Azure Pipelines 的自定义 NuGet 打包配置文件。 **解决的问题:** 为 Foundry Local 提供支持,使其能够将 WebGPU 作为插件式执行提供程序(plugin-ep)独立下载和安装,而不是捆绑在主 NuGet 包中。 **对 WebGPU 支持的影响:** 这是一个打包策略调整,WebGPU 功能从内置组件变为可选插件,提高了部署灵活性,允许用户按需加载 WebGPU 支持,减小核心包体积。 **技术要点:** 改动非常轻量(仅 4 行代码变更),采用模块化架构设计,将执行提供程序与核心运行时解耦,符合插件化扩展模式。

📁 Changed Files (1 files, 4 changes: +2/-2)
tools/ci_build/github/azure-pipelines/custom-nuget-packaging-pipeline.yml
🤖 AI 摘要

## PR 主要改动总结 ### 核心改动 这是一次代码清理工作,将 `OpKernel` 类中的两个虚方法 `UseSharedPrePackedBuffers` (V1) 和 `UseSharedPrePackedBuffers_V2` 合并为单一方法,采用 V2 的签名(包含 4 个参数,新增了 `prepacked_buffer_sizes` 参数)。 ### 解决的问题 消除了历史遗留的方法冗余。V2 原本是为了传递预打包权重缓冲区的大小信息而引入,但保留了 V1 用于向后兼容。此次统一了接口,删除了 V1 及其默认转发逻辑,解决了 `op_kernel.h` 中的 TODO 注释。 ### 影响范围 涉及 27 个文件的修改,主要更新了各个算子(如 MatMul、Conv、Attention、量化相关算子等)的实现,将方法签名统一为新的 4 参数版本。这是纯代码重构,不影响功能行为,对 WebGPU 或其他 EP 的运行时逻辑无实质性影响。 ### 技术要点 使用 `gsl::span<const size_t>` 传递缓冲区大小信息,提供了更安全的数组视图接口,同时保持了 API 的简洁性和一致性。

📁 Changed Files (27 files, 94 changes: +54/-40)
include/onnxruntime/core/framework/op_kernel.h
onnxruntime/contrib_ops/cpu/bert/attention.cc
onnxruntime/contrib_ops/cpu/moe/moe_quantization_cpu.cc
onnxruntime/contrib_ops/cpu/moe/moe_quantization_cpu.h
onnxruntime/contrib_ops/cpu/quantization/attention_quant.cc
onnxruntime/contrib_ops/cpu/quantization/dynamic_quantize_lstm.cc
onnxruntime/contrib_ops/cpu/quantization/matmul_nbits.cc
onnxruntime/core/framework/session_state.cc
onnxruntime/core/providers/acl/math/matmul.cc
onnxruntime/core/providers/acl/math/matmul.h
onnxruntime/core/providers/acl/nn/conv.cc
onnxruntime/core/providers/acl/nn/conv.h
onnxruntime/core/providers/cpu/fp16/fp16_conv.cc
onnxruntime/core/providers/cpu/math/gemm.cc
onnxruntime/core/providers/cpu/math/gemm.h
onnxruntime/core/providers/cpu/math/matmul.cc
onnxruntime/core/providers/cpu/math/matmul.h
onnxruntime/core/providers/cpu/nn/conv_transpose.cc
onnxruntime/core/providers/cpu/nn/conv_transpose.h
onnxruntime/core/providers/cpu/quantization/matmul_integer_base.h
onnxruntime/core/providers/cpu/quantization/qlinearconv.cc
onnxruntime/core/providers/cpu/rnn/deep_cpu_gru.cc
onnxruntime/core/providers/cpu/rnn/deep_cpu_gru.h
onnxruntime/core/providers/cpu/rnn/deep_cpu_lstm.cc
onnxruntime/core/providers/cpu/rnn/deep_cpu_lstm.h
onnxruntime/core/session/plugin_ep/ep_kernel_registration.cc
onnxruntime/test/framework/session_state_test.cc
👤 edgchen1📅 Created: 03/31/2026
🤖 AI 摘要

## PR 主要改动总结 **核心功能:** 此 PR 为 ONNX Runtime 的 WebGPU 执行提供程序添加了 Conv3D(三维卷积)操作支持。 **主要改动:** 1. 新增 `Conv3DNaiveProgram` 类实现了基于 WebGPU 的逐元素 Conv3D 着色器,支持"channels last"和"channels first"两种数据布局,并可选支持 bias 和 activation 2. 更新了主卷积逻辑以检测 5D 张量并构建相应的 3D 卷积着色器程序,传递空间/步长/膨胀等参数作为 uniform 3. 启用了 Conv3D 相关测试用例,但暂不支持分组 Conv3D(Grouped Conv3D) **技术影响:** 这是 WebGPU 后端对 3D 卷积算子的首次支持,扩展了 ONNX Runtime 在 WebGPU 平台上处理三维数据(如视频、医学影像等)的能力,但当前实现采用朴素算法,性能优化空间较大。

📁 Changed Files (5 files, 255 changes: +250/-5)
onnxruntime/core/providers/webgpu/nn/conv.cc
onnxruntime/core/providers/webgpu/nn/conv3d_naive.cc
onnxruntime/core/providers/webgpu/nn/conv3d_naive.h
onnxruntime/test/providers/cpu/nn/conv_fp16_test.cc
onnxruntime/test/providers/cpu/nn/conv_op_test.cc
👤 fs-eire📅 Created: 03/30/2026
🤖 AI 摘要

## PR 主要改动总结 ### 1. 主要功能 这是一个代码现代化重构 PR,在 ONNX Runtime 升级到 C++20 后,对 WebGPU EP (Execution Provider) 的代码进行全面的 C++20 惯用法改造,涉及 19 个文件,净删除 3 行代码。 ### 2. 核心改进 - **C++20 语法现代化**:采用 `contains()` 替代 `find() != end()`,使用 `requires` 子句替代 SFINAE,应用 `std::erase_if` 等现代习语,提升代码可读性和简洁性 - **严格别名问题修复**:移除了 3 处编译器警告抑制指令,通过正确使用 `static_cast` 和基于值的操作替代危险的引用类型转换,解决潜在的未定义行为 ### 3. 技术要点 重点修复了 `program.h`、`shader_variable.h` 等核心文件中的类型双关 (type punning) 问题,将不安全的 C 风格引用转换改为类型安全的实现,同时新增了单元测试文件 `program_test.cc` 确保重构正确性。 ### 4. 影响评估 纯代码质量提升,不改变功能行为,提高了 WebGPU 后端的代码健壮性和可维护性,为后续开发奠定更好的基础。

📁 Changed Files (19 files, 401 changes: +200/-201)
cmake/onnxruntime_providers_webgpu.cmake
onnxruntime/contrib_ops/webgpu/bert/bias_add.cc
onnxruntime/contrib_ops/webgpu/bert/rotary_embedding.cc
onnxruntime/core/providers/webgpu/math/einsum.cc
onnxruntime/core/providers/webgpu/math/unary_elementwise_ops.cc
onnxruntime/core/providers/webgpu/nn/pool.cc
onnxruntime/core/providers/webgpu/program.h
onnxruntime/core/providers/webgpu/program_test.cc
onnxruntime/core/providers/webgpu/reduction/reduction_ops.cc
onnxruntime/core/providers/webgpu/reduction/reduction_ops.h
onnxruntime/core/providers/webgpu/shader_helper.cc
onnxruntime/core/providers/webgpu/shader_variable.cc
onnxruntime/core/providers/webgpu/shader_variable.h
onnxruntime/core/providers/webgpu/string_utils.h
onnxruntime/core/providers/webgpu/tensor/split.cc
onnxruntime/core/providers/webgpu/tensor/upsample.cc
onnxruntime/core/providers/webgpu/webgpu_context.cc
onnxruntime/core/providers/webgpu/webgpu_context.h
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
👤 guschmue📅 Created: 03/29/2026
🤖 AI 摘要

## PR 主要改动总结 **核心功能:** 为 ONNX Runtime 的 WebGPU 后端添加了 `LinearAttention` 和 `CausalConvWithState` 两个算子的支持,这是基于 ONNX 提案实现的贡献算子。 **解决的问题:** 使 Qwen3.5 系列模型能够在 WebGPU 上高效运行,提供了 fp16 和 q4 量化版本的参考实现。这两个算子是新型注意力机制的关键组件,对提升模型推理性能至关重要。 **技术要点:** - 新增了完整的算子实现(~771 行核心代码)和单元测试(~1393 行测试代码) - 同时补充了相关的 RMS Norm、Rotary Embedding、Attention 等 LLM 基础算子的 WebGPU 实现 - 涉及 Reshape、Concat 等现有算子的优化调整,确保算子间的协同工作 **影响:** 这是 WebGPU 支持现代 LLM 架构的重要里程碑,使浏览器端能够原生运行 Qwen3.5 等新一代高效语言模型。

📁 Changed Files (23 files, 3300 changes: +3293/-7)
onnxruntime/contrib_ops/webgpu/bert/causal_conv_with_state.cc
onnxruntime/contrib_ops/webgpu/bert/causal_conv_with_state.h
onnxruntime/contrib_ops/webgpu/bert/causal_conv_with_state.wgsl.template
onnxruntime/contrib_ops/webgpu/bert/linear_attention.cc
onnxruntime/contrib_ops/webgpu/bert/linear_attention.h
onnxruntime/contrib_ops/webgpu/bert/linear_attention.wgsl.template
onnxruntime/contrib_ops/webgpu/webgpu_contrib_kernels.cc
onnxruntime/core/graph/contrib_ops/bert_defs.cc
onnxruntime/core/graph/contrib_ops/ms_opset.h
onnxruntime/core/providers/webgpu/llm/attention.cc
onnxruntime/core/providers/webgpu/llm/attention.h
onnxruntime/core/providers/webgpu/llm/rotary_embedding.cc
onnxruntime/core/providers/webgpu/llm/rotary_embedding.h
onnxruntime/core/providers/webgpu/nn/rms_norm.cc
onnxruntime/core/providers/webgpu/nn/rms_norm.h
onnxruntime/core/providers/webgpu/tensor/concat.cc
onnxruntime/core/providers/webgpu/tensor/reshape.cc
onnxruntime/core/providers/webgpu/tensor/transpose.cc
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
onnxruntime/core/providers/webgpu/webgpu_supported_types.h
onnxruntime/test/contrib_ops/causal_conv_with_state_op_test.cc
onnxruntime/test/contrib_ops/linear_attention_op_test.cc
onnxruntime/test/providers/cpu/tensor/concat_op_test.cc
ep:WebGPU
👤 guschmue📅 Created: 03/27/2026
🤖 AI 摘要

## PR 改动总结 **主要功能:** 为 ONNX Runtime 的 WebGPU 执行提供程序添加了 LSTM(长短期记忆网络)算子的完整支持,新增了约 666 行代码实现 LSTM 的 GPU 加速计算。 **解决的问题:** 填补了 WebGPU 后端对循环神经网络(RNN)中核心算子 LSTM 的支持空白,使得包含 LSTM 层的模型能够在 WebGPU 环境中运行,扩展了 WebGPU 后端对序列建模任务的支持能力。 **对 WebGPU 的影响:** 显著增强了 WebGPU 执行提供程序对深度学习模型的覆盖范围,特别是自然语言处理、时间序列预测等需要 LSTM 的场景,提升了浏览器端运行复杂 RNN 模型的能力。 **技术要点:** 实现包含独立的 LSTM 头文件和实现文件(lstm.h/cc),并在 WebGPU 执行提供程序中注册该算子,涉及 LSTM 特有的门控机制、隐藏状态管理和 GPU 计算着色器的适配。

📁 Changed Files (3 files, 666 changes: +666/-0)
onnxruntime/core/providers/webgpu/rnn/lstm.cc
onnxruntime/core/providers/webgpu/rnn/lstm.h
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
ep:WebGPU
👤 guschmue📅 Created: 03/27/2026
🤖 AI 摘要

## PR 主要改动总结 **核心功能:** 为 ONNX Runtime 的 WebGPU 执行提供器添加了 LpNorm(Lp范数)算子的支持,新增了完整的实现文件和头文件。 **解决问题:** 补充了 WebGPU 后端对 LpNorm 算子的支持,使得使用该算子的模型可以在 WebGPU 环境下运行,增强了 WebGPU 执行提供器的算子覆盖率。 **技术实现:** 新增代码约182行,包括算子的 GPU 实现逻辑(lp_norm.cc)和接口定义(lp_norm.h),并在 WebGPU 执行提供器中注册了该算子。 **影响范围:** 这是一个纯新增特性,不影响现有功能,进一步完善了 ONNX Runtime 在 Web 端的深度学习推理能力。

📁 Changed Files (3 files, 182 changes: +182/-0)
onnxruntime/core/providers/webgpu/nn/lp_norm.cc
onnxruntime/core/providers/webgpu/nn/lp_norm.h
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
ep:WebGPU
👤 fs-eire📅 Created: 03/25/2026
🤖 AI 摘要

## PR 主要改动总结 **核心功能:** 此 PR 为 ONNX Runtime 的 WebGPU Execution Provider (EP) 插件建立了完整的 CI/CD 打包流水线,支持 Windows (x64/arm64)、Linux (x64) 和 macOS (arm64) 四个平台的自动化构建和打包。 **解决的问题:** 通过新增 Azure Pipelines 配置文件和构建脚本,实现了 WebGPU 插件的跨平台自动化编译、打包和发布流程。主要包括主流水线文件 (`plugin-webgpu-pipeline.yml`)、各平台的构建阶段模板 (stage.yml)、以及构建变量设置模板,支持参数化配置 API 版本、包版本和构建类型。 **技术要点:** 采用模块化的流水线设计,每个平台有独立的 stage 模板文件;新增了 Linux 平台的构建脚本 (`build_webgpu_plugin_package.sh`);对 CMake 配置和分配器头文件进行了小幅调整以支持插件架构。整体改动以基础设施代码为主 (858 行新增),为 WebGPU EP 的插件化分发奠定了自动化基础。

📁 Changed Files (11 files, 839 changes: +836/-3)
cmake/onnxruntime_providers_webgpu.cmake
include/onnxruntime/ep/api.h
onnxruntime/core/providers/webgpu/ep/factory.cc
onnxruntime/core/session/onnxruntime_c_api.cc
tools/ci_build/github/azure-pipelines/plugin-webgpu-pipeline.yml
tools/ci_build/github/azure-pipelines/stages/plugin-linux-webgpu-stage.yml
tools/ci_build/github/azure-pipelines/stages/plugin-mac-webgpu-stage.yml
tools/ci_build/github/azure-pipelines/stages/plugin-webgpu-packaging-stage.yml
tools/ci_build/github/azure-pipelines/stages/plugin-win-webgpu-stage.yml
tools/ci_build/github/azure-pipelines/templates/set-plugin-build-variables-step.yml
tools/ci_build/github/linux/build_webgpu_plugin_package.sh
🤖 AI 摘要

## PR 主要改动总结 ### 核心功能 为 ONNX Runtime 的 WebGPU 后端新增了三个缺失的算子实现:**SpaceToDepth**、**ConstantOfShape** 和 **Compress**,共新增约 607 行代码。 ### 解决的问题 在优化 lfm2-vl 视觉模型时发现这些算子缺失导致推理过程中产生大量 **CPU 与 GPU 之间的数据拷贝**,严重影响性能。实现这些算子后,模型(特别是视觉编码器部分)的推理速度显著提升。 ### 技术实现 - 为每个算子分别创建了独立的头文件和实现文件(.h/.cc) - 在 `webgpu_execution_provider.cc` 中注册了新算子 - PR 开发主要借助 Claude Opus 4.6 生成,但经过人工审查、修正和测试验证 ### 影响意义 消除了 WebGPU 后端的关键算子空白,减少了推理时的 CPU-GPU 数据传输开销,增强了 WebGPU 在视觉模型上的实用性和性能表现。

📁 Changed Files (7 files, 607 changes: +607/-0)
onnxruntime/core/providers/webgpu/generator/constant_of_shape.cc
onnxruntime/core/providers/webgpu/generator/constant_of_shape.h
onnxruntime/core/providers/webgpu/tensor/compress.cc
onnxruntime/core/providers/webgpu/tensor/compress.h
onnxruntime/core/providers/webgpu/tensor/space_to_depth.cc
onnxruntime/core/providers/webgpu/tensor/space_to_depth.h
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
👤 edgchen1📅 Created: 03/21/2026
🤖 AI 摘要

## ONNX Runtime WebGPU MultiHeadAttention 修复总结 **主要改动:** 修复了 WebGPU 后端中 MultiHeadAttention 算子的 flash attention 路径在处理 past KV 缓存时的错误逻辑。当 `present_key/present_value` 输出未被请求时,flash attention 路径错误地仍然使用了 `past_key/past_value` 输入,而非 flash 路径则正确地忽略了这些输入。 **解决的问题:** 修复了在支持 subgroup 的 GPU 上(会选择 flash attention 路径)产生错误结果的问题。通过在 `ApplyFlashAttention` 中添加与 `ApplyAttention` 相同的检查逻辑:当 present 输出都为空时,将 past 输入置空并相应调整序列长度参数。 **技术要点:** 将函数参数签名从 const 引用改为按值传递,以允许在函数内部调整 past_key/past_value 和相关序列长度参数,确保两种 attention 实现路径的行为一致性。

📁 Changed Files (2 files, 14 changes: +12/-2)
onnxruntime/contrib_ops/webgpu/bert/flash_attention.cc
onnxruntime/contrib_ops/webgpu/bert/flash_attention.h