def save_to_peft_format(ckpt_dir: str, output_dir: str) -> None:
        """Save swift format to peft format

        Args:
            ckpt_dir(`str`): Original swift output dir
            output_dir(`str`): Converted peft format dir
        """
        assert ckpt_dir and output_dir, 'Please pass in valid ckpt_dir and output_dir.'
        assert os.path.exists(ckpt_dir), f'ckpt_dir: {ckpt_dir} must exists in local disk.'
        if os.path.exists(os.path.join(ckpt_dir, SwiftModel.EXTRA_STATE_DIR)):
            raise AssertionError('Cannot transfer to peft format, because you are additional state dicts.')

        adapter_names = [
            sub_dir for sub_dir in os.listdir(ckpt_dir) if os.path.isfile(os.path.join(ckpt_dir, sub_dir, CONFIG_NAME))
        ]

        def has_custom_content(_json):
            if _json.get('swift_type', _json.get('peft_type')) != SwiftTuners.LORA:
                logger.warn('Only LoRA can be converted to peft format')
                return True

            from swift import LoRAConfig
            return not LoRAConfig(**_json).can_be_saved_to_peft()

        for adapter in adapter_names:
            with open(os.path.join(ckpt_dir, adapter, CONFIG_NAME), encoding='utf-8') as f:
                _json = json.load(f)
                if has_custom_content(_json):
                    raise AssertionError('Cannot transfer to peft format, '
                                         'because you have special parameters or adapter types.')

        os.makedirs(output_dir, exist_ok=True)
        if ckpt_dir != output_dir:
            shutil.copytree(ckpt_dir, output_dir, dirs_exist_ok=True)

        for adapter in adapter_names:
            safe_serialization = os.path.isfile(os.path.join(output_dir, adapter, SAFETENSORS_WEIGHTS_NAME))
            state_dict = SwiftModel.load_state_file(os.path.join(output_dir, adapter))
            new_state_dict = {}
            for key, value in state_dict.items():
                if not key.startswith('base_model.model.'):
                    key = 'base_model.model.' + key
                key = key.replace(f'lora_A.{adapter}.', 'lora_A.')
                key = key.replace(f'lora_B.{adapter}.', 'lora_B.')
                key = key.replace(f'lora_embedding_A.{adapter}.', 'lora_embedding_A.')
                key = key.replace(f'lora_embedding_B.{adapter}.', 'lora_embedding_B.')
                key = key.replace(f'lora_magnitude_vector.{adapter}', 'lora_magnitude_vector')
                new_state_dict[key] = value
            state_dict = new_state_dict
            SwiftModel._save_state_dict(state_dict, os.path.join(output_dir, adapter), safe_serialization)
            from swift import LoRAConfig
            with open(os.path.join(output_dir, adapter, CONFIG_NAME), encoding='utf-8') as f:
                _json = json.load(f)
                peft_config = LoRAConfig(**_json).to_peft_config()
            peft_config.save_pretrained(os.path.join(output_dir, adapter))

        if 'default' in adapter_names:
            shutil.move(os.path.join(output_dir, 'default', CONFIG_NAME), os.path.join(output_dir, CONFIG_NAME))
            state_dict = SwiftModel.load_state_file(os.path.join(output_dir, 'default'))
            safe_serialization = os.path.isfile(os.path.join(output_dir, 'default', SAFETENSORS_WEIGHTS_NAME))
            SwiftModel._save_state_dict(state_dict, output_dir, safe_serialization)
            shutil.rmtree(os.path.join(output_dir, 'default'))
Save swift format to peft format

        Args:
            ckpt_dir(`str`): Original swift output dir
            output_dir(`str`): Converted peft format dir
        
swift/tuners/base.py