benchmark
84363122 - Deprecate the profiler's with_modules option (#192808)

Commit
103 days ago
Deprecate the profiler's with_modules option (#192808) Summary: **Motivation** `with_modules` attaches a "Module Hierarchy" string to each op, but it only collects anything for TorchScript models. It reads the TorchScript interpreter's thread-local frame stack, which is empty in eager mode, so an eager run pays for the argument and gets nothing back. TorchScript has been deprecated since 2.5 and `torch.jit.script` now raises a `FutureWarning`, so the option has no supported way left to produce data. Its other consumer, `KinetoEdgeCPUProfiler`, serves Lite Interpreter, deprecated in favor of ExecuTorch. Nothing downstream reads the field. It is written by `AddTensorboardFields`, but the TensorBoard plugin only ever consumed "Call stack" and has since been deleted from kineto. `KinetoEvent::moduleHierarchy` is not bound to Python, and `hasModuleHierarchy` has no callers anywhere. Eager users wanting module attribution already get `nn.Module` events from `with_stack=True`. **Approach** The warning goes in `torch.autograd.profiler.profile.__init__`, the one constructor every public path reaches, since `torch.profiler.profile` and `_KinetoProfile` both build one in `prepare_trace`. Warning there fires once per profiler rather than once per layer, and sits beside the `profiler_metrics` deprecation that solves the same plumbing problem the same way. The four in-tree callers passing `with_modules=True` are all eager, so they collect nothing today and are dropped rather than carried through the deprecation. `test_module_hierarchy` asserted only inside `if "Module Hierarchy" in args`, so it passed with zero comparisons whenever the feature emitted nothing; the feature could have been gutted without turning CI red. It now counts its comparisons and requires at least one. Only the Python surface is deprecated here. The C++ `ProfilerConfig` field, `collection.cpp`, the edge profiler, and kineto's `ClientInterface::prepare` signature are untouched; that removal belongs with Lite Interpreter's. Authored with assistance from Claude Code. X-link: https://github.com/pytorch/pytorch/pull/192808 Approved by: https://github.com/ryanzhang22 Reviewed By: atalman Differential Revision: D115505059 fbshipit-source-id: 992e44c59d0173a2b14ba4946020ee4d35cf52db
Author
Committer
Parents
Loading