(self, input_: torch.Tensor)
| 139 | return gather_from_model_parallel_region(self.weight.data.transpose(0, 1)).transpose_(0, 1) |
| 140 | |
| 141 | def forward(self, input_: torch.Tensor) -> torch.Tensor: # type: ignore |
| 142 | # Set up backprop all-reduce. |
| 143 | input_parallel = copy_to_model_parallel_region(input_) |
| 144 | # Matrix multiply. |
| 145 | output_parallel = F.linear(input_parallel, self.weight, self.bias) |
| 146 | if self.lora_a is not None: |
| 147 | modification = self.lora_b(self.lora_a(input_)) |
| 148 | else: |
| 149 | modification = None |
| 150 | |
| 151 | if self.gather_output: |
| 152 | # All-gather across the partitions. |
| 153 | output = gather_from_model_parallel_region(output_parallel) |
| 154 | else: |
| 155 | output = output_parallel |
| 156 | |
| 157 | if modification is not None: |
| 158 | output = output + modification |
| 159 | return output |
| 160 | |
| 161 | |
| 162 | class LoraRowParallelLinear(RowParallelLinear): |
nothing calls this directly
no outgoing calls
no test coverage detected