power_limit
zeus.optimizer.power_limit
Optimizers that select the optimum power limit.
This module contains the following pieces:
GlobalPowerLimitOptimizer
is the main class that implements the state machine and the logic for profiling power limits and selecting the optimum power limit.PowerLimitMeasurement
and various state classes are helpers that support the state machine.OptimumSelector
is an abstract base class for selecting the optimum power limit from a list of power limit profiling results. There are concrete classes that implement different selection strategies, like minimizing energy, minimizing time, minimizing the Zeus time-energy cost, or selecting the lowest power limit that meets the given maximum training time slowdown factor.
OptimumSelector
Bases: ABC
Base class for optimum power limit selectors.
Source code in zeus/optimizer/power_limit.py
50 51 52 53 54 55 |
|
select
abstractmethod
select(measurements)
Select the optimal power limit (W) from measurements.
Source code in zeus/optimizer/power_limit.py
53 54 55 |
|
Energy
Bases: OptimumSelector
Selects the power limit that minimizes energy consumption.
Source code in zeus/optimizer/power_limit.py
58 59 60 61 62 63 |
|
select
select(measurements)
Select the optimal power limit (W) from measurements.
Source code in zeus/optimizer/power_limit.py
61 62 63 |
|
Time
Bases: OptimumSelector
Selects the power limit that minimizes training time.
This may not necessarily choose the maximum power limit, as time profiling results can be slightly noisy. However, we believe that's actually better because it means that training time is very similar among higher power limits, but lower power limit will consume less power.
Source code in zeus/optimizer/power_limit.py
66 67 68 69 70 71 72 73 74 75 76 77 |
|
select
select(measurements)
Select the optimal power limit (W) from measurements.
Source code in zeus/optimizer/power_limit.py
75 76 77 |
|
ZeusCost
Bases: OptimumSelector
Selects the power limit that minimizes a linear Zeus time-energy cost function.
Cost function is \(C = \eta \cdot Energy + MaxPower \cdot (1 - \eta) \cdot Time\).
Source code in zeus/optimizer/power_limit.py
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 |
|
__init__
__init__(eta_knob, world_size=1)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eta_knob |
float
|
The \(0 \le \eta \le 1\) knob for the Zeus time-energy cost function. |
required |
world_size |
int
|
The number of GPUs in the training job. Defaults to 1. |
1
|
Source code in zeus/optimizer/power_limit.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
select
select(measurements)
Select the optimal power limit (W) from measurements.
Source code in zeus/optimizer/power_limit.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
MaxSlowdownConstraint
Bases: OptimumSelector
Selects the minumum power limit that does not slow down training by more than the given factor.
Source code in zeus/optimizer/power_limit.py
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 |
|
__init__
__init__(factor)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factor |
float
|
The maximum allowed slowdown factor. Greater than or equal to 1.0. |
required |
Source code in zeus/optimizer/power_limit.py
122 123 124 125 126 127 128 129 130 131 132 133 |
|
select
select(measurements)
Select the optimal power limit (W) from measurements.
Source code in zeus/optimizer/power_limit.py
135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
Ready
Bases: BaseModel
State for when we are ready to start measuring the next power limit.
Initial state of the state machine if no previous profiling results were given.
Ready
-> Warmup
after step
'th on_step_begin
.
Source code in zeus/optimizer/power_limit.py
150 151 152 153 154 155 156 157 158 |
|
Warmup
Bases: BaseModel
State for when we are warming up for a power limit.
Warmup
-> Profiling
on the steps
'th on_step_begin
.
Warmup
-> Ready
on on_epoch_end
before steps
'th on_step_begin
.
Source code in zeus/optimizer/power_limit.py
161 162 163 164 165 166 167 168 169 |
|
Profiling
Bases: BaseModel
State for when we are profiling a power limit.
Profiling
-> Warmup
after steps
'th on_step_begin
and
there are still power limits left to profile.
Profiling
-> Done
after steps
'th on_step_begin
and
there are no more power limits left to profile.
Profiling
-> Ready
on on_epoch_end
before steps
'th on_step_begin
.
Source code in zeus/optimizer/power_limit.py
172 173 174 175 176 177 178 179 180 181 182 183 |
|
Done
Bases: BaseModel
State for when we are done profiling all power limits.
Initial state of the state machine if previous profiling results were given. Final state of the state machine in any case.
Source code in zeus/optimizer/power_limit.py
186 187 188 189 190 191 192 193 |
|
PowerLimitMeasurement
Bases: BaseModel
POD for GPU energy and time measurements for one power limit (W).
Source code in zeus/optimizer/power_limit.py
196 197 198 199 200 201 |
|
_PowerLimitMeasurementList
Bases: BaseModel
Proxy class to save and load a list of PowerLimitMeasurement
s.
Source code in zeus/optimizer/power_limit.py
204 205 206 207 |
|
GlobalPowerLimitOptimizer
Bases: Callback
Optimizer for the power limit knob.
This optimizer uses the JIT profiling log to determine the optimal power limit.
Source code in zeus/optimizer/power_limit.py
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 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 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 |
|
__init__
__init__(monitor, optimum_selector=None, wait_steps=1, warmup_steps=10, profile_steps=40, pl_step=25, profile_path=None)
GPU indices to profile and optimize for are taken from monitor.gpu_indices
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
monitor |
ZeusMonitor
|
|
required |
optimum_selector |
OptimumSelector | None
|
The optimum selector to use. If not given, use |
None
|
wait_steps |
int
|
Number of steps to pass by before doing anything at the beginning.
Useful if you have something like |
1
|
warmup_steps |
int
|
Number of warmup iterations for each power limit. |
10
|
profile_steps |
int
|
Number of profie iterations for each power limit. |
40
|
pl_step |
int
|
The stride between power limits to explore, in unites of Watts. |
25
|
profile_path |
str | Path | None
|
If the path points to an existing file, load the profile from the file
and do not run any profiling. If the path points to a non-existing file, profile
and save the profile to the file. If |
None
|
Source code in zeus/optimizer/power_limit.py
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 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
on_epoch_end
on_epoch_end()
Mark the end of a training epoch.
Source code in zeus/optimizer/power_limit.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
|
on_step_begin
on_step_begin()
Mark the beginning of a training step.
Source code in zeus/optimizer/power_limit.py
362 363 364 365 366 367 368 369 370 371 372 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 |
|
_set_power_limit
_set_power_limit(power_limit)
Set the power limit for all GPUs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
power_limit |
int
|
The power limit to set, in milliWatts. |
required |
Source code in zeus/optimizer/power_limit.py
436 437 438 439 440 441 442 443 444 445 446 447 |
|
_compute_optimal_power_limit
_compute_optimal_power_limit()
Compute the optimal power limit in milliWatts.
Source code in zeus/optimizer/power_limit.py
449 450 451 452 453 |
|
_save_profile
_save_profile()
Save JIT profiling results and the optimal power limit to a JSON file.
Source code in zeus/optimizer/power_limit.py
455 456 457 458 459 460 461 462 463 464 465 466 467 |
|