Skip to content

Commit 044e16a

Browse files
[ExecuTorch][WebGPU] Consolidate landed-op tests into the cases.py op-test framework
Pull Request resolved: #20357 `add` and `rms_norm` already have declarative suites in the `cases.py` framework, so their standalone tests are redundant. Remove them, leaving the framework as the single home for these stateless single-forward ops (mirroring Vulkan). `update_cache` and `sdpa` stay hand-written — stateful KV-cache replay can't be a single `module -> golden` forward. Removed: - `test_single_add`/`test_chained_add` + their `main()` plumbing from `test_webgpu_native.cpp`. - the standalone `test/native/test_rms_norm.cpp` binary + its CMake target. - the add/rms_norm export+run wiring in `test_webgpu_native_ci.sh` + `test_build_webgpu.sh`. - `webgpu_native_test` re-gated on the executorch wheel being importable (was the add `.pte`); it still hosts the quantized_linear/SDPA/update_cache/symint sweeps. ghstack-source-id: 394625048 @exported-using-ghexport Differential Revision: [D108821384](https://our.internmc.facebook.com/intern/diff/D108821384/)
1 parent f1c6743 commit 044e16a

5 files changed

Lines changed: 19 additions & 367 deletions

File tree

backends/webgpu/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ endfunction()
138138

139139
if(EXECUTORCH_BUILD_WEBGPU_TEST)
140140
add_webgpu_native_test(webgpu_native_test test/test_webgpu_native.cpp)
141-
add_webgpu_native_test(webgpu_rms_norm_test test/native/test_rms_norm.cpp)
142141
add_webgpu_native_test(
143142
webgpu_dispatch_order_test test/native/test_dispatch_order.cpp
144143
)

backends/webgpu/scripts/test_webgpu_native_ci.sh

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
# Build + run the WebGPU native test executables on Dawn (Tint) + SwiftShader.
99
# This is the substantive op-coverage gate: unlike the python operators suite
1010
# (which only delegates add.Tensor to WebGPU, the rest CPU-fallback), these
11-
# executables run rms_norm / multi-dispatch ordering / scratch through the real
12-
# WebGPU backend on Dawn.
11+
# executables run quantized_linear / SDPA / update_cache / multi-dispatch
12+
# ordering / scratch through the real WebGPU backend on Dawn. (Simple ops —
13+
# add / rms_norm / the misc ops — run through the cases.py op-test framework.)
1314
#
1415
# Assumes the Dawn env is already sourced (Dawn_DIR + VK_ICD_FILENAMES +
1516
# LD_LIBRARY_PATH) via .ci/scripts/setup-webgpu-linux-deps.sh. For local runs:
1617
# source .ci/scripts/setup-webgpu-linux-deps.sh
1718
# bash backends/webgpu/scripts/test_webgpu_native_ci.sh
1819
#
1920
# Builds whatever native test targets are present in the landed tree (NOT a fixed
20-
# list). This stack lands: webgpu_native_test, webgpu_rms_norm_test (base) +
21-
# webgpu_dispatch_order_test, webgpu_scratch_buffer_test (D107576199) +
22-
# webgpu_update_cache_test (D107547307). SDPA executables join once they land.
21+
# list): webgpu_native_test (base) + webgpu_dispatch_order_test,
22+
# webgpu_scratch_buffer_test (D107576199) + webgpu_update_cache_test
23+
# (D107547307). SDPA executables join once they land.
2324

2425
set -e
2526

@@ -37,33 +38,19 @@ fi
3738
cd "${EXECUTORCH_ROOT}"
3839

3940
# ── Exports for the model-driven executables (best-effort) ───────────────────
40-
# native_test + rms_norm + dispatch_order read .pte/golden inputs via env/dir and
41-
# self-skip if absent; scratch is standalone (generates its own inputs).
42-
PTE_MODEL="/tmp/webgpu_add_test.pte"
43-
PTE_CHAINED_MODEL="/tmp/webgpu_chained_add_test.pte"
44-
RMS_NORM_DIR="/tmp/rmsn"
45-
RMS_NORM_OK=1
41+
# native_test (quantized_linear/SDPA/update_cache) + dispatch_order read .pte/
42+
# golden inputs via env/dir and self-skip if absent; scratch is standalone.
43+
# native_test itself is gated below on the executorch wheel being importable.
4644
DISPATCH_ORDER_DIR="/tmp/dispatch_order"
4745
DISPATCH_ORDER_OK=1
4846
UPDATE_CACHE_DIR="/tmp/update_cache"
4947
UPDATE_CACHE_OK=1
5048

51-
$PYTHON_EXECUTABLE -c "
52-
from executorch.backends.webgpu.test.ops.add.test_add import export_add_model, export_chained_add_model
53-
export_add_model('${PTE_MODEL}')
54-
export_chained_add_model('${PTE_CHAINED_MODEL}')
55-
" || echo "WARN: add export failed; webgpu_native_test self-skips models whose .pte is absent"
56-
5749
$PYTHON_EXECUTABLE -c "
5850
from executorch.backends.webgpu.test.ops.quantized_linear.test_quantized_linear import export_all_quantized_linear_models
5951
export_all_quantized_linear_models('/tmp')
6052
" || echo "WARN: q4gsw export failed; required configs will FAIL in webgpu_native_test"
6153

62-
$PYTHON_EXECUTABLE -c "
63-
from executorch.backends.webgpu.test.ops.rms_norm.test_rms_norm import export_rms_norm_cases
64-
export_rms_norm_cases('${RMS_NORM_DIR}')
65-
" || { echo "WARN: rms_norm export failed; skipping rms_norm native test"; RMS_NORM_OK=0; }
66-
6754
$PYTHON_EXECUTABLE -c "
6855
from executorch.backends.webgpu.test.ops.dispatch_order.test_dispatch_order import export_dispatch_order_cases
6956
export_dispatch_order_cases('${DISPATCH_ORDER_DIR}')
@@ -112,7 +99,7 @@ cmake \
11299
"${EXECUTORCH_ROOT}"
113100

114101
# ── Build + run every native test target that exists in this tree ────────────
115-
TARGETS=(webgpu_native_test webgpu_rms_norm_test webgpu_dispatch_order_test webgpu_scratch_buffer_test webgpu_update_cache_test)
102+
TARGETS=(webgpu_native_test webgpu_dispatch_order_test webgpu_scratch_buffer_test webgpu_update_cache_test)
116103
BIN_DIR="${BUILD_DIR}/backends/webgpu"
117104

118105
# Which targets are defined depends on which diffs are landed (native_test +
@@ -141,20 +128,17 @@ for t in "${TARGETS[@]}"; do
141128
done
142129

143130
echo "=== Run native tests on Dawn + SwiftShader ==="
144-
# native_test is model-driven; only run it if the export produced its .pte
145-
# (CI's setup-linux.sh provides the executorch wheel so exports succeed; a bare
146-
# local run without the wheel self-skips here rather than hard-failing on load).
147-
if [[ -x "${BIN_DIR}/webgpu_native_test" && -f "${PTE_MODEL}" ]]; then
148-
env WEBGPU_TEST_MODEL="${PTE_MODEL}" \
149-
WEBGPU_TEST_CHAINED_MODEL="${PTE_CHAINED_MODEL}" \
150-
WEBGPU_TEST_SDPA_DIR=/tmp/ \
131+
# webgpu_native_test hosts the quantized_linear / SDPA / update_cache / symint
132+
# sweeps. Gate on the executorch wheel being importable (the proxy for "the
133+
# exports above ran"): CI has the wheel so they ran; a bare local run without it
134+
# skips here rather than hard-failing the required-config guards.
135+
if [[ -x "${BIN_DIR}/webgpu_native_test" ]] &&
136+
"${PYTHON_EXECUTABLE}" -c "import executorch" 2>/dev/null; then
137+
env WEBGPU_TEST_SDPA_DIR=/tmp/ \
151138
WEBGPU_TEST_QUANTIZED_LINEAR_DIR=/tmp/ \
152139
"${BIN_DIR}/webgpu_native_test"
153140
else
154-
echo "(skipping webgpu_native_test: no exported .pte — needs the executorch python wheel)"
155-
fi
156-
if [[ "${RMS_NORM_OK}" == "1" && -x "${BIN_DIR}/webgpu_rms_norm_test" ]]; then
157-
"${BIN_DIR}/webgpu_rms_norm_test" "${RMS_NORM_DIR}"
141+
echo "(skipping webgpu_native_test: executorch wheel absent — exports did not run)"
158142
fi
159143
if [[ "${UPDATE_CACHE_OK}" == "1" && -x "${BIN_DIR}/webgpu_update_cache_test" ]]; then
160144
"${BIN_DIR}/webgpu_update_cache_test" "${UPDATE_CACHE_DIR}"

backends/webgpu/test/native/test_rms_norm.cpp

Lines changed: 0 additions & 173 deletions
This file was deleted.

backends/webgpu/test/test_build_webgpu.sh

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,18 @@ $PYTHON_EXECUTABLE -m pytest "${SCRIPT_DIR}/test_wgsl_codegen.py" -v
2626

2727
echo "=== Step 1: Run Python export tests ==="
2828
$PYTHON_EXECUTABLE -m pytest "${SCRIPT_DIR}/ops/add/test_add.py" -v
29-
# Non-fatal: a rms_norm pytest failure skips the rms_norm native test below
30-
# rather than aborting the whole run.
31-
RMS_NORM_PYTEST_OK=1
32-
$PYTHON_EXECUTABLE -m pytest "${SCRIPT_DIR}/ops/rms_norm/test_rms_norm.py" -v \
33-
|| RMS_NORM_PYTEST_OK=0
29+
$PYTHON_EXECUTABLE -m pytest "${SCRIPT_DIR}/ops/rms_norm/test_rms_norm.py" -v
3430

3531
# ── Step 2: Export .pte model ─────────────────────────────────────────────────
3632

3733
echo "=== Step 2: Export test models ==="
38-
PTE_MODEL="/tmp/webgpu_add_test.pte"
39-
PTE_CHAINED_MODEL="/tmp/webgpu_chained_add_test.pte"
40-
RMS_NORM_DIR="/tmp/rmsn"
4134
DISPATCH_ORDER_DIR="/tmp/dispatch_order"
4235
PTE_UPDATE_CACHE_MODEL="/tmp/webgpu_update_cache_test.pte"
4336
cd "${EXECUTORCH_ROOT}"
4437
$PYTHON_EXECUTABLE -c "
45-
from executorch.backends.webgpu.test.ops.add.test_add import export_add_model, export_chained_add_model
46-
export_add_model('${PTE_MODEL}')
47-
export_chained_add_model('${PTE_CHAINED_MODEL}')
48-
"
49-
$PYTHON_EXECUTABLE -c "
5038
from executorch.backends.webgpu.test.ops.dispatch_order.test_dispatch_order import export_dispatch_order_cases
5139
export_dispatch_order_cases('${DISPATCH_ORDER_DIR}')
5240
"
53-
if [[ "${RMS_NORM_PYTEST_OK}" == "1" ]]; then
54-
$PYTHON_EXECUTABLE -c "
55-
from executorch.backends.webgpu.test.ops.rms_norm.test_rms_norm import export_rms_norm_cases
56-
export_rms_norm_cases('${RMS_NORM_DIR}')
57-
" || { echo "WARN: rms_norm export failed; skipping rms_norm native test"; RMS_NORM_PYTEST_OK=0; }
58-
fi
5941

6042
echo "=== Export update_cache model ==="
6143
UPDATE_CACHE_OK=1
@@ -113,7 +95,6 @@ cmake \
11395
"${EXECUTORCH_ROOT}"
11496

11597
cmake --build "${NATIVE_BUILD_DIR}" --target webgpu_native_test -j${NPROC}
116-
cmake --build "${NATIVE_BUILD_DIR}" --target webgpu_rms_norm_test -j${NPROC}
11798
cmake --build "${NATIVE_BUILD_DIR}" --target webgpu_dispatch_order_test -j${NPROC}
11899
cmake --build "${NATIVE_BUILD_DIR}" --target webgpu_scratch_buffer_test -j${NPROC}
119100

@@ -125,18 +106,10 @@ else
125106
echo "(skipping update_cache native test: export did not complete)"
126107
fi
127108
env \
128-
WEBGPU_TEST_MODEL="${PTE_MODEL}" \
129-
WEBGPU_TEST_CHAINED_MODEL="${PTE_CHAINED_MODEL}" \
130109
${UPDATE_CACHE_ENV_VAR} \
131110
WEBGPU_TEST_SDPA_DIR=/tmp/ \
132111
"${NATIVE_BUILD_DIR}/backends/webgpu/webgpu_native_test"
133112

134-
if [[ "${RMS_NORM_PYTEST_OK}" == "1" ]]; then
135-
"${NATIVE_BUILD_DIR}/backends/webgpu/webgpu_rms_norm_test" "${RMS_NORM_DIR}"
136-
else
137-
echo "(skipping rms_norm native test: pytest or export did not complete)"
138-
fi
139-
140113
"${NATIVE_BUILD_DIR}/backends/webgpu/webgpu_dispatch_order_test" "${DISPATCH_ORDER_DIR}"
141114
"${NATIVE_BUILD_DIR}/backends/webgpu/webgpu_scratch_buffer_test"
142115

0 commit comments

Comments
 (0)