Skip to content

[ET-VK][fix] Widen WAR barrier to a full memory dependency for reused tensors#20915

Merged
meta-codesync[bot] merged 1 commit into
gh/SS-JIA/572/basefrom
gh/SS-JIA/572/head
Jul 15, 2026
Merged

[ET-VK][fix] Widen WAR barrier to a full memory dependency for reused tensors#20915
meta-codesync[bot] merged 1 commit into
gh/SS-JIA/572/basefrom
gh/SS-JIA/572/head

Conversation

@SS-JIA

@SS-JIA SS-JIA commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

vTensorStorage::transition() emitted the write-after-read (WAR) barrier with a read-only source access mask, which Vulkan treats as an execution-only dependency (no memory dependency). Some Adreno drivers drop this narrow COMPUTE -> COMPUTE dependency, letting the current write race the previous read. This surfaced as deterministic output corruption at the tile seams of the tiled im2col+GEMM conv2d path (the reused im2col scratch TmpTensor): the next tile's im2col overwrote the trailing rows of the scratch while the current tile's GEMM was still reading them. The Vulkan op impl was unchanged and passed previously only because other leased CI devices happened to serialize the tiles; a device/driver whose scheduling did not exposed the latent hazard. When the previous access was a genuine read-only (prev_read && !prev_written && cur_written), widen the barrier to a full ALL_COMMANDS execution + memory dependency so the driver reliably honors it. Scoped to the rare WAR transition, so the common first-write and RAW/WAW paths are untouched; widening a barrier is always correctness-safe. Fixes WAR hazards generically for all storage types, not just this conv.

Differential Revision: D111994459

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 Cancelled Job

As of commit 5bc882f with merge base ceecc9e (image):

CANCELLED JOB - The following job was cancelled. Please retry:

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 Jul 14, 2026
@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.

@meta-codesync meta-codesync Bot merged commit 80da17b into gh/SS-JIA/572/base Jul 15, 2026
206 of 209 checks passed
@meta-codesync meta-codesync Bot deleted the gh/SS-JIA/572/head branch July 15, 2026 00:32
@meta-codesync meta-codesync Bot temporarily deployed to cherry-pick-bot July 15, 2026 00:32 Inactive
SS-JIA added a commit that referenced this pull request Jul 15, 2026
… tensors

`vTensorStorage::transition()` emitted the write-after-read (WAR) barrier with a read-only source access mask, which Vulkan treats as an execution-only dependency (no memory dependency). Some Adreno drivers drop this narrow `COMPUTE -> COMPUTE` dependency, letting the current write race the previous read. This surfaced as deterministic output corruption at the tile seams of the tiled im2col+GEMM conv2d path (the reused im2col scratch `TmpTensor`): the next tile's im2col overwrote the trailing rows of the scratch while the current tile's GEMM was still reading them. The Vulkan op impl was unchanged and passed previously only because other leased CI devices happened to serialize the tiles; a device/driver whose scheduling did not exposed the latent hazard. When the previous access was a genuine read-only (`prev_read && !prev_written && cur_written`), widen the barrier to a full `ALL_COMMANDS` execution + memory dependency so the driver reliably honors it. Scoped to the rare WAR transition, so the common first-write and RAW/WAW paths are untouched; widening a barrier is always correctness-safe. Fixes WAR hazards generically for all storage types, not just this conv.

Differential Revision: [D111994459](https://our.internmc.facebook.com/intern/diff/D111994459/)


ghstack-source-id: 402958244
Pull-Request: #20915
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.

2 participants