Skip to content

[WebGPU] Regenerate WGSL in-tree golden fixtures to match current templates - #32115

Merged
Ananya Anand (4n4ny4) merged 1 commit into
microsoft:mainfrom
4n4ny4:webgpu-wgsl-goldens-resync
Aug 21, 2026
Merged

[WebGPU] Regenerate WGSL in-tree golden fixtures to match current templates#32115
Ananya Anand (4n4ny4) merged 1 commit into
microsoft:mainfrom
4n4ny4:webgpu-wgsl-goldens-resync

Conversation

@4n4ny4

@4n4ny4 Ananya Anand (4n4ny4) commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Description

Regenerates the WGSL in-tree golden fixtures. No production code changes; every file
touched lives under onnxruntime/test/in_tree_golden/.

Generated with:

UPDATE_WGSL_GOLDEN=1 python tools/python/wgsl_template/test/run_tests.py

Before: Ran 87 tests, FAILED (failures=2)
After: Ran 87 tests, OK

Three fixtures are new or rewritten: subgroup_matrix_gemm_8x16x16,
subgroup_matrix_matmul_8x16x16, subgroup_matrix_matmul_pad_b. The remaining churn in
im2col_matmul.h, oihw_to_ohwi.h, pad.h and string_table.h is index renumbering: the
generator emits one globally numbered string table, so adding literals shifts every
downstream __str_N index. Those files are unchanged once the indices are normalized.

Motivation and Context

The in-tree golden test compares the whole generated tree against committed fixtures, so it
fails on main today. The subgroup-matrix templates were added or rewritten without
regenerating the goldens.

The in-tree golden test compares the entire generated tree against committed
fixtures, so it fails on main today: subgroup_matrix_gemm_8x16x16,
subgroup_matrix_matmul_8x16x16 and subgroup_matrix_matmul_pad_b were added or
rewritten without regenerating the goldens.

The generator emits one globally numbered string table, so new literals shift
every downstream __str_N index. That accounts for the churn in im2col_matmul.h,
oihw_to_ohwi.h and pad.h, which are unchanged once the indices are normalized.

Before: Ran 87 tests, FAILED (failures=2)
After:  Ran 87 tests, OK

Generated with: UPDATE_WGSL_GOLDEN=1 python tools/python/wgsl_template/test/run_tests.py

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 16, 2026 23:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 15 changed files in this pull request and generated no new comments.

@qjia7

Copy link
Copy Markdown
Contributor

Edward Chen (@edgchen1), could you help add the Python WGSL template tests as a required CI check for changes to WebGPU .wgsl.template files or the WGSL generator?

Some background: the in-tree golden test was introduced on June 16, 2026, in PR #28355 ("Add python implementation for wgsl-gen"). It generates C++ from the real WebGPU templates using both static-cpp and static-cpp-literal, then compares the results with committed snapshots under tools/python/wgsl_template/test/in_tree_golden.

Subsequent PRs #29592, #29749, #29813, and #29893 added or rewrote subgroup-matrix templates without regenerating those snapshots. As a result, main had two failing golden comparisons. PR #32115 regenerates and synchronizes the fixtures.

Existing WebGPU build and kernel tests did not catch the stale snapshots because wgsl_template_python_tests is registered only in a specific WebGPU CTest configuration and apparently is not enforced by the relevant CI paths.

The check is lightweight--87 tests complete in under a second locally:

python tools\python\wgsl_template\test\run_tests.py

Ideally, it should run when files under onnxruntime/core/providers/webgpu/**/*.wgsl.template or tools/python/wgsl_template/** change. This would catch missing golden regeneration before merge.

Ananya Anand (4n4ny4) added a commit to 4n4ny4/onnxruntime that referenced this pull request Aug 20, 2026
The previous regeneration updated the per-template generated headers but
not the aggregate index.h, so generated/nn/im2col_matmul.h referenced
params.param_activation_kind against a struct that did not declare it.

Regenerated with the canonical command documented in test_in_tree_smoke.py:

    UPDATE_WGSL_GOLDEN=1 python wgsl_template/test/run_tests.py

Only index.h changed in each variant. index_impl.h, string_table.h and
every file under generated/ were already byte-identical to the generator
output, so the earlier regeneration was correct apart from this one file.

Of the 60 added lines per variant, one is the missing
param_activation_kind member; the other 59 are declarations for the three
math/subgroup_matrix_* templates, which have been on main since 56598d6
without their goldens ever being regenerated. Their generated/math/*.h
bodies are deliberately left out here: they are supplied by microsoft#32115, which
fixes that pre-existing drift on its own. The in-tree golden smoke test
therefore still reports a file-set difference for those three headers
until microsoft#32115 lands, but no longer reports any content mismatch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Ananya Anand (4n4ny4) added a commit to 4n4ny4/onnxruntime that referenced this pull request Aug 20, 2026
…factor

The uniforms refactor and the im2col fusion change were landing together, but
they are different kinds of change. Moving activation parameters into uniforms
preserves existing behaviour for kernels that already ran. Enabling fusion on
the im2col path removes a `// TODO: Support fuse` guard and makes a different
kernel run for real fused NHWC convolutions.

That second change cannot be exercised anywhere available. Im2ColMatMulProgram
requires an adapter reporting vendor "intel" and architecture "xe-2lpg",
"xe-2hpg", "xe-3lpg" or "xe-3lpg-xs" -- Lunar Lake, Battlemage or Panther Lake.
No ORT CI agent has one, and no machine available during development does
either, so its three parity tests GTEST_SKIP everywhere. It deserves its own
review rather than riding along with a behaviour-preserving refactor.

Reverted to their state on main:

  nn/im2col_matmul.cc
  nn/im2col_matmul.h
  nn/im2col_matmul.wgsl.template

conv.cc keeps its four activation-uniform hunks but reverts the three that were
only there to carry the Activation into the im2col path: both
CanApplyIm2ColMatMulProgram call sites go back to passing
`activation_.activation_kind_ != ActivationKind::None`, and
ApplyIm2ColMatMulProgram loses its activation argument. Reverting the three
im2col files without these would not compile.

graph_transform_test.cc loses RunWebGpuIm2ColActivationParity, its three tests,
and `#include <fstream>`, which this branch added solely for that helper's
profile reader.

fuse_utils.h loses the comment claiming ActivationKind values are mirrored by
im2col_matmul.wgsl.template, which is no longer true here. Everything else it
gained is still required: WEBGPU_PROGRAM_ACTIVATION_UNIFORM_VARIABLES is used by
six programs, and AppendActivationUniformsData is called at eight sites.

Goldens regenerated with the canonical command:

    UPDATE_WGSL_GOLDEN=1 python wgsl_template/test/run_tests.py

Beyond the expected im2col_matmul.h churn, this renumbers __str_N indices in
static-cpp/generated/tensor/{pad,oihw_to_ohwi}.h, because the six activation
string fragments left the shared string table and every later index shifts down
by six. static-cpp-literal is unaffected there since it embeds its strings. The
index_impl.h change is the content-hash comment on the im2col include.

The generated/math/subgroup_matrix_*.h bodies remain deliberately absent; they
are supplied by microsoft#32115. The in-tree golden smoke test therefore still reports a
file-set difference for those three headers, and no content mismatch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Ananya Anand (4n4ny4) pushed a commit to 4n4ny4/onnxruntime that referenced this pull request Aug 20, 2026
This branch adds param_quick_gelu_unit_alpha to the im2col_matmul template but did not regenerate the aggregate index.h, and it is based on the pre-fix microsoft#32116 commit, so index.h was also still missing param_activation_kind. generated/nn/im2col_matmul.h referenced both against a struct that declared neither.

Regenerated with the canonical command documented in test_in_tree_smoke.py:

    UPDATE_WGSL_GOLDEN=1 python wgsl_template/test/run_tests.py

Only index.h changed in each variant. index_impl.h, string_table.h and every file under generated/ were already byte-identical to the generator output, so the earlier regeneration was correct apart from this one file.

Of the 61 added lines per variant, two are the missing param_activation_kind and param_quick_gelu_unit_alpha members; the other 59 are declarations for the three math/subgroup_matrix_* templates, which land in microsoft#32115. The bulky generated/math/*.h bodies are deliberately left out so this PR does not duplicate that payload; index.h is a single aggregate file and cannot be split, matching the precedent set on microsoft#32116.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@4n4ny4
Ananya Anand (4n4ny4) merged commit 775526b into microsoft:main Aug 21, 2026
90 of 92 checks passed
@4n4ny4
Ananya Anand (4n4ny4) deleted the webgpu-wgsl-goldens-resync branch August 21, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants