TorchTalk PyTorch Analyzer
When to Use
- •"How does torch.X work internally?"
- •"Where is X implemented?" (Python/C++/CUDA)
- •"What would break if I change X?"
- •"How does nn.Linear connect to native code?"
- •"Find tests for the softmax operator"
Quick Start
code
get_status() # Check what's loaded and available
Tools by Category
ATen Operators (torch.add, torch.matmul, etc.)
| Tool | Use For |
|---|---|
trace(name, focus?) | Python → YAML → C++ → file:line |
search(query, backend?) | Find ops by name, filter by CPU/CUDA |
cuda_kernels(name?) | GPU kernel launches |
Call Graph Analysis (requires PyTorch build)
| Tool | Use For |
|---|---|
impact(name, depth?) | What breaks if I change this? (transitive callers) |
calls(name) | What does this function call? |
called_by(name) | What calls this function? |
Python Modules (torch.nn, torch.optim)
| Tool | Use For |
|---|---|
trace_module(name) | Trace nn.Linear, optim.Adam, etc. |
list_modules(category) | List available modules ("nn", "optim", "all") |
Test Infrastructure
| Tool | Use For |
|---|---|
find_similar_tests(query) | Find tests for an operator/concept |
list_test_utils(category) | Available test utilities and patterns |
test_file_info(path) | Details about a specific test file |
Common Workflows
"How does torch.matmul work?"
code
trace("matmul") # Get binding chain
calls("matmul") # See internal dependencies
"What breaks if I modify GEMM?"
code
impact("gemm", depth=4) # Transitive callers + Python entry points
"Where is conv2d for CUDA?"
code
search("conv2d", backend="CUDA")
# or
trace("conv2d", focus="dispatch")
"How does nn.Linear work?"
code
trace_module("Linear") # Python class details
trace("linear") # Underlying ATen op
"Find tests for softmax"
code
find_similar_tests("softmax")
Requirements
- •Always available: trace, search, cuda_kernels, trace_module, list_modules, test tools
- •Requires PyTorch build: impact, calls, called_by (need
compile_commands.json)
Run get_status() to check availability.