Repository navigation
Conversation
Cell variables that share a name with a local variable are stored separately in `localsplus` in cpython. This distinction is lost in dynamo, where all variables are stored in `symbolic_locals`. This doesn't matter for most purposes, but becomes relevant with the combination of an inlined list comprehension graph break with nested graph breaks enabled. In this case the shared entry in `symbolic_locals` gets set to NULL, which causes a segfault when dynamo tries to pass the cell to the resume function. Authored with an LLM ghstack-source-id: f957817 Pull-Request: #188029
Cell variables that share a name with a local variable are stored separately in `localsplus` in cpython. This distinction is lost in dynamo, where all variables are stored in `symbolic_locals`. This doesn't matter for most purposes, but becomes relevant with the combination of an inlined list comprehension graph break with nested graph breaks enabled. In this case the shared entry in `symbolic_locals` gets set to NULL, which causes a segfault when dynamo tries to pass the cell to the resume function. Authored with an LLM ghstack-source-id: f957817 Pull-Request: #188029
| # in `symbolic_locals` would let fast-local ops (LOAD_FAST_AND_CLEAR) clobber | ||
| # the cell, so the colliding cell lives here instead. Non-colliding cells | ||
| # stay in `symbolic_locals`. | ||
| symbolic_cellvars: dict[str, VariableTracker] |
There was a problem hiding this comment.
could we name this symbolic_localsplus?
There was a problem hiding this comment.
It's not directly analogous to localsplus, since it only holds cells. I thought about having a single localsplus storage, but it would have to be an array rather than a dict keyed by variable name. That would actually be a pretty big change since we also need to reference variables by name for codegen. So I think we probably need separate storage for locals and cells, though I'm not sure if this is the best way to manage it
| # symbolic_cellvars registers all of the frame's cells; listing it | ||
| # second makes cell contents take precedence over a (shadowing) | ||
| # colliding fast local of the same name. | ||
| items = list(tx.symbolic_locals.items()) + list(tx.symbolic_cellvars.items()) |
There was a problem hiding this comment.
Use itertools.chain
| # when the slot doesn't hold a cell: either the name is a colliding | ||
| # free var that never lives in symbolic_locals, or the cell was | ||
| # temporarily evicted by LOAD_FAST_AND_CLEAR. | ||
| var = self.symbolic_locals.get(name) |
There was a problem hiding this comment.
Is it guaranteed that name is in symbolic_locals? on _register_cells you pop the intersection of (co_freevars, co_varnames).
There was a problem hiding this comment.
No. If it's missing .get will return None and we'll fall back to symbolic_cellvars
This reverts commit 7ac8666. Reverted #189592 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](#188029 (comment)))
…ocals (#188029)" This reverts commit 0c0aa24. Reverted #188029 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](#188029 (comment)))
|
@rtimpe your PR has been successfully reverted. |
…ytorch#188029) Cell variables that share a name with a local variable are stored separately in `localsplus` in cpython. This distinction is lost in dynamo, where all variables are stored in `symbolic_locals`. This doesn't matter for most purposes, but becomes relevant with the combination of an inlined list comprehension graph break with nested graph breaks enabled. In this case the shared entry in `symbolic_locals` gets set to NULL, which causes a segfault when dynamo tries to pass the cell to the resume function. Authored with an LLM Pull Request resolved: pytorch#188029 Approved by: https://github.com/guilhermeleobas, https://github.com/williamwen42
This adds support for sentinels created outside of the compiled region and basic operations on them (identity comparsion and attribute access). Creating sentinels, as well as other operations, are not supported yet. This is the minimal amount of support needed for pytorch#185682 Generated with AI assistance Pull Request resolved: pytorch#189592 Approved by: https://github.com/guilhermeleobas ghstack dependencies: pytorch#188029
Fix pygen_yf to account for virtual iterators in python 3.15 Pull Request resolved: pytorch#190312 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#188029, pytorch#189592
This reverts commit 0f32fe1. Reverted pytorch#190312 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#188029 (comment)))
This reverts commit 7ac8666. Reverted pytorch#189592 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#188029 (comment)))
…ocals (pytorch#188029)" This reverts commit 0c0aa24. Reverted pytorch#188029 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#188029 (comment)))
|
Starting merge as part of PR stack under #190312 |
This adds support for sentinels created outside of the compiled region and basic operations on them (identity comparsion and attribute access). Creating sentinels, as well as other operations, are not supported yet. This is the minimal amount of support needed for #185682 Generated with AI assistance Pull Request resolved: #189592 Approved by: https://github.com/guilhermeleobas ghstack dependencies: #188029
Fix pygen_yf to account for virtual iterators in python 3.15 Pull Request resolved: #190312 Approved by: https://github.com/Skylion007 ghstack dependencies: #188029, #189592
…ytorch#188029) Cell variables that share a name with a local variable are stored separately in `localsplus` in cpython. This distinction is lost in dynamo, where all variables are stored in `symbolic_locals`. This doesn't matter for most purposes, but becomes relevant with the combination of an inlined list comprehension graph break with nested graph breaks enabled. In this case the shared entry in `symbolic_locals` gets set to NULL, which causes a segfault when dynamo tries to pass the cell to the resume function. Authored with an LLM Pull Request resolved: pytorch#188029 Approved by: https://github.com/guilhermeleobas, https://github.com/williamwen42
This adds support for sentinels created outside of the compiled region and basic operations on them (identity comparsion and attribute access). Creating sentinels, as well as other operations, are not supported yet. This is the minimal amount of support needed for pytorch#185682 Generated with AI assistance Pull Request resolved: pytorch#189592 Approved by: https://github.com/guilhermeleobas ghstack dependencies: pytorch#188029
Fix pygen_yf to account for virtual iterators in python 3.15 Pull Request resolved: pytorch#190312 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#188029, pytorch#189592
This reverts commit 0f32fe1. Reverted pytorch#190312 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#188029 (comment)))
This reverts commit 7ac8666. Reverted pytorch#189592 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#188029 (comment)))
…ocals (pytorch#188029)" This reverts commit 0c0aa24. Reverted pytorch#188029 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#188029 (comment)))
Stack from ghstack (oldest at bottom):
Cell variables that share a name with a local variable are stored separately in
localsplusin cpython. Thisdistinction is lost in dynamo, where all variables are stored in
symbolic_locals. This doesn't matter for mostpurposes, but becomes relevant with the combination of an inlined list comprehension graph break with nested graph breaks
enabled. In this case the shared entry in
symbolic_localsgets set to NULL, which causes a segfault when dynamo triesto pass the cell to the resume function.
Authored with an LLM
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98