stormlog.tensorflow.profiler

Core TensorFlow Stormlog

Main profiling engine for capturing and analyzing GPU memory usage during TensorFlow model training and inference.

Classes

MemorySnapshot(timestamp, name, ...[, ...])

Represents a point-in-time memory snapshot.

ProfileResult(start_time, end_time, ...[, ...])

Comprehensive profiling results.

TFMemoryProfiler([device, ...])

Main TensorFlow Stormlog class.

TensorTracker()

Tracks TensorFlow tensor lifecycle and memory usage.

class stormlog.tensorflow.profiler.MemorySnapshot(timestamp, name, gpu_memory_mb, cpu_memory_mb, gpu_memory_reserved_mb, gpu_utilization, num_tensors, tensor_sizes=<factory>, operation_name=None, graph_node=None)[source]

Bases: object

Represents a point-in-time memory snapshot.

Parameters:
  • timestamp (float)

  • name (str)

  • gpu_memory_mb (float)

  • cpu_memory_mb (float)

  • gpu_memory_reserved_mb (float)

  • gpu_utilization (float)

  • num_tensors (int)

  • tensor_sizes (Dict[str, int])

  • operation_name (str | None)

  • graph_node (str | None)

timestamp: float
name: str
gpu_memory_mb: float
cpu_memory_mb: float
gpu_memory_reserved_mb: float
gpu_utilization: float
num_tensors: int
tensor_sizes: Dict[str, int]
operation_name: str | None = None
graph_node: str | None = None
class stormlog.tensorflow.profiler.ProfileResult(start_time, end_time, peak_memory_mb, average_memory_mb, min_memory_mb, total_allocations, total_deallocations, snapshots=<factory>, function_profiles=<factory>, tensor_lifecycle=<factory>, memory_fragmentation=0.0, efficiency_score=0.0)[source]

Bases: object

Comprehensive profiling results.

Parameters:
  • start_time (float)

  • end_time (float)

  • peak_memory_mb (float)

  • average_memory_mb (float)

  • min_memory_mb (float)

  • total_allocations (int)

  • total_deallocations (int)

  • snapshots (List[MemorySnapshot])

  • function_profiles (Dict[str, Dict[str, Any]])

  • tensor_lifecycle (Dict[str, Any])

  • memory_fragmentation (float)

  • efficiency_score (float)

start_time: float
end_time: float
peak_memory_mb: float
average_memory_mb: float
min_memory_mb: float
total_allocations: int
total_deallocations: int
snapshots: List[MemorySnapshot]
function_profiles: Dict[str, Dict[str, Any]]
tensor_lifecycle: Dict[str, Any]
memory_fragmentation: float = 0.0
efficiency_score: float = 0.0
property duration: float

Total profiling duration in seconds.

property memory_growth_rate: float

Memory growth rate in MB/second.

class stormlog.tensorflow.profiler.TensorTracker[source]

Bases: object

Tracks TensorFlow tensor lifecycle and memory usage.

track_tensor(tensor, operation_name='unknown')[source]

Track a new tensor.

Parameters:
  • tensor (tensorflow.Tensor)

  • operation_name (str)

Return type:

None

get_active_tensors()[source]

Get information about currently active tensors.

Return type:

Dict[str, Any]

get_tensor_lifecycle()[source]

Get complete tensor lifecycle history.

Return type:

List[Dict[str, Any]]

class stormlog.tensorflow.profiler.TFMemoryProfiler(device=None, enable_tensor_tracking=True)[source]

Bases: object

Main TensorFlow Stormlog class.

Parameters:
  • device (str | None)

  • enable_tensor_tracking (bool)

capture_snapshot(name='snapshot')[source]

Capture current memory state.

Parameters:

name (str)

Return type:

MemorySnapshot

profile_function(func)[source]

Decorator to profile function memory usage.

Parameters:

func (Callable[[~P], R])

Return type:

Callable[[~P], R]

profile_context(name='context')[source]

Context manager for profiling code blocks.

Parameters:

name (str)

Return type:

Iterator[None]

start_continuous_profiling(interval=1.0)[source]

Start continuous memory profiling.

Parameters:

interval (float)

Return type:

None

stop_continuous_profiling()[source]

Stop continuous memory profiling.

Return type:

None

get_results()[source]

Get comprehensive profiling results.

Return type:

ProfileResult

reset()[source]

Reset profiler state.

Return type:

None