Commit 6ebaa05
[ET-VK] Fix missing memory barrier for first-use writes on aliased tensors
Pull Request resolved: #17309
Tensors sharing physical memory via SharedObject each track their own
`last_access_` independently. When a tensor's first access is a write,
`prev_stage` is `NO_STAGE`, causing `transition()` to use
`TOP_OF_PIPE_BIT` as `srcStageMask` with no `srcAccessMask` — effectively
a no-op barrier. If the same physical memory was previously written
through a different aliased tensor handle, this creates a WAW hazard
where the new write may execute before or concurrently with the prior
write, producing non-deterministic results.
This was observed as non-deterministic q8ta_conv2d output in ResNet50:
running the model twice with the same input produced slightly different
quantized int8 values. Adding a debug print shader after each conv2d
dispatch masked the issue because the print node's read-after-write
barrier serialized GPU work.
The fix: when `prev_stage` is `NO_STAGE` and the current access is a
write, use `COMPUTE_SHADER_BIT` with `SHADER_WRITE_BIT` instead of
`TOP_OF_PIPE_BIT` with no access flags. This ensures all prior compute
shader work completes and its writes are made visible before the new
write begins.
Authored with Claude.
ghstack-source-id: 339884030
@exported-using-ghexport
Differential Revision: [D92715369](https://our.internmc.facebook.com/intern/diff/D92715369/)1 parent 90e6e4c commit 6ebaa05
1 file changed
Lines changed: 18 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
775 | 775 | | |
776 | 776 | | |
777 | 777 | | |
| 778 | + | |
| 779 | + | |
778 | 780 | | |
779 | | - | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
780 | 792 | | |
| 793 | + | |
781 | 794 | | |
782 | 795 | | |
783 | 796 | | |
| |||
786 | 799 | | |
787 | 800 | | |
788 | 801 | | |
| 802 | + | |
| 803 | + | |
789 | 804 | | |
790 | 805 | | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
| 806 | + | |
796 | 807 | | |
797 | 808 | | |
798 | 809 | | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
| 810 | + | |
803 | 811 | | |
804 | 812 | | |
805 | 813 | | |
| |||
0 commit comments