计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
save-load-merge【效率与协作】Save, load, inspect, merge, hotswap, mix, and convert PEFT adapters and checkpoints for local or Hub workflows.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task is about PEFT checkpoint files, save_pretrained, from_pretrained, AutoPeftModel*, adapter state dicts, Hub loading, merge_and_unload, PeftMixedModel, hotswapping adapters, weighted adapter merging, conversion helpers, or deployment packaging.
adapter_config.json plus adapter_model.safetensors or adapter_model.bin.PeftModel.from_pretrained, PeftConfig.from_pretrained, AutoPeftModel*, or load_adapter.save_pretrained, including non-default adapter subdirectories and embedding-layer save decisions.PeftMixedModel, or hotswapping LoRA weights in place.merge_and_unload or creating weighted LoRA/(IA)³ adapters with add_weighted_adapter.get_peft_model, PeftConfig, target module selection, and adapter lifecycle basics: use ../adapter-core/SKILL.md.../lora-and-quantization/SKILL.md.../training-and-integrations/SKILL.md.python scripts/inspect_adapter_checkpoint.py <adapter-dir> from this sub-skill directory to check local adapter files without network access.references/checkpoints.md for checkpoint layout, save/load class selection, state dict helpers, Hub/local loading, and embedding save rules.references/merge-and-conversion.md for merge_and_unload, weighted adapter merging, mixed adapters, hotswap, and conversion utilities.references/troubleshooting.md when loaded results look wrong or errors mention base models, vocab/embeddings, unexpected config keys, slow adapter load, active adapters, or unsupported merges.from peft import PeftConfig, PeftModel
from transformers import AutoModelForCausalLM
adapter_id = "org-or-path/my-adapter"
config = PeftConfig.from_pretrained(adapter_id)
base_model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path)
model = PeftModel.from_pretrained(base_model, adapter_id)
Use AutoPeftModelForCausalLM.from_pretrained(adapter_id) when the adapter config contains enough base-model and task information and you want PEFT to infer the model class. Use the explicit PeftConfig + Transformers base model pattern when you need full control over dtype, quantization, device_map, local files, revisions, or base-model class.
adapter_config.json and either adapter_model.safetensors or adapter_model.bin.adapter_config.json should identify peft_type; task_type and base_model_name_or_path strongly improve automatic loading and handoff quality.adapter_model.safetensors is preferred over .bin; both carry the adapter state_dict.save_embedding_layers=True, modules_to_save, or method-specific trainable-token settings.merged_model = model.merge_and_unload() when deployment needs a plain Transformers model and the method/settings support merging.model.add_weighted_adapter(...) to create a new adapter from compatible loaded adapters before selecting it with set_adapter.PeftMixedModel only for inference-time composition of compatible adapter types; mixed adapter models are not a portable saved mixed checkpoint.torch.compile.references/checkpoints.md: concrete file layout, save/load workflows, state dict helpers, Hub/local loading, AutoPeftModel choices, and embedding persistence.references/merge-and-conversion.md: merge/unload, weighted merges, mixed adapters, hotswap constraints, and conversion helpers.references/troubleshooting.md: focused diagnosis for bad outputs, missing bases, random embeddings, version drift, slow loading, adapter activation, and merge failures.scripts/inspect_adapter_checkpoint.py: no-network local adapter directory inspector with class hints and tiny fixture generation.