Change NamedTupleVariable implementation to subclass UserDefinedTupleVariable#167468
Change NamedTupleVariable implementation to subclass UserDefinedTupleVariable#167468morrison-turnansky wants to merge 28 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/167468
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 992fe52 with merge base d2237eb ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
I went through the repo and grabbed namedtuple tests. The following pass locally with python 3.13 (required for collections tests) |
597d115 to
768d30d
Compare
|
@isuruf addressed failing tests, we should be good now |
StrongerXi
left a comment
There was a problem hiding this comment.
This looks great! Could you please keep NamedTupleVariable inside lists.py though, for 2 reasons:
- To minimize changes and make the diff clearer.
- We already have more non-primitive container classes like deque and torch.Size emulated inside
lists.py, so it makes sense to keep named tuple there as well.
I think you can avoid circular dependency by moving this to within where it's used:
pytorch/torch/_dynamo/variables/user_defined.py
Lines 744 to 747 in 780e325
|
@StrongerXi I moved NamedTupleVariable back to list. You'll see some additional changes to fix circular dependencies besides what you listed. In addition, since typing errors in user_defined.py is ignored, I had to make some linting changes. Everything else is more or less the same. |
guilhermeleobas
left a comment
There was a problem hiding this comment.
One a few minor comments but the code looks good to me. Thanks for the contribution @morrison-turnansky
StrongerXi
left a comment
There was a problem hiding this comment.
Dropped a nit on docs, otherwise LGTM! Please address Guilherme's comments too. Thank you for this clean up!
|
@pytorchbot merge |
Merge startedYour 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 |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@pytorchbot merge -f "unrelated build error" |
3d026d0 to
992fe52
Compare
|
@pytorchbot merge |
|
Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra. |
|
@pytorchbot merge |
|
Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra. |
|
@pytorchbot merge |
|
Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra. |
|
@pytorchbot merge |
|
Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra. |
|
@pytorchbot merge |
Merge startedYour 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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10 / test (distributed, 3, 3, linux.rocm.gpu.gfx942.4) Details for Dev Infra teamRaised by workflow job |
|
@pytorch merge -i |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: trunk / linux-jammy-rocm-py3.10 / test (distributed, 2, 3, linux.rocm.gpu.gfx942.4) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…Variable (pytorch#167468) Continuation of work from previous PR, see link for context pytorch#161645 (comment) I think this PR is a step in that direction. There is probably some room for simplification. At a high level, the new class NamedTupleVariable handles methods that branch on structseq or the more dynamic subclasses of namedtuple, and falls back to UserDefinedTupleVariable otherwise. Please let me know what you think. @StrongerXi Pull Request resolved: pytorch#167468 Approved by: https://github.com/Lucaskabela
Continuation of work from previous PR, see link for context #161645 (comment)
I think this PR is a step in that direction. There is probably some room for simplification.
At a high level, the new class NamedTupleVariable handles methods that branch on structseq or the more dynamic subclasses of namedtuple, and falls back to UserDefinedTupleVariable otherwise.
Please let me know what you think. @StrongerXi
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @Lucaskabela @jataylo @chenyang78