yaml_model_schema ¶
Module for handling YAML configuration files and converting them to Ray Tune format.
Classes:
-
CustomTunableParameter
–Custom tunable parameter.
-
Data
–Data parameters.
-
Loss
–Loss parameters.
-
Model
–Model configuration.
-
RayTuneModel
–Ray Tune compatible model configuration.
-
RunParams
–Run parameters.
-
Scheduler
–Scheduler parameters.
-
TunableParameter
–Tunable parameter.
-
Tune
–Tune parameters.
-
TuneParams
–Tune parameters.
-
YamlRayConfigLoader
–Load and convert YAML configurations to Ray Tune format.
CustomTunableParameter ¶
Bases: BaseModel
Custom tunable parameter.
Data ¶
Bases: BaseModel
Data parameters.
Loss ¶
Bases: BaseModel
Loss parameters.
Model ¶
Bases: BaseModel
Model configuration.
RayTuneModel ¶
Bases: BaseModel
Ray Tune compatible model configuration.
RunParams ¶
Bases: BaseModel
Run parameters.
Scheduler ¶
Bases: BaseModel
Scheduler parameters.
TunableParameter ¶
Bases: BaseModel
Tunable parameter.
Methods:
-
validate_mode
–Validate that mode is supported by Ray Tune.
validate_mode ¶
validate_mode() -> TunableParameter
Validate that mode is supported by Ray Tune.
Source code in src/stimulus/utils/yaml_model_schema.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
Tune ¶
Bases: BaseModel
Tune parameters.
TuneParams ¶
Bases: BaseModel
Tune parameters.
YamlRayConfigLoader ¶
YamlRayConfigLoader(model: Model)
Load and convert YAML configurations to Ray Tune format.
This class handles loading model configurations and converting them into formats compatible with Ray Tune's hyperparameter search spaces.
Parameters:
-
model
(Model
) –Pydantic Model instance containing configuration
Methods:
-
convert_config_to_ray
–Convert Model configuration to Ray Tune format.
-
convert_raytune
–Convert parameter configuration to Ray Tune format.
-
get_config
–Return the current configuration.
-
raytune_sample_from
–Apply tune.sample_from to a given custom sampling function.
-
raytune_space_selector
–Convert space parameters to Ray Tune format based on the mode.
-
sampint
–Return a list of n random samples from the sample_space.
Source code in src/stimulus/utils/yaml_model_schema.py
127 128 129 130 131 132 133 134 |
|
convert_config_to_ray ¶
convert_config_to_ray(model: Model) -> RayTuneModel
Convert Model configuration to Ray Tune format.
Converts parameters in network_params and optimizer_params to Ray Tune search spaces.
Parameters:
-
model
(Model
) –Model configuration
Returns:
-
RayTuneModel
–Ray Tune compatible model configuration
Source code in src/stimulus/utils/yaml_model_schema.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
convert_raytune ¶
convert_raytune(
param: TunableParameter | CustomTunableParameter,
) -> Any
Convert parameter configuration to Ray Tune format.
Parameters:
-
param
(TunableParameter | CustomTunableParameter
) –Parameter configuration
Returns:
-
Any
–Ray Tune compatible parameter configuration
Source code in src/stimulus/utils/yaml_model_schema.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
get_config ¶
get_config() -> RayTuneModel
Return the current configuration.
Returns:
-
RayTuneModel
–Current configuration dictionary
Source code in src/stimulus/utils/yaml_model_schema.py
203 204 205 206 207 208 209 |
|
raytune_sample_from ¶
raytune_sample_from(
mode: Callable, param: CustomTunableParameter
) -> Any
Apply tune.sample_from to a given custom sampling function.
Parameters:
-
mode
(Callable
) –Ray Tune sampling function
-
param
(CustomTunableParameter
) –TunableParameter containing sampling parameters
Returns:
-
Any
–Configured sampling function
Raises:
-
NotImplementedError
–If the sampling function is not supported
Source code in src/stimulus/utils/yaml_model_schema.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
raytune_space_selector ¶
Convert space parameters to Ray Tune format based on the mode.
Parameters:
-
mode
(Callable
) –Ray Tune search space function (e.g., tune.choice, tune.uniform)
-
space
(list
) –List of parameters defining the search space
Returns:
-
Any
–Configured Ray Tune search space
Source code in src/stimulus/utils/yaml_model_schema.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
sampint staticmethod
¶
Return a list of n random samples from the sample_space.
This function is useful for sampling different numbers of layers, each with different numbers of neurons.
Parameters:
-
sample_space
(list
) –List [min, max] defining range of values to sample from
-
n_space
(list
) –List [min, max] defining range for number of samples
Returns:
Note
Uses Python's random module which is not cryptographically secure. This is acceptable for hyperparameter sampling but should not be used for security-critical purposes (S311 fails when linting).
Source code in src/stimulus/utils/yaml_model_schema.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|