[LoRA] Remove linear hack outside transformers backend (#14177)
Signed-off-by: Isotr0py <2037008807@qq.com>
This commit is contained in:
@@ -67,16 +67,6 @@ def from_layer(layer: nn.Module,
|
||||
packed_modules_list=packed_modules_list,
|
||||
model_config=model_config):
|
||||
instance_layer = lora_cls(layer)
|
||||
if layer.__class__.__name__ == "HFCompatibleLinear":
|
||||
# HACK: Make the forward method compatible with the original
|
||||
# forward method of the instance_layer.
|
||||
original_forward = instance_layer.forward
|
||||
|
||||
def new_forward(input):
|
||||
input = input.squeeze(0)
|
||||
return original_forward(input)[0] # noqa: B023
|
||||
|
||||
instance_layer.forward = new_forward
|
||||
instance_layer.create_lora_weights(max_loras, lora_config,
|
||||
model_config)
|
||||
return instance_layer
|
||||
|
||||
Reference in New Issue
Block a user