Repository navigation
fix(pt2e): insert activation input observers before consumer node - #5041
Open
devtyagi3909 wants to merge 1 commit into
Open
devtyagi3909 wants to merge 1 commit into
devtyagi3909 wants to merge 1 commit into
Conversation
Fixes pytorch#5040 When inserting input observers in prepare_pt2e, intermediate activation tensors were previously observed immediately after their producing node via insert_obs_or_fq (inserting_after(arg)). If the activation undergoes in-place mutations or writes through views prior to being consumed (e.g. new_zeros followed by select().copy_()), the observer was placed before the mutation, capturing uninitialized/zero data and causing the quantized consumer to ignore inputs. Update _maybe_insert_input_observer_for_arg_or_kwarg to insert activation input observers immediately before the consumer node using inserting_before(node), while preserving insertion after get_attr nodes for static parameters/weights. Signed-off-by: DEV TYAGI <[email protected]>
devtyagi3909
requested review from
andrewor14,
jerryzh168 and
vkuzo
as code owners
October 30, 2026 17:59
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/5041
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This branch has not been 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.
fixes #5040
what changed
activation input observers were previously placed right after the producer node with
insert_obs_or_fq(graph.inserting_after(arg)). when an intermediate buffer is mutated in-place or written through views prior to consumption (likebuf = x.new_zeros(...); buf.select(0, 0).copy_(x); conv(buf)), the observer was inserted before the write completed, observing zeros and causing the consumer to ignore the input.updated
_maybe_insert_input_observer_for_arg_or_kwargto insert activation input observers before the consumer node (with graph.inserting_before(node):).get_attrnodes (weights/params) continue inserting afterargto preserve parameter quantization node order.test plan
added
test_inplace_view_write_activation_input_observedintest/quantization/pt2e/test_quantize_pt2e.pyverifying that in-place view writes propagate through quantization. all 75 pt2e unit tests pass.