| 401 | |
| 402 | |
| 403 | class Optimizer2State(Optimizer8bit): |
| 404 | def __init__( |
| 405 | self, |
| 406 | optimizer_name, |
| 407 | params, |
| 408 | lr=1e-3, |
| 409 | betas=(0.9, 0.999), |
| 410 | eps=1e-8, |
| 411 | weight_decay=0.0, |
| 412 | optim_bits=32, |
| 413 | args=None, |
| 414 | min_8bit_size=4096, |
| 415 | max_unorm=0.0, |
| 416 | skip_zeros=False, |
| 417 | is_paged=False, |
| 418 | alpha=0.0, |
| 419 | t_alpha: Optional[int] = None, |
| 420 | t_beta3: Optional[int] = None, |
| 421 | ): |
| 422 | """ |
| 423 | Base 2-state update optimizer class. |
| 424 | |
| 425 | Arguments: |
| 426 | optimizer_name (`str`): |
| 427 | The name of the optimizer. |
| 428 | params (`torch.Tensor`): |
| 429 | The input parameters to optimize. |
| 430 | lr (`float`, defaults to 1e-3): |
| 431 | The learning rate. |
| 432 | betas (`tuple`, defaults to (0.9, 0.999)): |
| 433 | The beta values for the optimizer. |
| 434 | eps (`float`, defaults to 1e-8): |
| 435 | The epsilon value for the optimizer. |
| 436 | weight_decay (`float`, defaults to 0.0): |
| 437 | The weight decay value for the optimizer. |
| 438 | optim_bits (`int`, defaults to 32): |
| 439 | The number of bits of the optimizer state. |
| 440 | args (`object`, defaults to `None`): |
| 441 | An object with additional arguments. |
| 442 | min_8bit_size (`int`, defaults to 4096): |
| 443 | The minimum number of elements of the parameter tensors for 8-bit optimization. |
| 444 | max_unorm (`float`, defaults to 0.0): |
| 445 | The maximum value to normalize each block with. |
| 446 | skip_zeros (`bool`, defaults to `False`): |
| 447 | Whether to skip zero values for sparse gradients and models to ensure correct updates. |
| 448 | is_paged (`bool`, defaults to `False`): |
| 449 | Whether the optimizer is a paged optimizer or not. |
| 450 | alpha (`float`, defaults to 0.0): |
| 451 | The alpha value for the AdEMAMix optimizer. |
| 452 | t_alpha (`Optional[int]`, defaults to `None`): |
| 453 | Number of iterations for alpha scheduling with AdEMAMix. |
| 454 | t_beta3 (`Optional[int]`, defaults to `None`): |
| 455 | Number of iterations for beta scheduling with AdEMAMix. |
| 456 | |
| 457 | """ |
| 458 | if not 0.0 <= lr: |
| 459 | raise ValueError(f"Invalid learning rate: {lr}") |
| 460 | if not 0.0 <= eps: |
nothing calls this directly
no outgoing calls
no test coverage detected