Treat aten.slice.Tensor as a shared-observer op in XNNPACKQuantizer - #21568
Open
Hyungkeun-Park-Nota wants to merge 1 commit into
Open
Treat aten.slice.Tensor as a shared-observer op in XNNPACKQuantizer#21568Hyungkeun-Park-Nota wants to merge 1 commit into
Hyungkeun-Park-Nota wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21568
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 9 Pending, 1 Unclassified FailureAs of commit 208a8e2 with merge base 4b4df96 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
`_is_share_obs_or_fq_op` only listed `aten.slice_copy.Tensor`, but the quantizer
runs before `to_edge()`, so the op it sees is `aten.slice.Tensor` and the slice
never gets its producer's SharedQuantizationSpec. The neighbouring ops are all
registered under both names (permute, squeeze, view); slice only had the `_copy`
one.
Input and output then end up with different quant params, which XNNPACK's
static_slice rejects, so the model lowers fine and fails at runtime init with
xnn_status_invalid_parameter. Hit this on a Gemma-family embedding model where
the RoPE rotate_half slices were all left unquantized.
`_test_qs8_slice_copy` was disabled for this ("T156004676 - slice isn't
propagated") and is re-enabled here. Its check_node_count keys had to move to
op overloads, and the expected quantize_per_tensor count is 5 rather than 3 now
that the slices are quantized too.
Hyungkeun-Park-Nota
force-pushed
the
xnnpack-quantizer-slice-shared-obs
branch
from
August 4, 2026 05:21
f76d609 to
208a8e2
Compare
Contributor
Author
|
@pytorchbot label "release notes: xnnpack" "module: xnnpack" |
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.
Summary
_is_share_obs_or_fq_oplistsaten.slice_copy.Tensorbut notaten.slice.Tensor.The quantizer runs before
to_edge(), so the op it actually sees isaten.slice.Tensor, the_copyentry never matches, andpropagate_annotationdoes not give the slice its producer's
SharedQuantizationSpec.The other data-movement ops in that list are registered under both names
(
permute.default/permute_copy.default,squeeze.dim/squeeze_copy.dim,view.default/view_copy.default); slice only had the_copyone.slicehasno
.defaultoverload, which is why the pre-functionalization name isslice.Tensorand notslice_copy.default.Without the shared spec, the slice input and output end up with different quant
params. XNNPACK's
static_slicerequires them to be equal, so the modelpartitions and lowers fine and then fails at runtime init:
I hit this quantizing a Gemma-family embedding model with
XNNPACKQuantizer(per-channel W8A8 static), where all 96 slices from the RoPE
rotate_halfpattern were left without quant params.
_test_qs8_slice_copywas already disabled for this ("T156004676 - slice isn'tpropagated"), and its comment names the same cause, so I re-enabled it here.
Test plan
The test runs end to end now: quantize, lower, serialize, run and compare
outputs. Reverting the one-line change makes it fail with 2
quantize_per_tensornodes instead of 5.Two assertions in it needed updating first.
check_node_counttakes opoverloads rather than the
"aten::slice.Tensor"strings the test was writtenwith, so it reported
Expected 3 aten::slice.Tensor nodes but found 0on agraph that did contain them. And the expected
quantize_per_tensorcount is 5,not 3, since the three slices are now quantized along with the input and the add
output.
lintrunner -m upstream/mainis clean.cc @GregoryComer @digantdesai @cbilgin @JakeStevens