Skip to content

[dynamo] Migrate ContextVarVariable methods to tp_methods - #195167

Closed
PrabinDevkota wants to merge 1 commit into
pytorch:mainfrom
PrabinDevkota:fix-195165-contextvar-tp-methods
Closed

PrabinDevkota wants to merge 1 commit into
pytorch:mainfrom
PrabinDevkota:fix-195165-contextvar-tp-methods

Conversation

@PrabinDevkota

@PrabinDevkota PrabinDevkota commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Migrate ContextVarVariable off a call_method if-chain onto declarative tp_methods, as in #195165.

get / set / reset are now Method handlers. Arity comes from CPython ml_flags (METH_FASTCALL for get, METH_O for set/reset). The extra-positional check on get is kept because FASTCALL does not cap at one argument. set / reset still graph-break.

Part of #195165 (does not close the umbrella).

Test plan

  • python test/dynamo/test_contextvars.py (24 passed)

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98

@pytorch-bot

pytorch-bot Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (3 Unrelated Failures)

As of commit 24c2794 with merge base 6a211a9 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

CRCR (non-blocking) - The following CRCR downstream CI jobs failed but are non-blocking:

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

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo labels Aug 28, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@PrabinDevkota

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Aug 28, 2026

@guilhermeleobas guilhermeleobas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@guilhermeleobas

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: torchtitan-test / torchtitan-x-pytorch-test / test (torchtitan_models_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8)

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

Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
…5167)

## Summary
Migrate `ContextVarVariable` off a `call_method` if-chain onto declarative `tp_methods`, as in pytorch#195165.

`get` / `set` / `reset` are now `Method` handlers. Arity comes from CPython `ml_flags` (`METH_FASTCALL` for `get`, `METH_O` for `set`/`reset`). The extra-positional check on `get` is kept because FASTCALL does not cap at one argument. `set` / `reset` still graph-break.

Part of pytorch#195165 (does not close the umbrella).

## Test plan
- [x] `python test/dynamo/test_contextvars.py` (24 passed)

Pull Request resolved: pytorch#195167
Approved by: https://github.com/guilhermeleobas
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: dynamo open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants