| 116 | |
| 117 | |
| 118 | class LARS32bit(Optimizer1State): |
| 119 | def __init__( |
| 120 | self, |
| 121 | params, |
| 122 | lr, |
| 123 | momentum=0, |
| 124 | dampening=0, |
| 125 | weight_decay=0, |
| 126 | nesterov=False, |
| 127 | args=None, |
| 128 | min_8bit_size=4096, |
| 129 | max_unorm=0.02, |
| 130 | ): |
| 131 | """ |
| 132 | 32-bit LARS optimizer. |
| 133 | |
| 134 | Arguments: |
| 135 | params (`torch.tensor`): |
| 136 | The input parameters to optimize. |
| 137 | lr (`float`): |
| 138 | The learning rate. |
| 139 | momentum (`float`, defaults to 0): |
| 140 | The momentum value speeds up the optimizer by taking bigger steps. |
| 141 | dampening (`float`, defaults to 0): |
| 142 | The dampening value reduces the momentum of the optimizer. |
| 143 | weight_decay (`float`, defaults to 1e-2): |
| 144 | The weight decay value for the optimizer. |
| 145 | nesterov (`bool`, defaults to `False`): |
| 146 | Whether to use Nesterov momentum. |
| 147 | args (`object`, defaults to `None`): |
| 148 | An object with additional arguments. |
| 149 | min_8bit_size (`int`, defaults to 4096): |
| 150 | The minimum number of elements of the parameter tensors for 8-bit optimization. |
| 151 | max_unorm (`float`, defaults to 0.02): |
| 152 | The maximum gradient norm. |
| 153 | """ |
| 154 | if momentum == 0: |
| 155 | raise NotImplementedError("LARS without momentum is not supported!") |
| 156 | super().__init__( |
| 157 | "lars", |
| 158 | params, |
| 159 | lr, |
| 160 | (momentum, dampening), |
| 161 | 0.0, |
| 162 | weight_decay, |
| 163 | 32, |
| 164 | args, |
| 165 | min_8bit_size, |
| 166 | max_unorm=max_unorm, |
| 167 | ) |
| 168 | |
| 169 | |
| 170 | class PytorchLARS(Optimizer): |
nothing calls this directly
no outgoing calls
no test coverage detected