Repository navigation
[ET-VK][q8ta] Support input broadcasting in q8ta_add - #23573
Open
pytorchbot wants to merge 1 commit into
Open
pytorchbot wants to merge 1 commit into
pytorchbot wants to merge 1 commit into
Conversation
## Ulterior Motive Correct results for int8 models on the ET-VK backend. A common pattern adds a per-sample context row to every row of a sequence, e.g. a `[1, 1, 512]` tensor added to a `[1, 60, 512]` tensor. In int8 models on ET-VK, this add was wrong for every row after the first. ## Rationale **What**: `q8ta_add` now broadcasts its inputs against the output. **Why**: The quantized binary pattern fuses any `dequantize -> add -> quantize` into `q8ta_add`, including adds whose inputs broadcast. The shader read both inputs at the output's tensor index, so broadcast adds silently produced wrong results on every GPU. ## Details - Broadcast add, e.g. `[1, 60, 512] + [1, 1, 512]` - **Before**: Input B is read at the output index. Only index 0 of a broadcast dim holds data; other indices read block padding or past the end of B's buffer. Rows 1-59 are off by up to 0.27 on Adreno and Mali; row 0 is exact. - **After**: Matches the reference on every row. - Implementation in `q8ta_binary.glsl`, applied to both inputs: - Each input's tensor index is clamped to `size - 1` per dim, so size 1 dims read index 0. - If a block dim is broadcast, the loaded block is replicated: block outer dim copies row 0 to all 4 rows; block inner (packed) dim copies byte 0 to all 4 bytes of each int32. - Broadcast dims are detected from the metadata UBOs at runtime, so it holds after dynamic resize. - `test_q8ta_binary`: optional input B shape, broadcasting reference, and 8 broadcast shapes (including broadcast input A and lower-rank B) across all 5 int8 layouts, with runtime-quantized and constant B. Authored with Claude Code. Differential Revision: [D123950526](https://our.internmc.facebook.com/intern/diff/D123950526/) ghstack-source-id: 443893319 Pull-Request: #23554
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23573
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit b0b4aa3 with merge base 4ca434e ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #23554 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/665/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/665/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/665/orig
Differential Revision: D123950526
@diff-train-skip-merge