0
# Profiling and Performance Analysis
1
2
Profiling tools for analyzing training performance, identifying bottlenecks, and optimizing model training efficiency across different hardware configurations.
3
4
## Capabilities
5
6
### PyTorch Profiler
7
8
Integration with PyTorch's built-in profiler for detailed performance analysis.
9
10
```python { .api }
11
class PyTorchProfiler:
12
def __init__(
13
self,
14
dirpath: Optional[str] = None,
15
filename: Optional[str] = None,
16
group_by_input_shapes: bool = False,
17
emit_nvtx: bool = False,
18
export_to_chrome: bool = True,
19
row_limit: int = 20,
20
sort_by_key: Optional[str] = None,
21
record_functions: Set[str] = None,
22
record_shapes: bool = False,
23
profile_memory: bool = False,
24
with_stack: bool = False,
25
with_flops: bool = False,
26
with_modules: bool = False,
27
**profiler_kwargs
28
):
29
"""Initialize PyTorch profiler."""
30
```
31
32
### Advanced Profiler
33
34
Comprehensive profiling with detailed timing information.
35
36
```python { .api }
37
class AdvancedProfiler:
38
def __init__(
39
self,
40
dirpath: Optional[str] = None,
41
filename: Optional[str] = None,
42
line_count_restriction: float = 1.0
43
):
44
"""Initialize advanced profiler."""
45
```
46
47
### Simple Profiler
48
49
Basic profiling for quick performance analysis.
50
51
```python { .api }
52
class SimpleProfiler:
53
def __init__(
54
self,
55
dirpath: Optional[str] = None,
56
filename: Optional[str] = None,
57
extended: bool = True
58
):
59
"""Initialize simple profiler."""
60
```
61
62
### Pass Through Profiler
63
64
No-operation profiler that disables profiling without code changes.
65
66
```python { .api }
67
class PassThroughProfiler:
68
def __init__(self):
69
"""Initialize pass-through profiler that performs no profiling."""
70
```
71
72
### XLA Profiler
73
74
Profiler for TPU training with XLA optimization analysis.
75
76
```python { .api }
77
class XLAProfiler:
78
def __init__(
79
self,
80
port: int = 9012,
81
record_shapes: bool = False,
82
profile_memory: bool = False
83
):
84
"""Initialize XLA profiler for TPU performance analysis."""
85
```
86
87
### Base Profiler
88
89
Base class for implementing custom profilers.
90
91
```python { .api }
92
class Profiler:
93
def __init__(self):
94
"""Initialize base profiler."""
95
96
def start(self, action_name: str) -> None:
97
"""Start profiling an action."""
98
99
def stop(self, action_name: str) -> None:
100
"""Stop profiling an action."""
101
102
def summary(self) -> str:
103
"""Get profiling summary."""
104
105
def describe(self) -> None:
106
"""Print profiling description."""
107
```