def get_peft_model(
        model: "PreTrainedModel", config: type[BasePassConfig], config_kwargs: dict = None
    ) -> "PeftModel":
        """Get the PEFT model for LoKr fine-tuning."""
        from peft import LoKrConfig, get_peft_model

        target_modules = config.target_modules or "all-linear"
        config = LoKrConfig(
            r=config.r,
            alpha=config.alpha,
            rank_dropout=config.rank_dropout,
            module_dropout=config.module_dropout,
            decompose_both=config.decompose_both,
            decompose_factor=config.decompose_factor,
            rank_dropout_scale=config.rank_dropout_scale,
            use_effective_conv2d=config.use_effective_conv2d,
            target_modules=target_modules,
            exclude_modules=config.exclude_modules,
            init_weights=config.init_weights,
            layers_to_transform=config.layers_to_transform,
            layers_pattern=config.layers_pattern,
            rank_pattern=config.rank_pattern,
            alpha_pattern=config.alpha_pattern,
            modules_to_save=config.modules_to_save,
        )

        return get_peft_model(model, config)
Get the PEFT model for LoKr fine-tuning.
olive/passes/pytorch/lora.py