(self, max_norm, device=None)
| 272 | if self.module_type == "linear": |
| 273 | mid = F.linear(x, self.lora_down.weight.to(x)) |
| 274 | elif self.tucker: |
| 275 | mid = self.lora_mid(self.lora_down(x)) |
| 276 | else: |
| 277 | mid = self.lora_down(x) |
| 278 | drop = ( |
| 279 | torch.rand(self.lora_dim, device=mid.device) > self.rank_dropout |
| 280 | ).to(mid.dtype) |
| 281 | if self.rank_dropout_scale: |
| 282 | drop /= drop.mean() |
| 283 | if (dims := len(x.shape)) == 4: |
| 284 | drop = drop.view(1, -1, 1, 1) |
| 285 | else: |
| 286 | drop = drop.view(*[1] * (dims - 1), -1) |
| 287 | mid = mid * drop |
nothing calls this directly
no test coverage detected