Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

previous_dtype is now inferred from F.linear's result output type. #1010

Merged
merged 16 commits into from
Feb 19, 2024
4 changes: 3 additions & 1 deletion src/peft/tuners/lora/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,18 @@ def _linear(self, input: torch.Tensor) -> torch.Tensor:
return F.linear(input, transpose(self.weight, self.fan_in_fan_out), bias=self.bias)

def forward(self, x: torch.Tensor) -> torch.Tensor:
previous_dtype = x.dtype

if self.disable_adapters:
if self.merged:
self.unmerge()
result = self._linear(x)
previous_dtype = result.dtype
elif self.merged:
result = self._linear(x)
previous_dtype = result.dtype
else:
result = self._linear(x)
previous_dtype = result.dtype
for active_adapter in self.active_adapters:
if active_adapter not in self.lora_A.keys():
continue
Expand Down