models
zeus.optimizer.batch_size.server.batch_size_state.models
Pydantic models for Batch size/Trials/GaussianTsArmState.
BatchSizeBase
Bases: BaseModel
Base model for representing batch size.
Attributes:
Name | Type | Description |
---|---|---|
job_id |
str
|
The ID of the job. |
batch_size |
int
|
The size of the batch (greater than 0). |
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Config
Model configuration.
Make it immutable after it's created.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
27 28 29 30 31 32 33 |
|
Trial
Bases: BatchSizeBase
Pydantic model that represents Trial.
Attributes:
Name | Type | Description |
---|---|---|
job_id |
str
|
The ID of the job. |
batch_size |
int
|
The size of the batch (greater than 0). |
trial_number |
int
|
Number of trial. |
start_timestamp |
datetime
|
Start time of trial. |
end_timestamp |
datetime
|
End time of trial. |
type |
TrialType
|
Type of this trial, which means in which stage this trial was executed. |
status |
TrialStatus
|
Status of trial |
time |
Optional[float]
|
Total time consumption of this trial. |
energy |
Optional[float]
|
Total energy consumption of this trial. |
converged |
Optional[bool]
|
Whether this trial is converged or not. |
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
Config
Model configuration.
Enable instantiating model from an ORM object, and make it immutable after it's created.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
61 62 63 64 65 66 67 68 |
|
_validate_mab
_validate_mab(values)
Validate trial.
We are checking - start_timestamp <= end_timestamp - if status == dispatched | Failed, time/energy/converged = None else time/energy/converged != None
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
GaussianTsArmState
Bases: BatchSizeBase
Model representing Gaussian Thompson Sampling arm state.
Attributes:
Name | Type | Description |
---|---|---|
param_mean |
float
|
Mean of the belief prior distribution. |
param_precision |
float
|
Precision of the belief prior distribution. |
reward_precision |
float
|
Precision (inverse variance) of the reward distribution. |
num_observations |
int
|
How many observations we made. |
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
Config
Model configuration.
Enable instantiating model from an ORM object, and make it immutable after it's created.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
120 121 122 123 124 125 126 127 |
|
to_orm
to_orm()
Convert pydantic model to ORM object.
Returns:
Name | Type | Description |
---|---|---|
GaussianTsArmState |
GaussianTsArmStateTable
|
The ORM object of Gaussian Arm State. |
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
129 130 131 132 133 134 135 136 137 138 139 |
|
TrialResult
Bases: BatchSizeBase
Model for reading the result of the trial.
Refer to Trial
for attributes.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
Config
Model configuration.
Enable instantiating model from an ORM object, and make it immutable after it's created.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
157 158 159 160 161 162 163 164 |
|
_check_state
_check_state(s)
Check if status is equal to succeeded.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
166 167 168 169 170 171 172 |
|
TrialResultsPerBs
Bases: BatchSizeBase
Model representing all succeeded results of trial for a given batch size.
Attributes:
Name | Type | Description |
---|---|---|
results |
list[TrialResult]
|
List of TrialResult per batch size. |
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
_check_explorations
_check_explorations(values)
Validate if job_id and bs are consistent across all items in results.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
ExplorationsPerJob
Bases: BaseModel
Model representing all succeeded explorations we have done for a job. Immutable after it's created.
Attributes:
Name | Type | Description |
---|---|---|
job_id |
str
|
The ID of the job. |
explorations_per_bs |
dict[int, list[Trial]]
|
Dictionary of "succeeded" explorations per batch size in trial_number ascending order. |
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
Config
Model configuration.
Make it immutable after it's created.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
220 221 222 223 224 225 226 |
|
_check_explorations
_check_explorations(values)
Check bs and job_id corresponds to explorations_per_bs and batch size is consistent.
Source code in zeus/optimizer/batch_size/server/batch_size_state/models.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|