Skip to content

Tighten generalized scatter graph target - #184075

Closed
jansel wants to merge 5 commits into
gh/jansel/733/basefrom
gh/jansel/733/head
Closed

jansel wants to merge 5 commits into
gh/jansel/733/basefrom
gh/jansel/733/head

Conversation

@jansel

@jansel jansel commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Represent Inductor's temporary generalized scatter form with private OpOverload targets so intermediate reinplace graphs do not contain plain Python function call_function targets. Add regression coverage for the post-canonicalization graph invariant.

Fixes #156818

Generated by my agent

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented May 17, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (2 Unrelated Failures)

As of commit 85781a1 with merge base cc4faaa (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

@jansel

jansel commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@claude review these changes

@claude

claude Bot commented May 17, 2026 •

Copy link
Copy Markdown

Claude finished @jansel's task in 2m 18s —— View job


Code Review: Tighten generalized scatter graph target

  • Read PR diff and understand the changes
  • Review torch/_inductor/fx_passes/reinplace.py changes
  • Review test/inductor/test_inplacing_pass.py changes
  • Post review feedback

Summary: This PR converts _generalized_scatter and _inplace_generalized_scatter from plain Python functions to proper OpOverload targets (registered under torch.ops._inductor_reinplace), ensuring the post-canonicalization graph invariant that all call_function nodes have OpOverload targets. The ViewOp dataclass is encoded into serializable tuples so it can be passed through the operator schema system.

Verdict: This looks good. The approach is clean and the encoding/decoding is well-structured. A few observations below:


Design

The encoding scheme (EncodedViewOp = tuple[int, tuple[Any, ...], tuple[tuple[str, Any], ...]]) is a reasonable way to represent ViewOp in a form compatible with operator schemas. Using integer codes for targets via _VIEW_OP_TO_CODE keeps the tuples compact.

Registering with "FRAGMENT" library and "CompositeExplicitAutograd" dispatch key is appropriate here since these ops exist only during graph transformation and get decomposed before lowering.

Minor observations

  1. Dead code path in impl (reinplace.py:123-126): The pytree.tree_map looking for torch.fx.Node instances inside _inplace_generalized_scatter_impl is effectively a no-op when called through the operator dispatch (since graph_call_function already maps nodes to fake values). This is pre-existing and harmless, but worth noting that this impl is only exercised during fake-mode execution for metadata inference, never at runtime.

  2. _VIEW_OPS ordering (reinplace.py:89): The integer encoding depends on tuple(_VIEW_OP_TO_SCATTER) iteration order, which is deterministic (dict insertion order in Python 3.7+) and stable since _SCATTER_OP_TO_VIEW is a literal. Fine as-is, but if someone reorders _SCATTER_OP_TO_VIEW in the future, it would silently change the encoding. Since these encoded tuples never persist across processes (only live within a single compilation), this isn't a correctness concern.

  3. Schema type (reinplace.py:154): The Any type for view_ops in the op schema is the right pragmatic choice since the torch schema language can't express nested tuple structures with mixed types.

Test

The new test_generalized_scatter_target_is_operator is a well-designed regression test. It verifies both the positive invariant (all targets are OpOverload or operator.getitem) and the decomposition completeness. Good coverage for the fix to #156818.


LGTM overall. No blocking issues found.

@jansel jansel added the topic: not user facing topic category label May 17, 2026
[ghstack-poisoned]
jansel added a commit that referenced this pull request May 17, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets and dispatcher-friendly encoded view args so intermediate reinplace graphs do not contain plain Python call_function targets. Add regression coverage for symbolic view args, unrelated view ops, and the post-canonicalization graph invariant.

Fixes #156818

Generated by my agent

ghstack-source-id: 165372b

Pull-Request: #184075
@jansel

jansel commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@claude review these changes

@claude

claude Bot commented May 17, 2026 •

Copy link
Copy Markdown

Claude finished @jansel's task in 1m 31s —— View job


Code Review: Tighten generalized scatter graph target

  • Read PR diff and understand the changes
  • Review torch/_inductor/fx_passes/reinplace.py changes
  • Review test/inductor/test_inplacing_pass.py changes
  • Post review feedback

Summary: This PR converts _generalized_scatter and _inplace_generalized_scatter from plain Python functions to proper OpOverload targets registered under torch.ops._inductor_reinplace, ensuring the post-canonicalization graph invariant that all call_function nodes have OpOverload targets. The ViewOp dataclass is encoded into flat, serializable tuples (view_codes, view_args, view_arg_counts, view_arg_none) compatible with the torch operator schema system.

Verdict: LGTM. The approach is clean and well-structured. Observations below:


Design

The encoding scheme is a sound approach to flatten arbitrary ViewOp sequences into schema-compatible arguments. The key design choices are good:

  • SymInt[] for view_args: Correctly allows fx.Node objects representing symbolic shapes to flow through the operator, preserving graph dependencies.
  • FRAGMENT library + CompositeExplicitAutograd: Appropriate since these ops live only during graph transformation.
  • Separate Meta impls: Clean — _generalized_scatter_meta returns a fresh tensor with matching metadata, _inplace_generalized_scatter_meta returns inp directly.

Observations

  1. _normalize_view_op handles fx.Node args correctly (reinplace.py:117-145): Since the normalization just shuffles positional/keyword args into a canonical positional form (filling defaults), fx.Node values pass through unchanged. They end up in the view_args tuple as SymInt references, which is exactly right.

  2. as_strided length-prefixed encoding (reinplace.py:148-151): The length-prefix approach for variable-length size/stride tuples is a clean solution for flat encoding. The _unflatten_view_op_args correctly mirrors this.

  3. None sentinel in view_arg_none (reinplace.py:165-167): Encoding None as (0, is_none=True) avoids type issues in SymInt[] while maintaining a 1:1 correspondence between view_args and view_arg_none. Efficient.

  4. Dead pytree.tree_map for fx.Node (reinplace.py:237-242): The tree_map checking for fx.Node instances in _inplace_generalized_scatter_impl is effectively a no-op when called through op dispatch (since graph_call_function already resolves nodes to fake values). However, this is defensive and harmless — it would catch bugs if the impl were ever called with raw nodes.

  5. can_fuse() comparison uses unnormalized scatter_view_op (reinplace.py:535-538): The scatter_view_op compared against node_to_view_op[inp] entries is the raw (unnormalized) ViewOp with fx.Node args from handle_views. Both sides store raw node references, so identity-based comparison of args is consistent. The normalized form (encoded_scatter_view_op) is only used for the actual encoding. This is correct.

  6. _slice.Tensor defaults include None (reinplace.py:129): The defaults (0, None, None, 1) for slice.Tensor's (dim, start, end, step) match the ATen schema where start and end are optional. After normalization, these Nones flow into encoding correctly via the view_arg_none mechanism.

Tests

The three new tests provide good coverage:

  • test_generalized_scatter_target_is_operator: Verifies the core invariant (all targets are OpOverload or operator.getitem) and decomposition completeness.
  • test_generalized_scatter_symbolic_view_args: Exercises the symbolic shape path — important for verifying SymInt[] schema compatibility.
  • test_generalized_scatter_ignores_unrelated_view_ops: Regression test ensuring unrelated views (like t()) don't interfere with scatter canonicalization.

No blocking issues found.


[ghstack-poisoned]
jansel added a commit that referenced this pull request May 18, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets and dispatcher-friendly encoded view args so intermediate reinplace graphs do not contain plain Python call_function targets. Add regression coverage for symbolic view args, unrelated view ops, and the post-canonicalization graph invariant.

Fixes #156818

Generated by my agent

ghstack-source-id: 5d76c8b

Pull-Request: #184075
@jansel

jansel commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

@claude review these changes

@claude

claude Bot commented May 18, 2026 •

Copy link
Copy Markdown

Claude finished @jansel's task in 2m 16s —— View job


Code Review: Tighten generalized scatter graph target

  • Read PR diff and understand the changes
  • Review torch/_inductor/fx_passes/reinplace.py changes
  • Review test/inductor/test_inplacing_pass.py changes
  • Post review feedback

Summary: This PR converts _generalized_scatter and _inplace_generalized_scatter from plain Python functions to proper OpOverload targets registered under torch.ops._inductor_reinplace. The ViewOp dataclass is encoded into flat, schema-compatible form (view_codes, view_args, view_arg_counts, view_arg_none) and a proper Meta implementation computes output shapes symbolically without materializing views.

Verdict: LGTM — the implementation is clean and thorough. Notes below.


Design strengths

  1. Flat encoding (reinplace.py:148-174): The _encode_view_ops / _decode_view_ops pair cleanly round-trips ViewOp sequences through schema-compatible flat tuples. The length-prefix approach for as_strided's variable-length size/stride is a good solution.

  2. Symbolic Meta impl (reinplace.py:300-341): _view_ops_shape computes view-chain shapes purely symbolically via _slice_view_length, _diagonal_view_length, etc. This avoids needing to call into the dispatcher during fake propagation and correctly handles SymInt arithmetic. The use of torch.sym_min/torch.sym_max/torch.sym_ite ensures guards aren't introduced.

  3. Normalize-before-encode (reinplace.py:641-645): Normalizing kwargs to positional form before encoding ensures a canonical representation regardless of how the original scatter op was called (positional vs keyword args, with or without defaults). The unnormalized scatter_view_op is correctly kept separate for the can_fuse() identity comparison (line 659).

Observations

  1. can_fuse() comparison consistency (reinplace.py:647-659): The comparison uses raw scatter_view_op (with fx.Node args) against node_to_view_op entries that also store raw fx.Node references. This is correct — both sides use node identity. The normalized form is only used for encoding. Worth noting: ViewOp is a @dataclass (not frozen=True), so equality is structural — the args tuples compare element-by-element, which works because fx.Node falls back to identity comparison.

  2. _apply_view_ops defensive fx.Node check (reinplace.py:236-239): The tree_map looking for fx.Node instances is effectively a no-op in practice — when called through the CompositeExplicitAutograd dispatch path with real tensors, there are no fx.Node objects; when called in fake mode for metadata inference, graph_call_function already resolves nodes to meta["val"]. This is harmless defensive code.

  3. wrap_negative_bound in _slice_view_length (reinplace.py:269-274): The SymInt path uses torch.sym_ite while the int path uses a plain conditional. The fallthrough case (line 274 return val) would apply to other numeric types or None — though None is already handled on lines 276-277 before wrap_negative_bound is called. This structure is fine.

  4. _validate_scatter_src_shape error path (reinplace.py:344-353): Uses torch.broadcast_shapes which works with both concrete and symbolic shapes. The broadcast_shape != dst_shape check may introduce a guard in symbolic mode if shapes are purely symbolic — but this is the expected behavior (we want to validate shapes eagerly).

Tests

Good edge-case coverage:

  • test_generalized_scatter_dynamic_clamped_slice: Tests z[:9223372036854775807] — exercises the sym_min clamping path in _slice_view_length with INT64_MAX.
  • test_generalized_scatter_dynamic_negative_slice: Tests z[-y.shape[0]:] — exercises wrap_negative_bound with a SymInt.
  • test_generalized_scatter_symbolic_view_args: Verifies the operator can be called in fake mode and produces correct shape metadata.
  • test_generalized_scatter_ignores_unrelated_view_ops: Regression test that unrelated views (t()) don't break scatter canonicalization.

No blocking issues found.


[ghstack-poisoned]
jansel added a commit that referenced this pull request May 18, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets and dispatcher-friendly encoded view args so intermediate reinplace graphs do not contain plain Python call_function targets. Validate scatter source broadcastability via the refs expand path to avoid unsupported translation-validation guard expressions.

Fixes #156818

Generated by my agent

ghstack-source-id: d02a276

Pull-Request: #184075
@jansel

jansel commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

@claude review these changes

@claude

claude Bot commented May 18, 2026 •

Copy link
Copy Markdown

Claude finished @jansel's task in 1m 27s —— View job


Code Review: Tighten generalized scatter graph target

  • Read PR diff and understand the changes
  • Review torch/_inductor/fx_passes/reinplace.py changes
  • Review test/inductor/test_inplacing_pass.py changes
  • Post review feedback

Summary: This PR converts _generalized_scatter and _inplace_generalized_scatter from plain Python functions to proper OpOverload targets registered under torch.ops._inductor_reinplace. ViewOp dataclasses are encoded into flat, schema-compatible tuples (view_codes, view_args, view_arg_counts, view_arg_none). A proper Meta implementation computes output shapes symbolically without materializing views.

Verdict: LGTM. Clean design, well-tested. Notes below.


Design

  1. Flat encoding scheme: The _encode_view_ops / _decode_view_ops round-trip through flat tuples is clean. The length-prefix approach for as_strided's variable-length size/stride is a good solution that avoids nested structures in the op schema.

  2. SymInt[] for view_args: Correctly allows fx.Node objects representing symbolic shapes to flow through the operator as graph dependencies.

  3. FRAGMENT library + CompositeExplicitAutograd: Appropriate since these ops are ephemeral graph-transformation artifacts.

  4. Symbolic Meta impl (reinplace.py:300-341): Computing view-chain shapes purely symbolically via _slice_view_length, _diagonal_view_length, etc. with torch.sym_min/torch.sym_max/torch.sym_ite is the right approach — avoids introducing guards.

Observations

  1. can_fuse() uses unnormalized scatter_view_op (reinplace.py:655-658): The comparison uses the raw scatter_view_op (with fx.Node args from node.args[2:]) against node_to_view_op entries that also store raw fx.Node references from handle_views. Both sides use structural @dataclass equality, which falls back to identity for fx.Node elements. This is correct and consistent. The normalized encoded_scatter_view_op is only used for the actual encoding into the new node.

  2. _apply_view_ops defensive fx.Node check (reinplace.py:236-242): The pytree.tree_map looking for fx.Node instances is effectively a no-op when called through CompositeExplicitAutograd dispatch (since graph_call_function already resolves nodes to meta["val"]). Harmless defensive code — would catch bugs if the impl were ever called with raw nodes.

  3. _validate_scatter_src_shape uses torch._refs.expand (reinplace.py:344-351): This is a lightweight way to check broadcast compatibility. The _refs.expand path works for both concrete and symbolic shapes, which is the right choice here.

  4. wrap_negative_bound fallthrough (reinplace.py:274): The bare return val handles the case where val is neither int nor torch.SymInt. In practice this path shouldn't be hit (slice args are always one of those types), but it's a safe fallback.

  5. _inplace_generalized_scatter_meta returns inp directly (reinplace.py:415): Correct for an in-place op — the schema declares Tensor(a!) return, so returning the input tensor preserves alias semantics in fake mode.

Tests

Good coverage across multiple dimensions:

  • test_generalized_scatter_target_is_operator: Verifies the core invariant (all targets are OpOverload or operator.getitem) and decomposition completeness.
  • test_generalized_scatter_symbolic_view_args: Exercises the symbolic shape path with SymInt[].
  • test_generalized_scatter_dynamic_clamped_slice: Tests z[:9223372036854775807] — exercises sym_min clamping in _slice_view_length with INT64_MAX.
  • test_generalized_scatter_dynamic_clamped_slice_translation_validation: Same scenario with z3 translation validation enabled — good for catching soundness issues in the symbolic arithmetic.
  • test_generalized_scatter_dynamic_negative_slice: Tests z[-y.shape[0]:] — exercises wrap_negative_bound with a SymInt.
  • test_generalized_scatter_ignores_unrelated_view_ops: Regression test that unrelated views (t()) don't break scatter canonicalization.

No blocking issues found.


View job

[ghstack-poisoned]
jansel added a commit that referenced this pull request May 19, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets and dispatcher-friendly encoded view args so intermediate reinplace graphs do not contain plain Python call_function targets. Validate scatter source broadcastability via the refs expand path and teach translation validation to lower SymPy Piecewise guards to Z3.

Fixes #156818

Generated by my agent

ghstack-source-id: a29f6ed

Pull-Request: #184075
@jansel

jansel commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

@claude review these changes

@claude

claude Bot commented May 19, 2026 •

Copy link
Copy Markdown

Claude finished @jansel's task in 1m 24s —— View job


Code Review: Tighten generalized scatter graph target

  • Read PR diff and understand the changes
  • Review torch/_inductor/fx_passes/reinplace.py changes
  • Review test/inductor/test_inplacing_pass.py changes
  • Review other changed files (validator.py, test_fx_experimental.py)
  • Post review feedback

Summary: This PR converts _generalized_scatter and _inplace_generalized_scatter from plain Python functions to proper OpOverload targets registered under torch.ops._inductor_reinplace. ViewOp dataclasses are encoded into flat, schema-compatible tuples (view_codes, view_args, view_arg_counts, view_arg_none). A proper Meta implementation computes output shapes symbolically. Additionally, z3 translation validation gains support for Piecewise/expr_cond_pair (needed for sym_ite in the symbolic slice length computation).

Verdict: LGTM. Clean, well-structured implementation with good test coverage. Notes below.


Design

  1. Flat encoding scheme (reinplace.py:155-174): The _encode_view_ops / _decode_view_ops round-trip is clean. The length-prefix approach for as_strided's variable-length size/stride in _flatten_view_op_args (line 148) avoids nested structures in the op schema. The view_arg_none bitmask for encoding None as (0, is_none=True) is a pragmatic way to keep SymInt[] homogeneous.

  2. Normalize-before-encode (reinplace.py:639-643): Converting kwargs to canonical positional form before encoding ensures a consistent representation regardless of call-site convention. The unnormalized scatter_view_op is correctly preserved for the can_fuse() identity-based comparison (line 655-658).

  3. Symbolic Meta impl (reinplace.py:300-341): Computing view-chain shapes purely symbolically using _slice_view_length, _diagonal_view_length, etc. with torch.sym_min/torch.sym_max/torch.sym_ite is the right approach — avoids introducing guards during tracing.

  4. FRAGMENT library + CompositeExplicitAutograd (reinplace.py:418-440): Appropriate since these ops are ephemeral graph-transformation artifacts that get decomposed before lowering.

  5. z3 piecewise support (validator.py:460-471): The implementation correctly builds a nested z3.If chain from right-to-left, matching sympy's Piecewise semantics where the last pair acts as the else branch. This unblocks translation validation for graphs containing sym_ite.

Observations

  1. can_fuse() comparison consistency (reinplace.py:655-658): The comparison uses the raw scatter_view_op (with fx.Node args from node.args[2:]) against node_to_view_op entries from handle_views (line 620-627) that also store raw fx.Node references. ViewOp is a @dataclass (not frozen), so equality is structural — fx.Node elements compare by identity. The normalized form is only used for encoding. This is correct and consistent.

  2. _apply_view_ops fx.Node handling (reinplace.py:236-241): The pytree.tree_map checking for fx.Node instances is effectively defensive code — when called through CompositeExplicitAutograd dispatch, graph_call_function (line 65-68) already resolves nodes to meta["val"] before the op is invoked. However, it's a safe fallback if the impl were ever called with raw nodes.

  3. detect_fake_mode scope (reinplace.py:224-225): The with fake_mode if fake_mode else nullcontext() wrapping the entire decode/view loop is a nice improvement over the previous per-view-op context manager — fewer context manager entries per call.

  4. _get_view_arg helper (reinplace.py:100-113): Clean resolution order: positional args → kwargs → default → error. The _MISSING sentinel avoids the None-as-default ambiguity that would otherwise arise with slice.Tensor's optional args.

  5. _inplace_generalized_scatter_meta returns inp directly (reinplace.py:415): Correct for the Tensor(a!) return schema — preserves alias semantics in fake mode.

Tests

Comprehensive edge-case coverage:

  • test_generalized_scatter_target_is_operator: Core invariant verification — all targets are OpOverload or operator.getitem.
  • test_generalized_scatter_symbolic_view_args: Exercises SymInt[] schema compatibility with symbolic shapes.
  • test_generalized_scatter_dynamic_clamped_slice: z[:9223372036854775807] exercises sym_min clamping in _slice_view_length with INT64_MAX.
  • test_generalized_scatter_dynamic_clamped_slice_translation_validation: Same with z3 validation — tests soundness of the symbolic arithmetic and the new piecewise z3 handler.
  • test_generalized_scatter_dynamic_negative_slice: z[-y.shape[0]:] exercises wrap_negative_bound with a SymInt and the sym_ite path.
  • test_generalized_scatter_ignores_unrelated_view_ops: Regression test that unrelated views (t()) don't break scatter canonicalization.

No blocking issues found.


View job

@jansel
jansel marked this pull request as ready for review May 19, 2026 21:23
@jansel
jansel requested review from oulgen, williamwen42 and zou3519 May 19, 2026 21:23
@jansel

jansel commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

@zou3519 can you look at this one?

@jansel

jansel commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 28, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

daisyden pushed a commit to daisyden/pytorch that referenced this pull request Jun 1, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets so intermediate reinplace graphs do not contain plain Python function call_function targets. Add regression coverage for the post-canonicalization graph invariant.

Fixes pytorch#156818

Generated by my agent

Pull Request resolved: pytorch#184075
Approved by: https://github.com/oulgen, https://github.com/zou3519
khushi-411 pushed a commit to khushi-411/pytorch that referenced this pull request Jun 1, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets so intermediate reinplace graphs do not contain plain Python function call_function targets. Add regression coverage for the post-canonicalization graph invariant.

Fixes pytorch#156818

Generated by my agent

Pull Request resolved: pytorch#184075
Approved by: https://github.com/oulgen, https://github.com/zou3519
@frgossen

Copy link
Copy Markdown
Contributor

@pytorchbot revert -m "Silent correctness regression in inductor reinplacing pass corrupts fp8 weights. Bisected and revert-confirmed on H100. See #188152" -c nosignal

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Reverting PR 184075 failed

Reason: Command git -C /home/runner/work/pytorch/pytorch revert --no-edit b35bc89b2928b9990a5104ed1af0f305c2fbc349 returned non-zero exit code 1

Auto-merging torch/_inductor/fx_passes/reinplace.py
CONFLICT (content): Merge conflict in torch/_inductor/fx_passes/reinplace.py
Auto-merging torch/fx/experimental/validator.py
error: could not revert b35bc89b292... Tighten generalized scatter graph target (#184075)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git revert --continue".
hint: You can instead skip this commit with "git revert --skip".
hint: To abort and get back to the state before "git revert",
hint: run "git revert --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Details for Dev Infra team Raised by workflow job

@frgossen

Copy link
Copy Markdown
Contributor

Reverting in #188219

frgossen added a commit that referenced this pull request Jun 26, 2026
This reverts commit b35bc89.

PR #184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The revert was applied on top of current main; three hunks in
reinplace.py conflicted only because later commits had refactored the
PR-introduced code (assert -> raise AssertionError). All conflicts were
resolved to the pre-PR form, fully removing the encode/decode machinery,
the torch.library registration, and the validator additions.

Test Plan:

```
python -c "import ast; ast.parse(open('torch/_inductor/fx_passes/reinplace.py').read())"
python test/inductor/test_inplacing_pass.py
```

This PR was authored with the assistance of an AI agent.


ghstack-source-id: 71af8ae
Pull-Request: #188219
frgossen added a commit that referenced this pull request Jun 26, 2026
This reverts commit b35bc89.

PR #184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The revert was applied on top of current main; three hunks in
reinplace.py conflicted only because later commits had refactored the
PR-introduced code (assert -> raise AssertionError). All conflicts were
resolved to the pre-PR form, fully removing the encode/decode machinery,
the torch.library registration, and the validator additions.

Test Plan:

```
python -c "import ast; ast.parse(open('torch/_inductor/fx_passes/reinplace.py').read())"
python test/inductor/test_inplacing_pass.py
```

This PR was authored with the assistance of an AI agent.


ghstack-source-id: af9ab73
Pull-Request: #188219
pytorchmergebot pushed a commit that referenced this pull request Jun 26, 2026
This reverts commit b35bc89.

PR #184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The revert was applied on top of current main; three hunks in
reinplace.py conflicted only because later commits had refactored the
PR-introduced code (assert -> raise AssertionError). All conflicts were
resolved to the pre-PR form, fully removing the encode/decode machinery,
the torch.library registration, and the validator additions.

Test Plan:

```
python -c "import ast; ast.parse(open('torch/_inductor/fx_passes/reinplace.py').read())"
python test/inductor/test_inplacing_pass.py
```

This PR was authored with the assistance of an AI agent.


ghstack-source-id: a985ff5
Pull-Request: #188219
pytorchmergebot pushed a commit that referenced this pull request Jun 26, 2026
This reverts commit b35bc89.

PR #184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The revert was applied on top of current main; three hunks in
reinplace.py conflicted only because later commits had refactored the
PR-introduced code (assert -> raise AssertionError). All conflicts were
resolved to the pre-PR form, fully removing the encode/decode machinery,
the torch.library registration, and the validator additions.

Test Plan:

```
python -c "import ast; ast.parse(open('torch/_inductor/fx_passes/reinplace.py').read())"
python test/inductor/test_inplacing_pass.py
```

This PR was authored with the assistance of an AI agent.

Pull Request resolved: #188219
Approved by: https://github.com/atalman, https://github.com/zou3519
atalman pushed a commit that referenced this pull request Jun 26, 2026
)" (#188277)

This reverts commit b35bc89 on the
release/2.13 branch. It is the release-branch counterpart of the
main-branch revert (#188219).

PR #184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The reinplace.py hunks conflicted against the release branch; all were
resolved to the pre-PR form with bare asserts (torch/_inductor/** is
still S101-exempt on this branch, so no noqa is added), fully removing
the encode/decode machinery, the torch.library registration, and the
z3 validator additions.

Test Plan:

```
lintrunner torch/_inductor/fx_passes/reinplace.py
```

This PR was authored with the assistance of an AI agent.
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets so intermediate reinplace graphs do not contain plain Python function call_function targets. Add regression coverage for the post-canonicalization graph invariant.

Fixes pytorch#156818

Generated by my agent

Pull Request resolved: pytorch#184075
Approved by: https://github.com/oulgen, https://github.com/zou3519
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ytorch#188219)

This reverts commit b35bc89.

PR pytorch#184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The revert was applied on top of current main; three hunks in
reinplace.py conflicted only because later commits had refactored the
PR-introduced code (assert -> raise AssertionError). All conflicts were
resolved to the pre-PR form, fully removing the encode/decode machinery,
the torch.library registration, and the validator additions.

Test Plan:

```
python -c "import ast; ast.parse(open('torch/_inductor/fx_passes/reinplace.py').read())"
python test/inductor/test_inplacing_pass.py
```

This PR was authored with the assistance of an AI agent.

Pull Request resolved: pytorch#188219
Approved by: https://github.com/atalman, https://github.com/zou3519
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
…ytorch#188219)

This reverts commit b35bc89.

PR pytorch#184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The revert was applied on top of current main; three hunks in
reinplace.py conflicted only because later commits had refactored the
PR-introduced code (assert -> raise AssertionError). All conflicts were
resolved to the pre-PR form, fully removing the encode/decode machinery,
the torch.library registration, and the validator additions.

Test Plan:

```
python -c "import ast; ast.parse(open('torch/_inductor/fx_passes/reinplace.py').read())"
python test/inductor/test_inplacing_pass.py
```

This PR was authored with the assistance of an AI agent.

Pull Request resolved: pytorch#188219
Approved by: https://github.com/atalman, https://github.com/zou3519
@github-actions
github-actions Bot deleted the gh/jansel/733/head branch July 26, 2026 02:24
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Represent Inductor's temporary generalized scatter form with private OpOverload targets so intermediate reinplace graphs do not contain plain Python function call_function targets. Add regression coverage for the post-canonicalization graph invariant.

Fixes pytorch#156818

Generated by my agent

Pull Request resolved: pytorch#184075
Approved by: https://github.com/oulgen, https://github.com/zou3519
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ytorch#188219)

This reverts commit b35bc89.

PR pytorch#184075 reworked Inductor's temporary generalized scatter form to use
private OpOverload targets (a torch.library FRAGMENT registering
generalized_scatter / inplace_generalized_scatter_ with flattened,
encoded view-op arguments) and added matching Piecewise support in the
z3 validator. This revert restores the prior representation that passes
view ops as a list of ViewOp dataclasses directly as call_function args.

The revert was applied on top of current main; three hunks in
reinplace.py conflicted only because later commits had refactored the
PR-introduced code (assert -> raise AssertionError). All conflicts were
resolved to the pre-PR form, fully removing the encode/decode machinery,
the torch.library registration, and the validator additions.

Test Plan:

```
python -c "import ast; ast.parse(open('torch/_inductor/fx_passes/reinplace.py').read())"
python test/inductor/test_inplacing_pass.py
```

This PR was authored with the assistance of an AI agent.

Pull Request resolved: pytorch#188219
Approved by: https://github.com/atalman, https://github.com/zou3519
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request Merged module: inductor topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants