easydel.utils.analyze_memory#

class easydel.utils.analyze_memory.DeviceStats(device_id: str, hostname: str, timestamp: ~datetime.datetime, utilization_percent: float, peak_utilization_percent: float, fragmentation_ratio: float, allocation_efficiency: float, memory_pressure: str, raw_stats: ~typing.Dict[str, ~typing.Any] = <factory>)[source]#

Bases: object

Dataclass to store device statistics.

device_id#

The ID of the device.

Type

str

hostname#

The hostname of the machine.

Type

str

timestamp#

The timestamp of the statistics.

Type

datetime

utilization_percent#

The utilization percentage of the device.

Type

float

peak_utilization_percent#

The peak utilization percentage of the device.

Type

float

fragmentation_ratio#

The fragmentation ratio of the device memory.

Type

float

allocation_efficiency#

The allocation efficiency of the device memory.

Type

float

memory_pressure#

The memory pressure status (e.g., ‘low’, ‘medium’, ‘high’).

Type

str

raw_stats#

A dictionary containing the raw statistics from the device.

Type

Dict[str, Any]

allocation_efficiency: float#
device_id: str#
fragmentation_ratio: float#
classmethod from_dict(data: Dict[str, Any]) T#

Deserializes a dictionary into a PyTree object.

classmethod from_json(json_str: str) T#

Deserializes a JSON string into a PyTree object.

hostname: str#
memory_pressure: str#
peak_utilization_percent: float#
raw_stats: Dict[str, Any]#
replace(**kwargs)#

Creates a new instance with specified fields replaced.

timestamp: datetime#
to_dict() Dict[str, Any]#

Serializes the PyTree object to a dictionary.

to_json(**kwargs) str#

Serializes the PyTree object to a JSON string.

utilization_percent: float#
class easydel.utils.analyze_memory.MemoryMonitorClient(server_host, server_port=5000, interval=60)[source]#

Bases: object

analyze_memory(memory_stats: Dict[str, Any]) DeviceStats[source]#

Analyze memory statistics for a single device

start_monitoring()[source]#

Start monitoring memory usage

stop_monitoring()[source]#

Stop monitoring memory usage

class easydel.utils.analyze_memory.MemoryMonitorServer(host='0.0.0.0', port=5000)[source]#

Bases: object

get_device_stats(device_id=None)[source]#

Get statistics for all devices or a specific device

start()[source]#

Start the monitoring server

class easydel.utils.analyze_memory.SMPMemoryMonitor(check_interval: int = 60)[source]#

Bases: object

analyze_device(device_stats: Dict, dev) Dict[source]#

Analyze memory stats for a single device.

check_all_devices() List[Dict][source]#

Check memory usage on all available devices. Returns list of analysis results.

get_device_history(device_id: Optional[str] = None) List[Dict][source]#

Get memory history for a specific device or all devices.

Parameters

device_id – tp.Optional device ID to filter by

Returns

tp.List of history entries for the specified device(s)

get_summary(format: str = 'auto') Union[List[Dict], DataFrame][source]#

Get a summary of memory usage history.

Parameters

format – Output format - ‘pandas’ (force pandas DataFrame), ‘list’ (force list), or ‘auto’ (use pandas if available)

Returns

Either pandas DataFrame or list of dictionaries depending on format and pandas availability

print_current_status()[source]#

Print current memory status for all devices.

print_history_summary(n_entries: int = 5)[source]#

Print a summary of recent memory usage without using pandas.

Parameters

n_entries – Number of most recent entries to show

start_monitoring()[source]#

Start automatic memory monitoring.

stop_monitoring()[source]#

Stop automatic memory monitoring.

easydel.utils.analyze_memory.start_client(server_host)[source]#
easydel.utils.analyze_memory.start_server()[source]#