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

Function forward_LoraColumnParallelLinear

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

Source from the content-addressed store, hash-verified

46 return output
47
48def forward_LoraColumnParallelLinear(self, input_: torch.Tensor) -> torch.Tensor: # type: ignore
49 # Set up backprop all-reduce.
50 input_parallel = copy_to_model_parallel_region(input_)
51 # Matrix multiply.
52 output_parallel = self.quanted_layer(input_parallel)
53 if self.bias is not None:
54 output_parallel = output_parallel + self.bias
55 if self.lora_a is not None:
56 modification = self.lora_b(self.lora_a(input_))
57 else:
58 modification = None
59
60 if self.gather_output:
61 # All-gather across the partitions.
62 output = gather_from_model_parallel_region(output_parallel)
63 else:
64 output = output_parallel
65
66 if modification is not None:
67 output = output + modification
68 return output
69
70def forward_LoraRowParallelLinear(self, input_: torch.Tensor) -> torch.Tensor: # type:ignore
71 # Set up backprop all-reduce.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected