MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / forward

Method forward

accessory/model/peft.py:141–159  ·  view source on GitHub ↗
(self, input_: torch.Tensor)

Source from the content-addressed store, hash-verified

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
162class LoraRowParallelLinear(RowParallelLinear):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected