(self, input_: torch.Tensor)
| 249 | return gather_from_model_parallel_region(self.weight.data) |
| 250 | |
| 251 | def forward(self, input_: torch.Tensor) -> torch.Tensor: # type:ignore |
| 252 | # Set up backprop all-reduce. |
| 253 | if self.input_is_parallel: |
| 254 | input_parallel = input_ |
| 255 | else: |
| 256 | input_parallel = scatter_to_model_parallel_region(input_) |
| 257 | # Matrix multiply. |
| 258 | output_parallel = F.linear(input_parallel, self.weight) |
| 259 | # All-reduce across all the partitions. |
| 260 | output_ = reduce_from_model_parallel_region(output_parallel) |
| 261 | if self.lora_a is not None: |
| 262 | modification = self.lora_b(self.lora_a(input_parallel)) |
| 263 | output_ = output_ + modification |
| 264 | if self.bias is not None: |
| 265 | output = output_ + self.bias |
| 266 | else: |
| 267 | output = output_ |
| 268 | return output |
nothing calls this directly
no outgoing calls
no test coverage detected