client
zeus.optimizer.batch_size.client
Zeus batch size optimizer client that communicates with server.
BatchSizeOptimizer
Bases: Callback
Batch size optimizer client that talks to server.
The following methods must be called in order inside the training script:
get_batch_size
: At the beginning of the script.on_train_begin
: Before running any epochs.on_evaluate
: After each epoch when the validation metric is available.
One batch size optimizer per one training session of the job.
The set of GPUs to be used for training should be homogeneous, and will be inferred
from the ZeusMonitor
instance passed into the constructor.
Source code in zeus/optimizer/batch_size/client.py
34 35 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 103 104 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 140 141 142 143 144 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 173 174 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 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
__init__
__init__(monitor, server_url, job, rank=0)
If job is already registered, check if the job configuration is identical with previously registered config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
monitor |
ZeusMonitor
|
|
required |
server_url |
str
|
url of batch size optimizer server |
required |
job |
JobSpec
|
job specification. Refer to |
required |
rank |
int
|
rank of gpu in the case of distributed training. We only let rank = 0 gpu to request for a batch size. |
0
|
Source code in zeus/optimizer/batch_size/client.py
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 |
|
get_batch_size
get_batch_size()
Get batch size to use from the BSO server.
Returns:
Type | Description |
---|---|
int
|
return a batch size to use for current job |
Raises:
Type | Description |
---|---|
`ZeusBSORuntimError`
|
if the batch size we receive is invalid |
Source code in zeus/optimizer/batch_size/client.py
101 102 103 104 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 |
|
on_train_begin
on_train_begin()
Start the monitor window and mark training is started.
Source code in zeus/optimizer/batch_size/client.py
141 142 143 144 |
|
on_evaluate
on_evaluate(metric)
Determine whether or not to stop training after evaluation.
Training stops when
- max_epochs
was reached, or
- the target metric was reached. or
- Cost exceeded the early stop threshold
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric |
float
|
Validation metric of this epoch. See also |
required |
Raises:
Type | Description |
---|---|
`ZeusBSOOperationOrderError`
|
When |
`ZeusBSOTrainFailError`
|
When train failed for a chosen batch size and should be stopped. This batch size will not be tried again. To proceed training, re-launch the training then bso will select another batch size |
`ZeusBSORuntimError`
|
When the server returns an error |
Source code in zeus/optimizer/batch_size/client.py
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 173 174 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 207 208 |
|
_handle_response
_handle_response(res)
Check if the response is success. Otherwise raise an error with error message from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res |
Response
|
response from the server |
required |
Source code in zeus/optimizer/batch_size/client.py
210 211 212 213 214 215 216 217 218 219 |
|