ptyrad.utils.common

ptyrad.utils.common#

General purpose utility tools for logging, converting types, parsing dicts and strings, etc.

Classes

CustomLogger([log_file, log_dir, ...])

Functions

expand_presets(input_list, presets)

get_nested(d, key[, delimiter, safe, default])

Get a value from a nested dictionary either safely (return default if not found) or stricly to fail early.

get_time([time_format])

Returns a formatted timestamp string based on time_format.

handle_hdf5_types(x)

Convert data to native Python or NumPy types.

is_mig_enabled()

Detects if any GPU on the system is operating in MIG (Multi-Instance GPU) mode.

list_nested_keys(hobj[, delimiter, prefix])

Recursively list all keys in an HDF5 file, HDF5 group, or dict, including hierarchical paths.

ndarrays_to_tensors(data[, device])

Recursively convert all numpy.ndarray instances in any nested structure (including lists, dicts, and tuples) into torch.Tensor on the specified device.

normalize_constraint_params(constraint_params)

Convert old constraint param format {freq} (pre v0.1.0b11) to {start_iter, step, end_iter}.

parse_hypertune_params_to_str(hypertune_params)

parse_sec_to_time_str(seconds)

print_gpu_info()

print_packages_info()

print_system_info()

resolve_seed_priority(args_seed, ...)

safe_filename(filepath[, verbose])

Ensures a filepath is safe across platforms by: 1.

set_accelerator()

set_gpu_device([gpuid])

Sets the GPU device based on the input.

set_random_seed(seed[, deterministic])

Set the random seeds for numpy and pytorch operations.

tensors_to_ndarrays(data)

Recursively convert all torch.Tensor instances in any nested structure (including lists, dicts, and tuples) into numpy.ndarray.

time_sync()

vprint(*args[, verbose])

Verbose print/logging with individual control, only for rank 0 in DDP.

vprint_nested_dict(d[, indent, verbose, ...])