Skip to content

Commit 0756ebc

Browse files
bobrenjc93pytorchmergebot
authored andcommitted
Add docblock to torch/_dynamo/trace_rules.py (pytorch#155401)
Add comprehensive module docstring explaining the tracing rules and policies that govern TorchDynamo's compilation decisions, including skip rules, inlining policies, and library-specific handling. Originally generated by claude but reviewed and edited by me. Pull Request resolved: pytorch#155401 Approved by: https://github.com/williamwen42
1 parent abf4da0 commit 0756ebc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

torch/_dynamo/trace_rules.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
# mypy: allow-untyped-defs
2+
3+
"""
4+
Tracing rules and policies for TorchDynamo compilation decisions.
5+
6+
This module defines the rules that govern what code TorchDynamo should trace and compile
7+
versus what should be executed eagerly. It contains functions and classes that determine:
8+
9+
- Which modules, functions, and objects should be skipped during tracing
10+
- Which parts of the code should cause graph breaks
11+
- How to handle different Python libraries and third-party packages
12+
- Rules for determining when to inline functions vs calling them eagerly
13+
14+
Key components:
15+
- Skip rules: Functions that return True if an object should be skipped during tracing
16+
- Inlining rules: Policies for when to inline function calls during compilation
17+
- Library-specific handling: Special cases for popular Python packages
18+
- Performance heuristics: Rules that balance compilation overhead vs runtime benefits
19+
20+
These rules are critical for TorchDynamo's ability to automatically determine
21+
compilation boundaries and optimize PyTorch programs effectively.
22+
"""
23+
224
import abc
325
import builtins
426
import collections

0 commit comments

Comments
 (0)