espnet2.rst.rst_model.merge_lora_adapters
Less than 1 minute
espnet2.rst.rst_model.merge_lora_adapters
espnet2.rst.rst_model.merge_lora_adapters(module: Module) → int
Fold every LoRA adapter in module into its base layer, in place.
The adapter only matters for training; once a trained predictor is loaded for use, its weights never change again, so the predictor loaders call this to compute W + scale * B A once per adapted layer and replace the adapter wrapper with that base layer. The output is unchanged and the adapter’s two extra matmuls per layer are gone. The adapters are added with peft.inject_adapter_in_model, not through a PeftModel, so merge_and_unload is not available; this is its equivalent for that layout. The bias of a bias="lora_only" adapter already is the base layer’s bias.
Returns the number of layers merged.
