05-acceleration showed a Python for loop pays real, fixed overhead per iteration, purely for being interpreted. Eager-mode PyTorch has an analogous cost at a different level: every single tensor operation call pays its own fixed Python-and-framework "dispatch" overhead — deciding which underlying kernel to actually run, checking types and devices — completely separate from the actual math that operation performs. A model with hundreds of layers pays that dispatch tax hundreds of separate times, every single forward pass.
Implement eager_python_dispatch_overhead(num_ops, per_op_dispatch_seconds), graph_mode_dispatch_overhead(per_op_dispatch_seconds), and graph_mode_speedup_estimate(...) — quantifying exactly the dispatch-overhead savings that exporting a model to TorchScript or ONNX (running as a compiled graph, not live Python) provides.
eager_python_dispatch_overhead returns num_ops * per_op_dispatch_seconds — every op pays the dispatch cost separately.graph_mode_dispatch_overhead returns per_op_dispatch_seconds directly — paid exactly once, regardless of how many ops the underlying graph actually contains.graph_mode_speedup_estimate returns eager_python_dispatch_overhead / graph_mode_dispatch_overhead.Open one at a time. Each gives away a little more than the last.
This mirrors 04-torch-compile-graph-compilation's exact shape: one quantity that scales with num_ops, one quantity that stays flat regardless of num_ops, and a ratio between them.
graph_mode_dispatch_overhead doesn't even need num_ops as a parameter — the whole point is that a compiled graph's dispatch cost genuinely doesn't depend on how many operations are inside it.
No results yet
Run your code to check it against the examples, or submit to run every test.