Bootstrap
hared bootstrap helpers for SEAWRD entrypoints.
- seawrd.bootstrap.config_to_worker_payload(config: SEAWRDConfig | dict[str, Any] | Any) dict[str, Any]
Convert a configuration object to a payload for the benchmark worker.
The configuration object can be a SEAWRDConfig, a dictionary, or any object that provides a to_dict method. The function returns a dictionary representation of the configuration that can be serialized to JSON for the worker process. This allows the benchmark worker to receive the necessary configuration for training the model without requiring the full SEAWRDConfig class or other dependencies.
- Parameters:
config (SEAWRDConfig | dict[str, Any] | Any) – The configuration object to convert.
- Returns:
The benchmark worker payload.
- Return type:
dict[str, Any]
- Raises:
TypeError – If the configuration object does not provide a to_dict method and is not a mapping.
- seawrd.bootstrap.get_cpu_name() str
Get the CPU name based on the current platform.
The most common method (platform.preprocessor()) often does not work properly for Linux, so this function has platform-specific implementations to retrieve the CPU name or description.
- Returns:
The CPU name or description, or an empty string if it cannot be determined.
- Return type:
str
- seawrd.bootstrap.get_gpu_names() list[str]
Get the names of any GPUs based on the current platform. This function uses platform-specific commands to retrieve the names of the GPUs available on the system. It supports Windows, Linux, and macOS
- Returns:
A list of GPU names or an empty list if no GPUs are found or the platform is unsupported.
- Return type:
list[str]
- seawrd.bootstrap.get_min_gpu_speedup(config: SEAWRDConfig | dict[str, Any] | Any) float
Get the minimum GPU speedup from the configuration object. The configuration object can be a SEAWRDConfig, a dictionary, or any object that provides a device.min_gpu_speedup attribute. The function returns the minimum GPU speedup as a float, which is used to determine whether to select the GPU for training based on the benchmark results.
- Parameters:
config (SEAWRDConfig | dict[str, Any] | Any) – The configuration object to extract the minimum GPU speedup from.
- Returns:
The minimum GPU speedup.
- Return type:
float
- Raises:
TypeError – If the configuration object does not provide a device.min_gpu_speedup attribute and is not a mapping.
- seawrd.bootstrap.load_effective_raw_config(config_path: Path, default_config_path: Path) dict[str, Any]
Load the effective configuration by merging the default configuration with the user-provided configuration. Allows for non-default configurations to be used in benchmarking.
- Parameters:
config_path (Path) – Path to the user-provided configuration file.
default_config_path (Path) – Path to the default configuration file.
- Returns:
A dictionary containing the effective configuration values after merging defaults and overrides.
- Return type:
dict[str, Any]
- seawrd.bootstrap.set_device_env(device_mode: str) str
Set CUDA visibility for the selected training device.
- Parameters:
device_mode (str) – The mode in which to run the training (either “cpu” or “gpu”).
- Returns:
The device mode that was set.
- Return type:
str