ONNX Runtime WebGPU PR Monitor

Last Updated: 10/14/2026, 09:29 PM | Total: 627 PRs

Showing 1-10 of 107 PRs
Page 1 of 11
🤖 AI 摘要

该 PR 为 WebGPU 增加可选的 MatMulNBits 与 LoRA/QLoRA 融合,将量化基座投影与适配器分支组合执行,旨在减少 GPU 调度和输入传输开销,同时保持适配器可替换、基座权重不变。实现包括面向 FP16 适配器的 MatMulNBitsLoRA、面向打包 INT8 适配器的 MatMulNBitsQLoRA,以及配套的算子定义、图融合优化和测试;首期仅支持 rank 32、FP16 激活、INT4 block-32 基座权重、隐式零点且无偏置的场景。Prefill 采用 fuse_up,先计算低秩中间结果,再将升维投影和残差加法融合到基座投影中;符合条件的 QLoRA DP4A 路径复用一次 X 量化,并针对窄投影使用 small-M 归约及 N < 64 时的 32 列分块。Decode 采用 fuse_down 联合调度基座投影和降维投影,但描述在后续向量处理处截断,无法确定完整执行流程;现有信息也未提供实测性能数据,因此只能确认其优化目标和适用范围,不能断言具体加速幅度或设备覆盖情况。

📁 Changed Files (30 files, 4026 changes: +3707/-319)
cmake/onnxruntime_unittests.cmake
docs/ContribOperators.md
docs/WebGPU_MatMulNBitsLoRA_Performance.md
docs/WebGPU_MatMulNBitsLoRA_Prototype.md
docs/WebGPU_MatMulNBitsQLoRA_Prototype.md
onnxruntime/contrib_ops/webgpu/quantization/dp4a_matmul.wgsl.template
onnxruntime/contrib_ops/webgpu/quantization/dp4a_matmul_nbits.cc
onnxruntime/contrib_ops/webgpu/quantization/dp4a_matmul_nbits.h
onnxruntime/contrib_ops/webgpu/quantization/dp4a_matmul_small_m.wgsl.template
onnxruntime/contrib_ops/webgpu/quantization/matmul_nbits.cc
onnxruntime/contrib_ops/webgpu/quantization/matmul_nbits.h
onnxruntime/contrib_ops/webgpu/quantization/matmul_nbits.wgsl.template
onnxruntime/contrib_ops/webgpu/quantization/matmul_nbits_lora.cc
onnxruntime/contrib_ops/webgpu/quantization/matmul_nbits_qlora.cc
onnxruntime/contrib_ops/webgpu/quantization/matmul_nbits_qlora.h
onnxruntime/contrib_ops/webgpu/quantization/matmul_nbits_wide_tile.wgsl.template
onnxruntime/contrib_ops/webgpu/webgpu_contrib_kernels.cc
onnxruntime/core/graph/contrib_ops/contrib_defs.cc
onnxruntime/core/optimizer/graph_transformer_utils.cc
onnxruntime/core/optimizer/matmul_nbits_lora_fusion.cc
onnxruntime/core/optimizer/matmul_nbits_lora_fusion.h
onnxruntime/core/optimizer/matmul_nbits_qlora_fusion.cc
onnxruntime/core/optimizer/matmul_nbits_qlora_fusion.h
onnxruntime/core/platform/telemetry_1ds.cc
onnxruntime/core/platform/telemetry_1ds.h
onnxruntime/core/platform/telemetry_1ds_platform.h
onnxruntime/core/platform/windows/telemetry_1ds.cc
onnxruntime/core/providers/webgpu/buffer_manager.cc
onnxruntime/core/providers/webgpu/buffer_manager.h
onnxruntime/core/providers/webgpu/data_transfer.cc
👤 gyagp📅 Created: 10/14/2026
🤖 AI 摘要

该改动修复 ONNX Runtime WebGPU 后端 LayerNormalization 在输入行包含较大且相近的数值时,因 E[x²] − E[x]² 的消减误差导致 NaN 或归一化缩放不准确的问题。实现上,标准 LayerNormalization 先对行数据做平移再计算均值偏移,并在普通与拆分调度的着色器中通过归约中心化偏差的平方计算方差,同时保持 SimplifiedLayerNormalization(RMSNorm)的计算方式不变。新增 FP32/FP16 常量及近常量回归用例,覆盖标量、vec2、vec4、拆分调度、偏置和统计量输出,并禁用 CPU 回退以验证 WebGPU 路径。Windows x64 Release、RTX 5080/D3D12 环境下相关测试共 63 项通过、无跳过,着色器转储也确认两种调度路径及 RMSNorm 算术符合预期;但未提供性能基准或其他设备、后端的验证结果,无法据此判断性能开销及跨平台表现。

📁 Changed Files (2 files, 163 changes: +149/-14)
onnxruntime/core/providers/webgpu/nn/layer_norm.cc
onnxruntime/test/providers/webgpu/layer_norm_test.cc
👤 gyagp📅 Created: 10/14/2026
🤖 AI 摘要

该改动修复了 GQA 前置归一化融合中的数值语义偏差:此前 Q/K 的 epsilon 差异不超过 1e-9 时仍允许融合,却将 Q 的值用于 K;现在可保留两者各自的值,并支持其他融合条件满足时任意正且有限的 epsilon 组合。实现上为 GroupQueryAttention 新增可选的 q_norm_epsilon 和 k_norm_epsilon,未设置时分别回退到原有 qk_norm_epsilon,相同 epsilon 的融合仍使用共享属性,以兼容已有模型。独立参数贯穿融合优化器及 WebGPU、CUDA 的归一化执行路径,并同步更新算子文档和回归测试,使不同 epsilon 的 Q/K 归一化也能在保留原始参数的前提下融合。Windows 新构建的验证结果显示,WebGPU 融合测试和 QK 归一化算子测试分别有 21 项和 5 项通过,CUDA 融合测试有 21 项通过,但提供的 CUDA 算子测试结果被截断,且没有性能基准,无法量化融合范围扩大带来的收益。

📁 Changed Files (15 files, 362 changes: +309/-53)
docs/ContribOperators.md
onnxruntime/contrib_ops/cpu/bert/attention_parameters.h
onnxruntime/contrib_ops/cuda/bert/attention_data.h
onnxruntime/contrib_ops/cuda/bert/group_query_attention.cc
onnxruntime/contrib_ops/cuda/bert/group_query_attention.h
onnxruntime/contrib_ops/cuda/bert/group_query_attention_impl.cu
onnxruntime/contrib_ops/cuda/bert/group_query_attention_qkv.cuh
onnxruntime/contrib_ops/webgpu/bert/group_query_attention.cc
onnxruntime/contrib_ops/webgpu/bert/group_query_attention.h
onnxruntime/contrib_ops/webgpu/bert/rotary_embedding.cc
onnxruntime/contrib_ops/webgpu/bert/rotary_embedding.h
onnxruntime/core/graph/contrib_ops/bert_defs.cc
onnxruntime/core/optimizer/group_query_attention_pre_norm_fusion.cc
onnxruntime/test/contrib_ops/group_query_attention_op_test.cc
onnxruntime/test/optimizer/group_query_attention_pre_norm_fusion_test.cc
👤 xiaofeihan1📅 Created: 10/14/2026
🤖 AI 摘要

该改动补齐 ONNX Runtime WebGPU 图捕获对 GPU 到 GPU 缓冲区复制的支持,使复制与计算派发按原始顺序重放,避免非原地 ScatterND、ScatterElements 等依赖数据复制的算子在图重放时遗漏操作。实现上引入区分计算派发与缓冲区复制的类型化命令序列,将 BufferManager::MemCpy 接入上下文的捕获感知复制路径,并在编码复制前处理此前延迟的派发、结束计算通道,延迟流水线编译仍仅用于计算派发。复制涉及的源、目标缓冲区会保留至图资源释放,重放复制不占用计算时间戳查询槽位,而主机上传、回读及分配器清零仍不纳入图捕获。测试新增了开启和关闭捕获时的非原地 Scatter 回归场景,在 GPU 地址固定的情况下改变输入以验证重放正确性;现有信息未提供性能基准,因此无法量化性能影响。

📁 Changed Files (7 files, 276 changes: +243/-33)
onnxruntime/core/providers/webgpu/buffer_manager.cc
onnxruntime/core/providers/webgpu/webgpu_context.cc
onnxruntime/core/providers/webgpu/webgpu_context.h
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc
onnxruntime/core/providers/webgpu/webgpu_execution_provider.h
onnxruntime/test/providers/graph_capture_test.cc
onnxruntime/test/providers/webgpu/webgpu_context_test.cc
👤 dannyota📅 Created: 10/14/2026
🤖 AI 摘要

该 PR 将 CPython 3.15 纳入 ONNX Runtime 的 CPU 与 CUDA 12/13 Python 打包流程,覆盖指定的 Windows、Linux 和 macOS 平台,并更新包元数据与冒烟测试,但不包含自由线程版 cp315t 或新增 GitHub Actions CI 作业。实现上调整了 Azure Pipelines 打包矩阵、Linux 打包解释器列表和构建测试逻辑,在 Python 3.15 上使用提供 cp315 wheel 的 NumPy 2.5.4,并将 torch、torchvision、triton、sentencepiece、h5py 及依赖 torch 测试的 neural-compressor 限制为 Python < 3.15,同时跳过 torch 依赖测试。新增测试主要覆盖 Python 打包、Linux 打包脚本和构建脚本的测试选择逻辑;分支工作流已在 Linux x64、Windows x64 和 macOS arm64 上验证 Python 3.14/3.15 CPU wheel,各任务均为 128 项通过、4 项 WebGPU 测试跳过。Linux cp315 wheel 还通过 WebGPU 插件执行提供程序在 Intel Arc GPU 上运行,提供了该组合可用性的验证,但现有信息未给出 CUDA 实测结果或性能基准,不能据此认定 GPU 性能提升或所有平台兼容性均已验证。

📁 Changed Files (24 files, 823 changes: +797/-26)
cmake/onnxruntime_unittests.cmake
onnxruntime/test/python/onnxruntime_test_python_symlink_data.py
onnxruntime/test/python/quantization/test_op_matmulnbits_prepacked_cuda.py
requirements-materialize-onnx-node-tests.txt
setup.py
tools/ci_build/build.py
tools/ci_build/github/azure-pipelines/py-cuda-package-test-pipeline.yml
tools/ci_build/github/azure-pipelines/py-cuda13-packaging-pipeline.yml
tools/ci_build/github/azure-pipelines/stages/py-cpu-packaging-stage.yml
tools/ci_build/github/azure-pipelines/stages/py-gpu-packaging-stage.yml
tools/ci_build/github/azure-pipelines/templates/py-package-smoking-test.yml
tools/ci_build/github/azure-pipelines/templates/py-win-cpu.yml
tools/ci_build/github/azure-pipelines/templates/set-python-manylinux-variables-step.yml
tools/ci_build/github/linux/build_linux_python_package.sh
tools/ci_build/github/linux/docker/inference/aarch64/python/cpu/scripts/requirements.txt
tools/ci_build/github/linux/docker/scripts/lort/requirements.txt
tools/ci_build/github/linux/docker/scripts/manylinux/requirements.txt
tools/ci_build/github/linux/docker/scripts/requirements.txt
tools/ci_build/github/linux/python/requirements.txt
tools/ci_build/github/windows/python/requirements.txt
tools/ci_build/requirements/transformers-test/requirements.txt
tools/ci_build/test_build_linux_python_package.py
tools/ci_build/test_build_python_tests.py
tools/ci_build/test_python_packaging.py
🤖 AI 摘要

此次重构将 WebGPU FlashAttention 的路径资格检查与执行逻辑拆分为独立辅助函数,由 ApplyFlashAttention() 按融合分页预填充、稠密预填充、split/reduce 的顺序选择内核;若均不适用则返回 NOT_IMPLEMENTED,避免分页缓存误入假定稠密存储的着色器。融合分页预填充要求未量化分页缓存、无 attention bias 和 head sink、BSNH QKV 布局以及 KV 和查询序列长度输入,并检查 FP16、查询长度至少为 32、共享内存容量及块与 tile 对齐条件。稠密预填充仅用于稠密缓存且查询长度至少为 32 的场景,同时验证所选着色器变体的工作组存储需求;短查询或稠密预填充超出存储预算时则转入 split/reduce。改动还涉及分页注意力调用处、预填充着色器模板、测试与设计文档,主要作用是明确缓存布局和设备资源约束下的内核选择边界;但描述在分页 decode 分支处截断,且未提供性能测量或测试结果,无法确认该分支的完整行为或量化性能收益。

📁 Changed Files (6 files, 573 changes: +289/-284)
docs/design/webgpu_paged_attention.md
onnxruntime/contrib_ops/webgpu/bert/flash_attention.cc
onnxruntime/contrib_ops/webgpu/bert/flash_attention.h
onnxruntime/contrib_ops/webgpu/bert/flash_attention_paged_prefill.wgsl.template
onnxruntime/contrib_ops/webgpu/bert/paged_attention.cc
onnxruntime/test/contrib_ops/paged_attention_op_test.cc
🤖 AI 摘要

该改动修复了 GQA 局部窗口 CPU 参考测试 FlashDecoding_LocalWindow_Reference_CPU 对线程池并行度的错误假设,实际修改位于注意力算子测试中,而非 WebGPU 推理内核。测试配置了 12 个线程,但在混合架构 CPU 上,ONNX Runtime 会通过 TaskGranularityFactor 放大调度并行度,使其报告为 48,导致原先的相等断言在执行注意力计算和校验输出之前失败。修复将断言改为 ASSERT_GE(..., thread_count),检查调度并行度不低于配置线程数,而不再要求二者相等。这提升了相关测试在混合架构 CPU 上的兼容性;所提供的信息未涉及 WebGPU 执行逻辑变更或性能测量,不能据此推断推理性能有所提升。

📁 Changed Files (1 files, 3 changes: +2/-1)
onnxruntime/test/contrib_ops/group_query_attention_op_test.cc
👤 aciddelgado📅 Created: 10/13/2026
🤖 AI 摘要

该改动将 ONNX Runtime WebGPU 的 FP16 MatMul GEMV 快速路径从仅支持 M=1 扩展到 1≤M≤8,旨在缓解推测解码中小 M 投影因切换到通用 MatMul 而出现的性能骤降,同时保留原有形状和结构约束。实现上,每行使用独立工作组,着色器从展平的工作组索引计算行号和列分组索引,并为输入输出访问添加行偏移,继续沿用 FP32 累加与归约。修改还涉及 MatMul 路径选择,并补充矩阵乘法与工作组调度归一化测试,以覆盖扩展后的执行场景。在 A100、WebGPU/Vulkan 环境下,针对 [M,5120]×[5120,48] 的独立内核测量显示,M=2、4、8 时相对通用 MatMul 约加速 5.15–5.57 倍;这些结果仅来自一次预热和三次测量的中位数,尚不能据此推断端到端生成收益或其他 GPU 上的表现。

📁 Changed Files (18 files, 3502 changes: +1873/-1629)
docs/design/webgpu_matmul_execution_planner.md
onnxruntime/core/providers/webgpu/math/matmul.cc
onnxruntime/core/providers/webgpu/math/matmul.h
onnxruntime/core/providers/webgpu/math/matmul_gemv.wgsl.template
onnxruntime/test/providers/webgpu/dispatch_normalization_test.cc
onnxruntime/test/providers/webgpu/math/matmul_test.cc
tools/python/wgsl_template/test/in_tree_golden/static-cpp-literal/generated/math/matmul_gemv.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp-literal/index_impl.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/math/matmul_gemv.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/math/subgroup_matrix_gemm_8x16x16.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/math/subgroup_matrix_matmul.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/math/subgroup_matrix_matmul_pad_b.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/nn/conv_transpose3d.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/nn/im2col_matmul.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/tensor/oihw_to_ohwi.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/generated/tensor/pad.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/index_impl.h
tools/python/wgsl_template/test/in_tree_golden/static-cpp/string_table.h
👤 kylo5aby📅 Created: 10/12/2026
🤖 AI 摘要

此改动修复了 If 分支直接返回、且未被分支内节点消费的 initializer 未获分配位置而默认留在 CPU 的问题,避免 If 运行于非 CPU 执行提供程序(EP)时,每次 Run 因分支输出源位置与取回目标不一致而产生两次拷贝。核心实现是在分配规划器的 ComputeValueLocation 中,将这类 initializer 放到 If 节点所属 EP 的默认设备,使其在会话初始化时一次性上传,运行时相关拷贝则变为设备到设备。对于 WebGPU 等非 CPU EP,这有助于减少重复的 CPU 到设备数据传输,但提供的信息未包含 WebGPU 专项测试或性能测量,无法量化收益。规则仅针对 If:Loop 的条件输出需取回 CPU,循环携带输出需匹配 Loop 输入位置,因此不适用父节点设备规则;Scan 也保持不变,并新增了针对 initializer 作为 If 子图输出的位置规划测试。

📁 Changed Files (2 files, 137 changes: +137/-0)
onnxruntime/core/framework/allocation_planner.cc
onnxruntime/test/framework/allocation_planner_test.cc
👤 qjia7📅 Created: 10/12/2026
🤖 AI 摘要

该 PR 修复 Windows 原生推理已完成并写出 profiling 结果后,进程退出仍可能卡在 1DS 遥测上传器清理流程的问题。实现上从已加载的 ntdll.dll 动态解析 RtlDllShutdownInProgress,在 OneDsTelemetry 析构函数获取遥测锁之前检测进程终止状态,并跳过上传器清理,因此退出时不会刷新待发送的遥测数据。该检测也适用于编译进 EP 插件 DLL 的遥测组件,正常对象析构和显式 FreeLibrary 仍走原有清理路径,非 Windows 行为不变,同时新增了 Windows 遥测生命周期测试及构建配置。此改动针对退出阶段的可靠性,不涉及 WebGPU 算子或 GPU 推理执行路径;现有信息未提供推理性能变化或具体 Windows 版本兼容性验证结果。

📁 Changed Files (8 files, 279 changes: +279/-0)
cmake/onnxruntime_unittests.cmake
onnxruntime/core/platform/telemetry_1ds.cc
onnxruntime/core/platform/telemetry_1ds.h
onnxruntime/core/platform/telemetry_1ds_platform.h
onnxruntime/core/platform/windows/telemetry_1ds.cc
onnxruntime/test/platform/windows_telemetry/lifecycle/telemetry_shutdown_test.cc
onnxruntime/test/platform/windows_telemetry/lifecycle/telemetry_shutdown_test_library.cc
onnxruntime/test/platform/windows_telemetry/lifecycle/telemetry_shutdown_test_library.def