ONNX Runtime WebGPU PR Monitor

Last Updated: 04/25/2026, 06:54 PM | Total: 198 PRs

Showing 1-10 of 32 PRs
Page 1 of 4
👤 edgchen1📅 Created: 04/24/2026
🤖 AI 摘要

## PR 主要改动总结 **核心功能:** 为 ONNX Runtime 的 WebGPU 插件执行提供器(EP)添加了完整的 Python 打包支持,包括构建流程和自动化测试管道。 **主要内容:** 1. 新增了 Python wheel 包的构建脚本(`build_wheel.py`)和跨平台打包工具,支持 Linux、Windows 和 macOS 三个平台 2. 建立了完整的 CI/CD 测试管道(Azure Pipelines),包含针对各平台的打包测试阶段,确保 Python 包的质量和功能正确性 3. 添加了 171 行的单元测试代码和 Docker 构建配置,实现了从构建到测试的全流程自动化 **技术影响:** 此改动使得 WebGPU 插件 EP 可以作为独立的 Python 包进行分发和安装,显著降低了用户使用门槛,推动了 ONNX Runtime 在 WebGPU 平台上的部署能力。代码新增 1198 行,仅删除 16 行,是一次完整的功能性扩展。

📁 Changed Files (24 files, 1214 changes: +1198/-16)
include/onnxruntime/ep/adapter/op_kernel_info.h
plugin-ep-webgpu/README.md
plugin-ep-webgpu/VERSION_NUMBER
plugin-ep-webgpu/python/README.md
plugin-ep-webgpu/python/build_wheel.py
plugin-ep-webgpu/python/onnxruntime_ep_webgpu/README.md
plugin-ep-webgpu/python/onnxruntime_ep_webgpu/__init__.py
plugin-ep-webgpu/python/pyproject.toml
plugin-ep-webgpu/python/requirements-build-wheel.txt
plugin-ep-webgpu/python/setup.py
plugin-ep-webgpu/python/test/test_webgpu_plugin_ep.py
tools/ci_build/github/azure-pipelines/plugin-webgpu-pipeline.yml
tools/ci_build/github/azure-pipelines/plugin-webgpu-test-pipeline.yml
tools/ci_build/github/azure-pipelines/stages/plugin-linux-webgpu-stage.yml
tools/ci_build/github/azure-pipelines/stages/plugin-linux-webgpu-test-stage.yml
tools/ci_build/github/azure-pipelines/stages/plugin-mac-webgpu-stage.yml
tools/ci_build/github/azure-pipelines/stages/plugin-mac-webgpu-test-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/stages/plugin-win-webgpu-test-stage.yml
tools/ci_build/github/azure-pipelines/templates/set-plugin-build-variables-step.yml
tools/ci_build/github/linux/build_webgpu_plugin_python_package.sh
tools/ci_build/github/linux/docker/inference/x86_64/python/webgpu/Dockerfile
tools/ci_build/github/linux/docker/inference/x86_64/python/webgpu/scripts/install_centos.sh
👤 titaiwangms📅 Created: 04/23/2026
🤖 AI 摘要

## PR 主要改动总结 **核心改动:** 为 WebGPU 和 JavaScript 实现的 RotaryEmbedding 算子添加 position_ids 边界校验,补全之前 PR #27597 中仅覆盖 CPU 和 CUDA 的安全修复。 **解决的问题:** 修复 `com.microsoft::RotaryEmbedding` 算子使用 position_ids 作为 cos_cache/sin_cache 索引时缺少边界检查的安全漏洞。WebGPU 硬件会静默截断越界读取,导致错误结果而不报错,存在安全隐患。 **WebGPU 影响:** 在 WebGPU 实现中添加了双重防护机制:主机端通过 ORT_MAKE_STATUS 进行严格校验,着色器端对越界访问进行防御性处理(pass-through)。同时为 TypeScript 版本添加了基于 getBigInt64Array 的校验逻辑。 **技术要点:** 新增 7 个 C++ 越界测试用例,覆盖 contrib 和 ONNX 域;WebGPU 实现支持 format-0 格式感知校验;总共添加 333 行代码以确保跨平台的边界安全性。

📁 Changed Files (6 files, 359 changes: +333/-26)
js/web/lib/wasm/jsep/init.ts
js/web/lib/wasm/jsep/webgpu/ops/rotary-embedding.ts
onnxruntime/contrib_ops/webgpu/bert/rotary_embedding.cc
onnxruntime/core/providers/webgpu/llm/rotary_embedding.cc
onnxruntime/test/contrib_ops/rotary_embedding_op_test.cc
onnxruntime/test/providers/cpu/llm/rotary_embedding_op_test.cc
🤖 AI 摘要

## PR 主要改动总结 **注意:此 PR 与 WebGPU 无关,是针对 CUDA 后端的改进** ### 核心改动 为 CUDA PagedAttention 算子添加了 CUTLASS 内存高效注意力机制(MEA)作为降级方案,首次在 **sm<80 架构(Turing/Volta/Pascal)上支持 fp16 的 PagedAttention**。 ### 解决的问题 - 原实现仅支持 sm>=80(Ampere 及更新架构)的 FlashAttention,在旧架构上会直接报错 - 现在 sm<80 + fp16 可通过 MEA 正常运行;sm>=80 默认仍使用 FlashAttention,可通过环境变量切换到 MEA 用于调试和性能对比 - 注意 bf16 在 sm<80 上仍不支持(MEA 的 bf16 需要 sm>=80) ### 技术要点 修改主要集中在实现层(`paged_attention_impl.cu` +204 行)和算子逻辑层(`paged_attention.cc` +85 行),增加了内核选择逻辑和 MEA 实现路径,并补充了相应的 Python 测试用例。

📁 Changed Files (6 files, 441 changes: +425/-16)
onnxruntime/contrib_ops/cuda/bert/attention_data.h
onnxruntime/contrib_ops/cuda/bert/paged_attention.cc
onnxruntime/contrib_ops/cuda/bert/paged_attention.h
onnxruntime/contrib_ops/cuda/bert/paged_attention_impl.cu
onnxruntime/contrib_ops/cuda/bert/paged_attention_impl.h
onnxruntime/test/python/transformers/test_paged_attention_cuda.py
👤 xhcao📅 Created: 04/23/2026
🤖 AI 摘要

## PR 主要改动总结 ### 核心改动 这个 PR 优化了 WebGPU 后端的矩阵乘法(MatMul)操作,当 `batchB==1` 时,将 `batchA` 维度合并到 `M` 维度中进行计算。 ### 解决的问题 针对 M 维度较小但 batchA 维度较大的场景,原有实现会在每个 tile 中产生大量无效元素。通过维度合并减少了 workgroup 数量,提升了计算效率和 GPU 利用率。 ### 技术影响 修改了 WebGPU 和 Intel 供应商特定的 MatMul 实现逻辑,优化了工作组调度策略。同时增加了相应的测试用例(32 行)以验证维度合并的正确性。 ### 技术要点 这是一个针对批量矩阵乘法的性能优化,通过重塑张量维度来改善 GPU 并行计算的工作负载分布,特别适用于非对称批量场景(一侧有批量维度,另一侧为单批次)。

📁 Changed Files (3 files, 58 changes: +44/-14)
onnxruntime/core/providers/webgpu/math/matmul.cc
onnxruntime/core/providers/webgpu/vendor/intel/math/matmul.cc
onnxruntime/test/providers/cpu/math/matmul_test.cc
ep:WebGPU
👤 xhcao📅 Created: 04/22/2026
🤖 AI 摘要

## PR 主要改动总结 **主要功能改动:** 针对 WebGPU 的 ReduceMean 算子优化了计算策略选择逻辑。当输出尺寸远大于归约维度大小时,改用朴素归约(naive reduction)方法替代共享内存归约方法。 **解决的问题:** 解决了共享内存归约方法在特定场景下的性能问题。当输出维度较大时,共享归约可能需要对输入进行转置操作,这会带来显著的时间开销,影响整体性能。 **对 WebGPU 支持的影响:** 通过根据数据维度特征智能选择归约算法,提升了 WebGPU 后端在处理大输出尺寸归约操作时的执行效率。 **技术要点:** 代码改动量很小(仅 3 行新增,1 行删除),通过添加条件判断实现算法切换,属于性能优化类改动。

📁 Changed Files (1 files, 25 changes: +16/-9)
onnxruntime/core/providers/webgpu/reduction/reduction_ops.cc
ep:WebGPU
👤 Jiawei-Shao📅 Created: 04/21/2026
🤖 AI 摘要

## PR 主要改动总结 **核心功能:** 该 PR 为 WebGPU 后端添加了对批量大小(batch size)> 1 时的 Split-K 优化支持。通过在 dispatch_z 维度同时编码批次索引和 Split-K 索引,并在着色器中通过除法和取模运算进行解码(`batch = logical_global_id.z / num_k_splits` 和 `split_index = logical_global_id.z % num_k_splits`)来实现。 **解决的问题:** 优化了多批次矩阵乘法的性能,在 Intel PTL 硬件上对 `sam-vit-b-decoder-static-fp16-demo` 模型实现了 7.5% 的性能提升。同时将批量大小纳入 Split-K 启用条件,因为增加批量大小本身就能提高并行度,从而降低 Split-K 的优化效果。 **技术要点:** 主要修改集中在 GEMM/MatMul 相关代码(gemm_utils.cc、matmul.cc、matmul_packed.cc 等),增加了 200+ 行代码和相应的测试用例。另外将 `ort_version_check.h` 中的 `consteval` 改为 `constexpr` 以解决 VS2022 的编译错误。

📁 Changed Files (11 files, 296 changes: +238/-58)
onnxruntime/core/providers/webgpu/math/gemm_packed.cc
onnxruntime/core/providers/webgpu/math/gemm_utils.cc
onnxruntime/core/providers/webgpu/math/matmul.cc
onnxruntime/core/providers/webgpu/math/matmul.h
onnxruntime/core/providers/webgpu/math/matmul_packed.cc
onnxruntime/core/providers/webgpu/math/matmul_packed.h
onnxruntime/core/providers/webgpu/webgpu_utils.cc
onnxruntime/core/providers/webgpu/webgpu_utils.h
onnxruntime/core/session/ort_version_check.h
onnxruntime/test/providers/cpu/math/matmul_test.cc
onnxruntime/test/providers/cpu/nn/conv_op_test.cc
ep:WebGPU
🤖 AI 摘要

## PR 主要改动总结 **核心改动:** 此 PR 移除了 `op_kernel_info.h` 头文件中不安全的 `reinterpret_cast` 强制类型转换,改用 ONNX Runtime 的 C API 调用来实现相同功能。 **解决的问题:** 修复了跨 DLL 边界的 ABI 兼容性问题。原先将 `OrtKernelInfo*` 直接转换为内部 `OpKernelInfo*` 会导致 vtable 不匹配,当 WebGPU 插件 EP 与旧版本 ORT(如 1.24.4)一起使用时,由于虚函数表结构变化会引发崩溃。 **技术实现:** 改用 `Ort::ConstKernelInfo::GetEp()` 替代直接访问执行提供器,使用 `KernelInfoGetAllocator` C API 和 `IAllocatorImplWrappingOrtAllocator` 包装器替代直接类型转换,确保了跨版本的二进制兼容性。 **WebGPU 影响:** 提升了 WebGPU 插件 EP 与不同版本 ONNX Runtime 的兼容性和稳定性,避免了版本升级时的崩溃问题。

📁 Changed Files (2 files, 89 changes: +78/-11)
include/onnxruntime/ep/adapter/allocator.h
include/onnxruntime/ep/adapter/op_kernel_info.h
👤 sushraja-msft📅 Created: 04/14/2026
🤖 AI 摘要

## PR 主要改动总结 ### 核心功能 为 ONNX Runtime WebGPU 实现了 **TurboQuant 量化加速技术**,这是一个正在开发中的实验性功能,用于优化大语言模型的推理性能。 ### 技术实现 - 采用 **Hadamard 矩阵进行旋转变换**替代论文中的常规矩阵方法,实现了自定义的 TurboQuant 变体 - 主要集成在 Flash Attention 和 Group Query Attention (GQA) 模块中,新增了旋转量化 (rotate_quantize) 的 WebGPU shader 实现 - 基准测试显示在 Phi-4 模型上获得了显著性能提升:**prompt 处理速度达到 1790 tokens/s,token 生成速度为 99.8 tokens/s** ### 代码结构 新增了完整的 TurboQuant 基础设施,包括 Hadamard 变换核心逻辑、WGSL shader 模板、GQA 测试用例和详细的实现计划文档(646 行),共计 2700+ 行新代码,为后续优化奠定基础。

📁 Changed Files (23 files, 2778 changes: +2739/-39)
.vscode/settings.json
cmake/CMakeLists.txt
docs/turbo_quant_plan.md
onnxruntime/contrib_ops/webgpu/bert/attention_common.h
onnxruntime/contrib_ops/webgpu/bert/flash_attention.cc
onnxruntime/contrib_ops/webgpu/bert/flash_attention.h
onnxruntime/contrib_ops/webgpu/bert/flash_attention.wgsl.template
onnxruntime/contrib_ops/webgpu/bert/flash_attention_decode_qkt.wgsl.template
onnxruntime/contrib_ops/webgpu/bert/flash_attention_decode_split_vx.wgsl.template
onnxruntime/contrib_ops/webgpu/bert/group_query_attention.cc
onnxruntime/contrib_ops/webgpu/bert/turbo_quant_common.wgsl.template
onnxruntime/contrib_ops/webgpu/bert/turbo_quant_hadamard.cc
onnxruntime/contrib_ops/webgpu/bert/turbo_quant_hadamard.h
onnxruntime/contrib_ops/webgpu/bert/turbo_quant_rotate_quantize.wgsl.template
onnxruntime/core/providers/webgpu/compute_context.h
onnxruntime/core/providers/webgpu/program_manager.cc
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
onnxruntime/core/providers/webgpu/webgpu_execution_provider.h
onnxruntime/core/providers/webgpu/webgpu_provider_factory.cc
onnxruntime/core/providers/webgpu/webgpu_provider_options.h
samples/cxx/CMakeLists.txt
samples/cxx/GqaTest.cc
samples/cxx/generate_gqa_model.py
👤 xenova📅 Created: 04/13/2026
🤖 AI 摘要

## PR 主要改动总结 **1. 主要功能:** 此 PR 为 ONNX Runtime 的 WebGPU 后端实现了 DeformConv(可变形卷积)算子,新增了约 370 行实现代码和相应的头文件。 **2. 解决的问题:** 添加 DeformConv 算子支持是为了运行 BiRefNet 模型,填补了 WebGPU 后端在该算子上的功能空缺。 **3. 对 WebGPU 的影响:** 增强了 WebGPU 执行提供程序的算子覆盖范围,使其能够支持更多依赖可变形卷积的深度学习模型,特别是图像分割类模型。 **4. 技术要点:** 在 `webgpu_execution_provider.cc` 中注册了新算子,实现遵循 ONNX 标准的 DeformConv 规范,同时更新了版本检查相关配置。

📁 Changed Files (4 files, 413 changes: +406/-7)
onnxruntime/core/providers/webgpu/nn/deform_conv.cc
onnxruntime/core/providers/webgpu/nn/deform_conv.h
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
onnxruntime/core/session/ort_version_check.h
ep:WebGPU
🤖 AI 摘要

## PR 改动总结 **主要改动:** 修复了 WebGPU 后端中 MultiHeadAttention 算子在没有 present 输出时错误处理 past key/value 输入的问题。 **解决的问题:** 当 MHA 只有 1 个输出(无 present_key/present_value 输出)时,past key/value 应该被完全忽略以匹配 CPU 后端语义,但之前的实现仍将其传递给 shader,导致: - past 数据泄漏到注意力计算中,产生错误结果(输出 pastValue 数据而非预期的 V 数据) - shader 缓存键受到不必要的影响 **技术方案:** 在 `applyAttention()` 函数中引入 `effectivePastKey`/`effectivePastValue` 变量,当 `outputCount <= 1` 时将其设为 `undefined`,确保所有下游使用(shader 创建、输入数组)都基于这些有效值而非原始参数,从而正确隔离 past 数据的影响。

📁 Changed Files (1 files, 15 changes: +9/-6)
js/web/lib/wasm/jsep/webgpu/ops/attention.ts