| 105 | |
| 106 | |
| 107 | class SGD32bit(Optimizer1State): |
| 108 | def __init__( |
| 109 | self, |
| 110 | params, |
| 111 | lr, |
| 112 | momentum=0, |
| 113 | dampening=0, |
| 114 | weight_decay=0, |
| 115 | nesterov=False, |
| 116 | args=None, |
| 117 | min_8bit_size=4096, |
| 118 | ): |
| 119 | """ |
| 120 | 32-bit SGD optimizer. |
| 121 | |
| 122 | Arguments: |
| 123 | params (`torch.tensor`): |
| 124 | The input parameters to optimize. |
| 125 | lr (`float`): |
| 126 | The learning rate. |
| 127 | momentum (`float`, defaults to 0): |
| 128 | The momentum value speeds up the optimizer by taking bigger steps. |
| 129 | dampening (`float`, defaults to 0): |
| 130 | The dampening value reduces the momentum of the optimizer. |
| 131 | weight_decay (`float`, defaults to 0.0): |
| 132 | The weight decay value for the optimizer. |
| 133 | nesterov (`bool`, defaults to `False`): |
| 134 | Whether to use Nesterov momentum. |
| 135 | args (`object`, defaults to `None`): |
| 136 | An object with additional arguments. |
| 137 | min_8bit_size (`int`, defaults to 4096): |
| 138 | The minimum number of elements of the parameter tensors for 8-bit optimization. |
| 139 | """ |
| 140 | if momentum == 0: |
| 141 | raise NotImplementedError("SGD without momentum is not supported!") |
| 142 | super().__init__( |
| 143 | "momentum", |
| 144 | params, |
| 145 | lr, |
| 146 | (momentum, dampening), |
| 147 | 0.0, |
| 148 | weight_decay, |
| 149 | 32, |
| 150 | args, |
| 151 | min_8bit_size, |
| 152 | ) |
nothing calls this directly
no outgoing calls
no test coverage detected