Skip to content

[Dynamo][Better Engineering] Add enhanced typing support to _dynamo/eval_frame.py#158276

Closed
Lucaskabela wants to merge 2 commits intomainfrom
lucaskabela/typing_eval_frame
Closed

[Dynamo][Better Engineering] Add enhanced typing support to _dynamo/eval_frame.py#158276
Lucaskabela wants to merge 2 commits intomainfrom
lucaskabela/typing_eval_frame

Conversation

@Lucaskabela
Copy link
Contributor

@Lucaskabela Lucaskabela commented Jul 14, 2025

As part of better engineering week, we would like to improve out type support to improve dev experience in dynamo

This PR adds strict typing support to the main entrypoint for dynamo, eval_frame.py

Running

mypy torch/_dynamo/eval_frame.py --linecount-report /tmp/coverage_log
-------- Lines Unannotated Lines Total % lines covered Funcs Unannotated Funcs Total % funcs covered
Main 623 2232 27.91% 19 68 27.94%
This PR 2285 2285 100.00% 68 68 100.00%
Delta +1662 +63 +72.09% +49 0 +72.06%

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

@pytorch-bot
Copy link

pytorch-bot bot commented Jul 14, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 4e4ec45 with merge base 5a54db1 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@Lucaskabela Lucaskabela force-pushed the lucaskabela/typing_eval_frame branch 2 times, most recently from 789efdd to 437994f Compare July 14, 2025 23:29
@Lucaskabela
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Jul 14, 2025
@Lucaskabela Lucaskabela force-pushed the lucaskabela/typing_eval_frame branch from 437994f to e2ead9a Compare July 15, 2025 16:20
@Lucaskabela Lucaskabela force-pushed the lucaskabela/typing_eval_frame branch from e2ead9a to 76f56da Compare July 15, 2025 18:15
@Lucaskabela Lucaskabela changed the title [Better Engineering] Add strict typing support to _dynamo/eval_frame.py [Better Engineering] Add enhanced typing support to _dynamo/eval_frame.py Jul 15, 2025
f_builtins: dict[str, object]
f_lasti: int
f_lineo: int
f_lineno: int
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved typing helped catch this error :)


# TODO(voz): Do we want a decorator for this?
reset()
from .backends.debugging import ExplainOutput
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved up to L1238 for typehint

@Lucaskabela Lucaskabela changed the title [Better Engineering] Add enhanced typing support to _dynamo/eval_frame.py [Dynamo][Better Engineering] Add enhanced typing support to _dynamo/eval_frame.py Jul 15, 2025
@Lucaskabela Lucaskabela marked this pull request as ready for review July 15, 2025 21:12
Co-authored-by: William Wen <williamwen@meta.com>
@Lucaskabela Lucaskabela force-pushed the lucaskabela/typing_eval_frame branch from 634f8c3 to 4e4ec45 Compare July 16, 2025 18:53
@Lucaskabela
Copy link
Contributor Author

@pytorchmergebot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 16, 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

@github-actions github-actions bot deleted the lucaskabela/typing_eval_frame branch August 16, 2025 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants