Replace frame_traced_fn hook with get_traced_code() util (#155249)

#153622 introduced a hook for getting the relevant code objects after frame tracing. The idea is to have vLLM use this instead of monkey-patching `inline_call_()` to determine the source code files to hash. Unfortunately, the hook runs too late; the vLLM backend needs access to the set of source code filenames while it's running.

This PR replaces the newly-added hook with a utility function that a backend can call to get this information. I've made the change in vLLM and can verify that this allows the information to be queried at the right time.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/155249
Approved by: https://github.com/zou3519
This commit is contained in:
Joel Schlosser
2025-06-10 13:24:34 -04:00
committed by PyTorch MergeBot
parent 8892b782a8
commit c4b93e6579
8 changed files with 41 additions and 40 deletions

View File

@ -2630,10 +2630,6 @@ def compile(
if options and isinstance(options, dict):
guard_filter_fn = options.pop("guard_filter_fn", None)
frame_traced_fn = None
if options and isinstance(options, dict):
frame_traced_fn = options.pop("frame_traced_fn", None)
if backend == "inductor":
backend = _TorchCompileInductorWrapper(mode, options, dynamic)
else:
@ -2645,7 +2641,6 @@ def compile(
dynamic=dynamic,
disable=disable,
guard_filter_fn=guard_filter_fn,
frame_traced_fn=frame_traced_fn,
)(model) # type: ignore[return-value]