8000 [Dynamo] Introduce hook receiving set of traced files by jbschlosser · Pull Request #153622 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[Dynamo] Introduce hook receiving set of traced files #153622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: gh/jbschlosser/246/base
Choose a base branch
from

Conversation

jbschlosser
Copy link
Contributor
@jbschlosser jbschlosser commented May 15, 2025

Stack from ghstack (oldest at bottom):

This PR:

  • Expands Hooks with a new, optional frame_traced_fn field. It should be a callable receiving the set of traced filenames
  • Maintains a set of traced_files in the TracingContext of an OutputGraph
    • Whenever an inline_call() is encountered, the corresponding filename is added to this set
    • OutputGraph's co_fields["co_filename"] is added to the set before the hook is called

I believe use of this hook should enable the source code hashing that vLLM does in a better way than monkey-patching inline_call().

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

Copy link
pytorch-bot bot commented May 15, 2025

🔗 Helpful Links

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

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

❌ 2 New Failures, 3 Unrelated Failures

As of commit dc5a663 with merge base 9c11493 (image):

NEW FAILURES - The following jobs have failed:

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

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

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

This PR:
* Expands `Hooks` with a new, optional `frame_traced_fn` field. It should be a callable receiving the set of traced filenames
* Maintains a set of `traced_files` in the `TracingContext` of an `OutputGraph`
    *  Whenever an `inline_call()` is encountered, the corresponding filename is added to this set
    * `OutputGraph`'s `co_fields["co_filename"]` is added to the set before the hook is called

I believe use of this hook should enable the source code hashing that vLLM does in a better way than monkey-patching `inline_call()`.

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

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request May 15, 2025
ghstack-source-id: d7a1083
Pull Request resolved: #153622
@@ -865,6 +865,8 @@ def __init__(self, fake_mode):
# see note: [Returning Fake Tensors on First AOT Autograd Call]
self.fakify_first_call = False
self.hop_dispatch_set_cache = HopDispatchSetCache()
# set of filenames for inlined functions
self.traced_files: set[str] = set()
Copy link
Contributor

Choose a reason for hiding this comment

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

OrderedSet or list

# they are benign and do not generate any new graphs.
hooks.guard_export_fn(output.guards)
if hooks.frame_traced_fn is not None:
output.tracing_context.traced_files.add(output.co_fields["co_filename"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the filename enough? One file can have many things in it. Maybe a function or code object would enable more use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
39C0
Development

Successfully merging this pull request may close these issues.

2 participants
0