xnn.common.finetune.lora.merge_lora#
- xnn.common.finetune.lora.merge_lora(model)[source]#
Fold every LoRA update into its base layer, in place.
The adapters are replaced by their base modules carrying the merged weights, so the result has the original architecture and
state_dictlayout (and loads where the pretrained model did), at the pretrained model’s inference cost. Every parameter is made trainable again.- Parameters:
model (torch.nn.Module) – A model with LoRA adapters (a model without any is returned unchanged).
- Returns:
model.- Return type: