| 57 | |
| 58 | |
| 59 | class SGD8bit(Optimizer1State): |
| 60 | def __init__( |
| 61 | self, |
| 62 | params, |
| 63 | lr, |
| 64 | momentum=0, |
| 65 | dampening=0, |
| 66 | weight_decay=0, |
| 67 | nesterov=False, |
| 68 | args=None, |
| 69 | min_8bit_size=4096, |
| 70 | ): |
| 71 | """ |
| 72 | 8-bit SGD optimizer. |
| 73 | |
| 74 | Arguments: |
| 75 | params (`torch.tensor`): |
| 76 | The input parameters to optimize. |
| 77 | lr (`float`): |
| 78 | The learning rate. |
| 79 | momentum (`float`, defaults to 0): |
| 80 | The momentum value speeds up the optimizer by taking bigger steps. |
| 81 | dampening (`float`, defaults to 0): |
| 82 | The dampening value reduces the momentum of the optimizer. |
| 83 | weight_decay (`float`, defaults to 0.0): |
| 84 | The weight decay value for the optimizer. |
| 85 | nesterov (`bool`, defaults to `False`): |
| 86 | Whether to use Nesterov momentum. |
| 87 | args (`object`, defaults to `None`): |
| 88 | An object with additional arguments. |
| 89 | min_8bit_size (`int`, defaults to 4096): |
| 90 | The minimum number of elements of the parameter tensors for 8-bit optimization. |
| 91 | """ |
| 92 | if momentum == 0: |
| 93 | raise NotImplementedError("SGD without momentum is not supported!") |
| 94 | super().__init__( |
| 95 | "momentum", |
| 96 | params, |
| 97 | lr, |
| 98 | (momentum, dampening), |
| 99 | 0.0, |
| 100 | weight_decay, |
| 101 | 8, |
| 102 | args, |
| 103 | min_8bit_size, |
| 104 | ) |
| 105 | |
| 106 | |
| 107 | class SGD32bit(Optimizer1State): |
nothing calls this directly
no outgoing calls
no test coverage detected