Skip to content

[ExecuTorch][WebGPU] Test coverage for the f16 KV cache#20773

Open
JCNTH wants to merge 2 commits into
gh/JCNTH/11/basefrom
gh/JCNTH/11/head
Open

[ExecuTorch][WebGPU] Test coverage for the f16 KV cache#20773
JCNTH wants to merge 2 commits into
gh/JCNTH/11/basefrom
gh/JCNTH/11/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 7, 2026

Copy link
Copy Markdown

Stack from ghstack (oldest at bottom):

Tests for the opt-in f16 KV cache (stacked op diff). When built with EXECUTORCH_WEBGPU_KV_F16 and run on a shader-f16 device, the SDPA op stores the K/V cache as f16, so the entire existing sdpa_with_kv_cache golden suite (config sweep + replay + dynamic decode) exercises the f16-KV path with no new goldens needed; this diff loosens the SDPA numeric tolerance to the f16 read-precision floor when — and only when — that path is active.

Key changes:

  • test_webgpu_native.cpp sdpa_within_tol — under #ifdef WGPU_BACKEND_KV_F16, compare at abs 2e-3 / rel 1e-2 when the device negotiated shader-f16, else keep the strict f32 abs 1e-4 / rel 1e-3. Every SDPA config/replay/decode golden then validates the f16-KV output through the existing exemplars.

Constraints: the default (flag-OFF) test build is unchanged; on a non-shader-f16 device (including the CI software adapter) the f16 KV path stays inactive and the strict f32 tolerance applies, so there is no CI behavior change. The f16-KV numeric validation is therefore shader-f16-device-only (Canary/Metal), matching the op's opt-in gating; no CI script change (mirrors the steel-f16 tests).

Co-authored-with: Claude Code.
@exported-using-ghexport

Differential Revision: D110919973

Differential Revision: D110919973

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20773

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 1 Pending, 1 Unrelated Failure

As of commit 1479030 with merge base f8c8334 (image):

NEW FAILURE - The following job has failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

[ghstack-poisoned]
JCNTH added a commit that referenced this pull request Jul 7, 2026
Pull Request resolved: #20773

Tests for the opt-in f16 KV cache (stacked op diff). When built with `EXECUTORCH_WEBGPU_KV_F16` and run on a shader-f16 device, the SDPA op stores the K/V cache as f16, so the entire existing `sdpa_with_kv_cache` golden suite (config sweep + replay + dynamic decode) exercises the f16-KV path with no new goldens needed; this diff loosens the SDPA numeric tolerance to the f16 read-precision floor when — and only when — that path is active.

Key changes:

- `test_webgpu_native.cpp` `sdpa_within_tol` — under `#ifdef WGPU_BACKEND_KV_F16`, compare at abs `2e-3` / rel `1e-2` when the device negotiated shader-f16, else keep the strict f32 abs `1e-4` / rel `1e-3`. Every SDPA config/replay/decode golden then validates the f16-KV output through the existing exemplars.

Constraints: the default (flag-OFF) test build is unchanged; on a non-shader-f16 device (including the CI software adapter) the f16 KV path stays inactive and the strict f32 tolerance applies, so there is no CI behavior change. The f16-KV numeric validation is therefore shader-f16-device-only (Canary/Metal), matching the op's opt-in gating; no CI script change (mirrors the steel-f16 tests).

Co-authored-with: Claude Code.
ghstack-source-id: 400708673
@exported-using-ghexport

Differential Revision: [D110919973](https://our.internmc.facebook.com/intern/diff/D110919973/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant