stormlog.profiler
Core Stormlog for PyTorch.
Classes
|
Comprehensive GPU memory profiler for PyTorch operations. |
|
Represents a memory snapshot at a specific point in time. |
|
Results from profiling a function or operation. |
Tracks tensor creation and deletion for memory profiling. |
- class stormlog.profiler.MemorySnapshot(timestamp, allocated_memory, reserved_memory, max_memory_allocated, max_memory_reserved, active_memory, inactive_memory, cpu_memory, device_id=0, operation=None, stack_trace=None)[source]
Bases:
objectRepresents a memory snapshot at a specific point in time.
- Parameters:
timestamp (float)
allocated_memory (int)
reserved_memory (int)
max_memory_allocated (int)
max_memory_reserved (int)
active_memory (int)
inactive_memory (int)
cpu_memory (int)
device_id (int)
operation (str | None)
stack_trace (str | None)
- timestamp: float
- allocated_memory: int
- reserved_memory: int
- max_memory_allocated: int
- max_memory_reserved: int
- active_memory: int
- inactive_memory: int
- cpu_memory: int
- device_id: int = 0
- operation: str | None = None
- stack_trace: str | None = None
- class stormlog.profiler.ProfileResult(function_name, execution_time, memory_before, memory_after, memory_peak, memory_allocated, memory_freed, tensors_created, tensors_deleted, call_count=1)[source]
Bases:
objectResults from profiling a function or operation.
- Parameters:
function_name (str)
execution_time (float)
memory_before (MemorySnapshot)
memory_after (MemorySnapshot)
memory_peak (MemorySnapshot)
memory_allocated (int)
memory_freed (int)
tensors_created (int)
tensors_deleted (int)
call_count (int)
- function_name: str
- execution_time: float
- memory_before: MemorySnapshot
- memory_after: MemorySnapshot
- memory_peak: MemorySnapshot
- memory_allocated: int
- memory_freed: int
- tensors_created: int
- tensors_deleted: int
- call_count: int = 1
- class stormlog.profiler.GPUMemoryProfiler(device=None, track_tensors=True, track_cpu_memory=True, collect_stack_traces=False)[source]
Bases:
objectComprehensive GPU memory profiler for PyTorch operations.
- Parameters:
device (str | int | torch.device | None)
track_tensors (bool)
track_cpu_memory (bool)
collect_stack_traces (bool)
- profile_function(func, *args, **kwargs)[source]
Profile a single function call.
- Parameters:
func (Callable[[...], Any]) – Function to profile
*args (Any) – Arguments to pass to function
**kwargs (Any) – Keyword arguments to pass to function
- Returns:
ProfileResult with profiling information
- Return type:
- profile_context(name='context')[source]
Context manager for profiling a block of code.
- Parameters:
name (str) – Name for the profiled context
- Yields:
ProfileResult after the context exits
- Return type:
Any