Skip to content

Comments

[ET-VK][qconv] Pad weight_sums buffer to multiple-of-4 alignment#17505

Merged
meta-codesync[bot] merged 3 commits intogh/SS-JIA/433/basefrom
gh/SS-JIA/433/head
Feb 20, 2026
Merged

[ET-VK][qconv] Pad weight_sums buffer to multiple-of-4 alignment#17505
meta-codesync[bot] merged 3 commits intogh/SS-JIA/433/basefrom
gh/SS-JIA/433/head

Conversation

@SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Feb 17, 2026

Stack from ghstack (oldest at bottom):

The q8ta convolution shaders read weight_sums via ivec4 loads (4 int32 values at once), requiring the buffer to have at least align_up_4(OC) elements. The weight tensor, weight_scales, and bias are all padded via align_width_and_update_state_dict, but weight_sums was created as a 1D tensor of shape (OC,) without any padding.

For OC values that are not a multiple of 4 (e.g. OC=1 in the final pointwise conv of MetaNet GreenScreen), this results in out-of-bounds GPU buffer reads. On host testing with ASAN, this manifests as a heap-buffer-overflow.

Fix by padding sum_per_output_channel to align_up_4(OC) before creating the constant placeholder. Also fix the C++ test utility compute_weight_sums() which was incorrectly shrinking a pre-allocated aligned buffer.

Differential Revision: D93511633

The q8ta convolution shaders read weight_sums via ivec4 loads (4 int32 values at once), requiring the buffer to have at least align_up_4(OC) elements. The weight tensor, weight_scales, and bias are all padded via align_width_and_update_state_dict, but weight_sums was created as a 1D tensor of shape (OC,) without any padding.

For OC values that are not a multiple of 4 (e.g. OC=1 in the final pointwise conv of MetaNet GreenScreen), this results in out-of-bounds GPU buffer reads. On host testing with ASAN, this manifests as a heap-buffer-overflow.

Fix by padding sum_per_output_channel to align_up_4(OC) before creating the constant placeholder. Also fix the C++ test utility compute_weight_sums() which was incorrectly shrinking a pre-allocated aligned buffer.

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

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 17, 2026

🔗 Helpful Links

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

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

❌ 6 New Failures

As of commit e7f6b78 with merge base 7b843e4 (image):

NEW FAILURES - The following jobs have failed:

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

@github-actions
Copy link

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.

ssjia and others added 2 commits February 18, 2026 13:02
…gnment"

The q8ta convolution shaders read weight_sums via ivec4 loads (4 int32 values at once), requiring the buffer to have at least align_up_4(OC) elements. The weight tensor, weight_scales, and bias are all padded via align_width_and_update_state_dict, but weight_sums was created as a 1D tensor of shape (OC,) without any padding.

For OC values that are not a multiple of 4 (e.g. OC=1 in the final pointwise conv of MetaNet GreenScreen), this results in out-of-bounds GPU buffer reads. On host testing with ASAN, this manifests as a heap-buffer-overflow.

Fix by padding sum_per_output_channel to align_up_4(OC) before creating the constant placeholder. Also fix the C++ test utility compute_weight_sums() which was incorrectly shrinking a pre-allocated aligned buffer.

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

[ghstack-poisoned]
…gnment"

The q8ta convolution shaders read weight_sums via ivec4 loads (4 int32 values at once), requiring the buffer to have at least align_up_4(OC) elements. The weight tensor, weight_scales, and bias are all padded via align_width_and_update_state_dict, but weight_sums was created as a 1D tensor of shape (OC,) without any padding.

For OC values that are not a multiple of 4 (e.g. OC=1 in the final pointwise conv of MetaNet GreenScreen), this results in out-of-bounds GPU buffer reads. On host testing with ASAN, this manifests as a heap-buffer-overflow.

Fix by padding sum_per_output_channel to align_up_4(OC) before creating the constant placeholder. Also fix the C++ test utility compute_weight_sums() which was incorrectly shrinking a pre-allocated aligned buffer.

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

[ghstack-poisoned]
@meta-codesync meta-codesync bot merged commit 8643b19 into gh/SS-JIA/433/base Feb 20, 2026
184 of 192 checks passed
@meta-codesync meta-codesync bot deleted the gh/SS-JIA/433/head branch February 20, 2026 01:13
SS-JIA pushed a commit that referenced this pull request Feb 20, 2026
Pull Request resolved: #17505

The q8ta convolution shaders read weight_sums via ivec4 loads (4 int32 values at once), requiring the buffer to have at least align_up_4(OC) elements. The weight tensor, weight_scales, and bias are all padded via align_width_and_update_state_dict, but weight_sums was created as a 1D tensor of shape (OC,) without any padding.

For OC values that are not a multiple of 4 (e.g. OC=1 in the final pointwise conv of MetaNet GreenScreen), this results in out-of-bounds GPU buffer reads. On host testing with ASAN, this manifests as a heap-buffer-overflow.

Fix by padding sum_per_output_channel to align_up_4(OC) before creating the constant placeholder. Also fix the C++ test utility compute_weight_sums() which was incorrectly shrinking a pre-allocated aligned buffer.
ghstack-source-id: 342806075
@exported-using-ghexport

Differential Revision: [D93511633](https://our.internmc.facebook.com/intern/diff/D93511633/)
SS-JIA pushed a commit that referenced this pull request Feb 20, 2026
Pull Request resolved: #17505

The q8ta convolution shaders read weight_sums via ivec4 loads (4 int32 values at once), requiring the buffer to have at least align_up_4(OC) elements. The weight tensor, weight_scales, and bias are all padded via align_width_and_update_state_dict, but weight_sums was created as a 1D tensor of shape (OC,) without any padding.

For OC values that are not a multiple of 4 (e.g. OC=1 in the final pointwise conv of MetaNet GreenScreen), this results in out-of-bounds GPU buffer reads. On host testing with ASAN, this manifests as a heap-buffer-overflow.

Fix by padding sum_per_output_channel to align_up_4(OC) before creating the constant placeholder. Also fix the C++ test utility compute_weight_sums() which was incorrectly shrinking a pre-allocated aligned buffer.
ghstack-source-id: 342806075
@exported-using-ghexport

Differential Revision: [D93511633](https://our.internmc.facebook.com/intern/diff/D93511633/)
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants