Skip to content

SDPA tests: select attn output by shape#20285

Open
JulianCloudNTH wants to merge 1 commit into
pytorch:mainfrom
JulianCloudNTH:export-D108650388
Open

SDPA tests: select attn output by shape#20285
JulianCloudNTH wants to merge 1 commit into
pytorch:mainfrom
JulianCloudNTH:export-D108650388

Conversation

@JulianCloudNTH

Copy link
Copy Markdown
Contributor

Summary:
Follow-up to D108625761 (#20283), which fixed test_sdpa_config's ambiguous attention-output selection; this handles the remaining edge cases in the sibling SDPA test functions.

sdpa_with_kv_cache returns [k_cache, v_cache, attn_output], where the attention output is [1, S, Hq, D] and each KV cache is [1, Cmax, Hkv, D]. Selecting the attention output by flat element count is ambiguous whenever S*Hq == Cmax*Hkv (all three tensors then share a numel) — the deterministic llama1b_prefill failure D108625761 fixed in test_sdpa_config. The three other SDPA test functions — test_sdpa_replay, test_sdpa_dynamic_decode, and test_sdpa_incache_decode — still matched by numel; no currently-configured sequence triggers the collision, but they carry the same latent ambiguity. This applies the same shape-based selection: match the attention output as the 4-D tensor [1, S, Hq, D] and (for replay and dynamic decode) classify the two caches as [1, Cmax, Hkv, D], keeping the per-step k-vs-v identification by content unchanged. Test-only; no kernel, runtime, or export change.

Authored with Claude Code.

Differential Revision: D108650388

Summary:
Follow-up to D108625761 (pytorch#20283), which fixed `test_sdpa_config`'s ambiguous attention-output selection; this handles the remaining edge cases in the sibling SDPA test functions.

`sdpa_with_kv_cache` returns `[k_cache, v_cache, attn_output]`, where the attention output is `[1, S, Hq, D]` and each KV cache is `[1, Cmax, Hkv, D]`. Selecting the attention output by flat element count is ambiguous whenever `S*Hq == Cmax*Hkv` (all three tensors then share a `numel`) — the deterministic `llama1b_prefill` failure D108625761 fixed in `test_sdpa_config`. The three other SDPA test functions — `test_sdpa_replay`, `test_sdpa_dynamic_decode`, and `test_sdpa_incache_decode` — still matched by `numel`; no currently-configured sequence triggers the collision, but they carry the same latent ambiguity. This applies the same shape-based selection: match the attention output as the 4-D tensor `[1, S, Hq, D]` and (for replay and dynamic decode) classify the two caches as `[1, Cmax, Hkv, D]`, keeping the per-step k-vs-v identification by content unchanged. Test-only; no kernel, runtime, or export change.

Authored with Claude Code.

Differential Revision: D108650388
@pytorch-bot

pytorch-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures, 4 Pending

As of commit 2762587 with merge base 99ca02f (image):

NEW FAILURES - The following jobs have failed:

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 15, 2026
@meta-codesync

meta-codesync Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@JulianCloudNTH has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108650388.

@github-actions

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.

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