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

Function forward_LoraRowParallelLinear

accessory/util/quant.py:70–87  ·  view source on GitHub ↗
(self, input_: torch.Tensor)

Source from the content-addressed store, hash-verified

68 return output
69
70def forward_LoraRowParallelLinear(self, input_: torch.Tensor) -> torch.Tensor: # type:ignore
71 # Set up backprop all-reduce.
72 if self.input_is_parallel:
73 input_parallel = input_
74 else:
75 input_parallel = scatter_to_model_parallel_region(input_)
76 # Matrix multiply.
77 output_parallel = self.quanted_layer(input_parallel)
78 # All-reduce across all the partitions.
79 output_ = reduce_from_model_parallel_region(output_parallel)
80 if self.lora_a is not None:
81 modification = self.lora_b(self.lora_a(input_parallel))
82 output_ = output_ + modification
83 if self.bias is not None:
84 output = output_ + self.bias
85 else:
86 output = output_
87 return output
88
89def forward_Linear(self, input: torch.Tensor) -> torch.Tensor:
90 output = self.quanted_layer(input)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected