adapter-core
Core PEFT adapter setup, configuration, target module selection, adapter lifecycle, model/layer status diagnostics, custom models, and low-level adapter injection.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- adapter-core
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Core PEFT adapter setup, configuration, target module selection, adapter lifecycle, model/layer status diagnostics, custom models, and low-level adapter injection.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md7.9 KB
- 参考文档references/troubleshooting.md8.0 KB
- 参考文档references/workflows.md7.2 KB
- 脚本scripts/check_peft_env.py5.8 KB
03 SKILL.md 正文
Adapter Core
Use this sub-skill when the task is about constructing PEFT configs, wrapping a model with adapters, managing adapters after creation, diagnosing adapter state, targeting modules in custom models, or using low-level adapter injection.
Route Here For
- Install/import smoke checks for
peft,torch,transformers, andacceleratewithout downloading models. - Core API choices:
PeftConfig,TaskType,PeftType,get_peft_model,PeftModel, and adapter names. - Adapter lifecycle: add, load, activate, disable, delete, inspect trainable parameters, and inspect model/layer status.
- Target module selection for custom or non-Transformers
torch.nn.Modulemodels. - Low-level injection with
inject_adapter_in_modelwhen aPeftModelwrapper is not desired. - Diagnosing invalid task/PEFT types, missing target modules, unsupported module classes, or unexpected trainable status.
Route Elsewhere
- LoRA variants, quantized loading, DoRA, rsLoRA, QLoRA-style workflows, and LoRA-specific initialization: use
../lora-and-quantization/SKILL.md. - Prompt tuning, prefix tuning, p-tuning, soft prompts, or prompt encoder internals: use
../prompt-and-soft-methods/SKILL.md. - Saving, loading checkpoints, merging adapters into base weights, or deployment packaging: use
../save-load-merge/SKILL.md. - Trainer, Accelerate, distributed, FSDP, DeepSpeed, or multi-GPU training integration: use
../training-and-integrations/SKILL.md.
Start Fast
- Run
python scripts/check_peft_env.pyfrom this sub-skill directory to verify imports and local package facts. - Read
references/api-reference.mdfor the core class/function surface and common enum values. - Follow
references/workflows.mdfor adapter construction, custom model targeting, lifecycle management, and low-level injection. - Use
references/troubleshooting.mdwhen errors mention invalid task types, missingtarget_modules, unsupported modules, adapter status irregularities, or optional dependency imports.
Core Decision Pattern
- Prefer
get_peft_model(base_model, peft_config, adapter_name="default")for normal Transformers and custom PyTorch models when PEFT should return aPeftModelwrapper with helper methods. - Use explicit
target_modulesfor custom models unless the method and architecture have a known PEFT default mapping. - Use
modules_to_savefor non-adapter layers that must remain trainable and be stored with the adapter, such as custom heads or task heads. - Use
print_trainable_parameters(),get_model_status(), andget_layer_status()before training when trainable counts, active adapters, or merged/disabled states look surprising. - Use low-level
inject_adapter_in_model(peft_config, model, adapter_name=...)only when the caller needs adapter layers in a plaintorch.nn.Moduleand does not needPeftModelhelper methods.
Bundled Materials
references/api-reference.md: API inventory, enum usage, config validation, lifecycle helpers, and status helpers.references/workflows.md: practical recipes for standard wrapping, custom modules, target discovery, adapter lifecycle, and low-level injection.references/troubleshooting.md: diagnosis paths for target module, enum, trainability, optional dependency, custom module, and low-level injection failures.scripts/check_peft_env.py: safe local import/config smoke check with--help, JSON output option, and optional CUDA facts.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).