KEMBAR78
[dynamo] Deprecate enable_cpp_framelocals_guard_eval config variable - default: True by BartlomiejStemborowski · Pull Request #151008 · pytorch/pytorch · GitHub
Skip to content

Conversation

@BartlomiejStemborowski
Copy link
Contributor

@BartlomiejStemborowski BartlomiejStemborowski commented Apr 10, 2025

[dynamo] Deprecate enable_cpp_framelocals_guard_eval config variable - default: True

Reading the feature enabling param enable_cpp_framelocals_guard_eval at the CPP level is time consuming and slows down the operation of the dynamo as it is done every time the function using this param is called. Reading the value only once at init isn’t an option as it would disable the modification of this param at the runtime. Since this feature is enabled by default for some time and it doesn’t cause known issues, the enable_cpp_framelocals_guard_eval configuration param will be deprecated by this commit and its value is hardcoded to true.

Local microbenchmark dynamo_guard_eval.py:

  • 931.9 us -> 538.9 us (3.10)

@williamwen42 @jansel @anijain2305

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

…once

Flow in the function run_root_guard_manager depends on the value of the enable_cpp_framelocals_guard_eval config
variable from the torch._dynamo.config file. Reading this variable each time is time consuming as it requires
importing whole module. In order to do it only once, the local variable enable_cpp_framelocals_guard_eval is
converted into a static one and is initialized with the value read from the config file.

Local microbenchmark dynamo_guard_eval.py:
- 931.9 us -> 553.7 us (3.10)
@pytorch-bot
Copy link

pytorch-bot bot commented Apr 10, 2025

🔗 Helpful Links

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

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

❌ 1 Cancelled Job

As of commit 1de5ffa with merge base 4273e5d (image):

CANCELLED JOB - The following job was cancelled. Please retry:

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

@BartlomiejStemborowski
Copy link
Contributor Author

@williamwen42 @jansel @anijain2305
Please help with the review

@BartlomiejStemborowski
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

Copy link
Member

@williamwen42 williamwen42 left a comment

Choose a reason for hiding this comment

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

We had a bunch of issues in the past involving loading modules statically, which is why I'm loading every time (cpython also caches these imports, so we're not actually doing the full import every time).

I also haven't received any complaints about this feature recently, so we could just deprecate this config.

…- default: True

Reading the feature enabling param enable_cpp_framelocals_guard_eval at the CPP level is time consuming
and slows down the operation of the dynamo as it is done every time the function using this param is called.
Reading the value only once at init isn’t an option as it would disable the modification of this param at
the runtime. Since this feature is enabled by default for some time and it doesn’t cause known issues,
the enable_cpp_framelocals_guard_eval configuration param will be deprecated by this commit and its value
is hardcoded to true.
@BartlomiejStemborowski BartlomiejStemborowski changed the title [dynamo] Read enable_cpp_framelocals_guard_eval config variable only once [dynamo] Deprecate enable_cpp_framelocals_guard_eval config variable - default: True Apr 11, 2025
@BartlomiejStemborowski
Copy link
Contributor Author

Updated the PR with the patch deprecating the enable_cpp_framelocals_guard_eval config. Please check.
@williamwen42 @jansel @anijain2305

@williamwen42
Copy link
Member

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 11, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / macos-py3-arm64 / build

Details for Dev Infra team Raised by workflow job

@williamwen42
Copy link
Member

@pytorchbot merge -i

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: trunk / macos-py3-arm64 / build

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

timocafe pushed a commit to timocafe/pytorch that referenced this pull request Apr 16, 2025
…- default: True (pytorch#151008)

[dynamo] Deprecate enable_cpp_framelocals_guard_eval config variable - default: True

Reading the feature enabling param `enable_cpp_framelocals_guard_eval `at the CPP level is time consuming and slows down the operation of the dynamo as it is done every time the function using this param is called. Reading the value only once at init isn’t an option as it would disable the modification of this param at the runtime. Since this feature is enabled by default for some time and it doesn’t cause known issues, the `enable_cpp_framelocals_guard_eval `configuration param will be deprecated by this commit and its value is hardcoded to true.

Local microbenchmark dynamo_guard_eval.py:
- 931.9 us -> 538.9 us (3.10)

@williamwen42 @jansel @anijain2305

Pull Request resolved: pytorch#151008
Approved by: https://github.com/williamwen42
amathewc pushed a commit to amathewc/pytorch that referenced this pull request Apr 17, 2025
…- default: True (pytorch#151008)

[dynamo] Deprecate enable_cpp_framelocals_guard_eval config variable - default: True

Reading the feature enabling param `enable_cpp_framelocals_guard_eval `at the CPP level is time consuming and slows down the operation of the dynamo as it is done every time the function using this param is called. Reading the value only once at init isn’t an option as it would disable the modification of this param at the runtime. Since this feature is enabled by default for some time and it doesn’t cause known issues, the `enable_cpp_framelocals_guard_eval `configuration param will be deprecated by this commit and its value is hardcoded to true.

Local microbenchmark dynamo_guard_eval.py:
- 931.9 us -> 538.9 us (3.10)

@williamwen42 @jansel @anijain2305

Pull Request resolved: pytorch#151008
Approved by: https://github.com/williamwen42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants