optimizer
zeus.policy.optimizer
Implementations for various optimization policies.
JITPowerLimitOptimizer
and
PruningGTSBatchSizeOptimizer
are the implementations used in Zeus's publication.
GTSBatchSizeOptimizer
Bases: BatchSizeOptimizer
One Gaussian Thompson Sampling MAB for each job.
Source code in zeus/policy/optimizer.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 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 |
|
name
property
name: str
Name of the batch size optimizer.
__init__
__init__(
learn_reward_precision,
reward_precision=0.0,
prior_mean=0.0,
prior_precision=0.0,
num_exploration=1,
seed=123456,
verbose=True,
)
Refer to the constructor of GaussianTS
for descriptions of other arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
learn_reward_precision |
bool
|
Whether to learn the reward precision of each arm as we accumulate observations. |
required |
Source code in zeus/policy/optimizer.py
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 |
|
register_job
register_job(job, batch_sizes)
Instantiate a new GaussianTS MAB for the new job.
Source code in zeus/policy/optimizer.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
predict
predict(job)
Return the batch size to use for the job.
Source code in zeus/policy/optimizer.py
100 101 102 103 104 105 106 107 |
|
observe
observe(job, batch_size, cost, converged=None)
Learn from the cost of using the given batch size for the job.
Source code in zeus/policy/optimizer.py
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 |
|
PruningExploreManager
Helper class that generates batch sizes to explore and prune.
Source code in zeus/policy/optimizer.py
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 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 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
__init__
__init__(batch_sizes, default, num_pruning_rounds=2)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_sizes |
list[int]
|
The initial set of batch sizes to prune from. |
required |
default |
int
|
The default batch size (b0) to begin exploration from. |
required |
num_pruning_rounds |
int
|
How many rounds to run pruning. |
2
|
Source code in zeus/policy/optimizer.py
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 |
|
_exploration_engine
_exploration_engine()
Drive pruning exploration.
Yields the batch size to be explored.
The caller should send
a tuple of (explored batch size, cost, whether reached).
As a safety measure, the explored batch size must match the most recently yielded
batch size, and otherwise a RuntimeError
is raised.
Finally, when exploration is over, returns a sorted list of batch sizes that
survived pruning.
Source code in zeus/policy/optimizer.py
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 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 |
|
next_batch_size
next_batch_size()
Return the next batch size to explore.
Raises StopIteration
when pruning exploration phase is over.
The exception instance contains the final set of batch sizes to consider.
Access it through exception.value
.
Source code in zeus/policy/optimizer.py
246 247 248 249 250 251 252 253 254 255 |
|
report_batch_size_result
report_batch_size_result(batch_size, cost, reached)
Report whether the previous batch size reached the target metric.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
int
|
The batch size which this cost observation is from. |
required |
cost |
float
|
The energy-time cost of running the job with this batch size. |
required |
reached |
bool
|
Whether the job reached the target metric. |
required |
Source code in zeus/policy/optimizer.py
257 258 259 260 261 262 263 264 265 266 267 268 |
|
PruningGTSBatchSizeOptimizer
Bases: BatchSizeOptimizer
One Gaussian Thompson Sampling MAB for each job with double pruning exploration.
Source code in zeus/policy/optimizer.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
name
property
name: str
Name of the batch size optimizer.
__init__
__init__(
prior_mean=0.0,
prior_precision=0.0,
window_size=0,
concurrency=False,
seed=123456,
verbose=True,
)
Refer to the constructor of GaussianTS
for descriptions of other arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
window_size |
int
|
Size of the window for the MAB (for drift handling). |
0
|
concurrency |
bool
|
Whether to support concurrent job submissions. |
False
|
Source code in zeus/policy/optimizer.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
|
register_job
register_job(job, batch_sizes)
Register the job.
Source code in zeus/policy/optimizer.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
predict
predict(job)
Return the batch size to use for the job.
Source code in zeus/policy/optimizer.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
|
observe
observe(job, batch_size, cost, converged=None)
Learn from the cost of using the given batch size for the job.
Source code in zeus/policy/optimizer.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
|
_get_history_for_bs
_get_history_for_bs(job, batch_size)
Return the windowed history for the given job's batch size.
Source code in zeus/policy/optimizer.py
513 514 515 516 517 518 519 520 521 522 523 524 |
|
_construct_mab
_construct_mab(job, batch_sizes)
When exploration is over, this method is called to construct and learn GTS.
Source code in zeus/policy/optimizer.py
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
JITPowerLimitOptimizer
Bases: PowerLimitOptimizer
Returns the best power limit to use for the job & batch size.
Source code in zeus/policy/optimizer.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
|
name
property
name: str
Name of the power limit optimizer.
__init__
__init__(verbose=True)
Source code in zeus/policy/optimizer.py
562 563 564 565 566 567 568 569 570 |
|
predict
predict(job, batch_size)
Return the best power limit for the job, or None if unknown.
Source code in zeus/policy/optimizer.py
577 578 579 580 581 582 583 584 585 |
|
observe
observe(job, batch_size, power_limit, cost)
Learn from the cost of using the given knobs for the job.
Source code in zeus/policy/optimizer.py
587 588 589 590 591 592 593 |
|