Skip to content

Skip executing large aliased constant folds that 4531 will not install. - #4597

Draft
micwill755 wants to merge 1 commit into
one-shot-decomp-in-tracefrom
skip-aliased-fold-execute
Draft

Skip executing large aliased constant folds that 4531 will not install.#4597
micwill755 wants to merge 1 commit into
one-shot-decomp-in-tracefrom
skip-aliased-fold-execute

Conversation

@micwill755

@micwill755 micwill755 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Honor Inductor's skip_folding_node_fn during constant_fold() so large aliased weight permutes/views are not executed, then thrown away.
  • 4531 already skipped installing those folds (cpu().contiguous()). This skips computing them: _TorchTensorRTConstantFolder.run_node returns unknown without calling the op when the node is a true view of a large module tensor.
  • aten.contiguous and other materializing ops still run. The 4531 install-time skip stays as a safety net.

PR 6 of the compile-startup stack; based on #4596.

Test plan

  • tests/py/dynamo/lowering/test_skip_aliased_fold_execute.py (large permute skipped and not executed, small permute still folds, large contiguous still executes, materialized weight + weight still folds)
  • Klein/Flux compile not re-run for this PR: leftover ConstantFolder.run is ~50 ms, of which the aliased permutes are ~2 ms (4531 already took the ~0.25 s cpu().contiguous() copies)

Stack created with GitHub Stacks CLIGive Feedback 💬

@meta-cla meta-cla Bot added the cla signed label Aug 26, 2026
@github-actions github-actions Bot added component: tests Issues re: Tests component: lowering Issues re: The lowering / preprocessing passes component: core Issues re: The core compiler component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Aug 26, 2026
@github-actions
github-actions Bot requested a review from zewenli98 August 26, 2026 22:04
@micwill755
micwill755 force-pushed the skip-aliased-fold-execute branch from d844300 to b61b68c Compare September 1, 2026 18:30
Inductor's skip_folding_node_fn never fires on our cf.run() path; honor it so large weight permutes/views are not computed, then discarded.
@micwill755
micwill755 force-pushed the skip-aliased-fold-execute branch from b61b68c to cacfbc5 Compare September 2, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed component: api [Python] Issues re: Python API component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: lowering Issues re: The lowering / preprocessing passes component: tests Issues re: Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant