Skip to content

fix(pass): constant folding keeps user-less in-place copies - #105

Open
wtr0504 wants to merge 1 commit into
SandAI-org:mainfrom
wtr0504:fix/fold-scalar-keep-inplace-copy
Open

wtr0504 wants to merge 1 commit into
SandAI-org:mainfrom
wtr0504:fix/fold-scalar-keep-inplace-copy

Conversation

@wtr0504

@wtr0504 wtr0504 commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

FoldPythonScalarConstantsPass ran graph-wide dead-code elimination on the pre-functionalization graph, where FX does not treat a Tensor.copy_ call_method as impure: a packed[:, :k].copy_(src) filling a buffer read later through packed has no users and was erased. Erase only the folded nodes that are left without users.

🗂️ PR Category

  • ✨ New Feature
  • 🚀 Optimization (performance, memory, etc.)
  • 💥 Breaking Change
  • 🐛 Bug Fix
  • 🛠️ Development / Refactoring
  • 📚 Documentation
  • 🧹 Chore (Dependencies, CI/CD, Configuration, etc.)
  • 🧪 Testing

📝 Description

FoldPythonScalarConstantsPass ran graph-wide dead-code elimination on the
pre-functionalization graph, where FX does not treat a Tensor.copy_ call_method
as impure: a `packed[:, :k].copy_(src)` filling a buffer read later through
`packed` has no users and was erased. Erase only the folded nodes that are left
without users.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant