peft-adapter-design
Design and implement new PEFT adapter types in peft-rs, following established trait patterns
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-12
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- peft-adapter-design
- description
- Design and implement new PEFT adapter types in peft-rs, following established trait patterns
03 SKILL.md 正文
PEFT Adapter Design Skill
When to Use
Invoke when the user asks to:
- Add a new adapter type (IA³, AdaLoRA, etc.)
- Modify existing adapter implementations
- Design adapter composition patterns
- Implement adapter serialization/deserialization
Adapter Architecture
All adapters must implement these traits:
// Required
pub trait Adapter {
type Config: AdapterConfig;
fn forward(&self, input: &Tensor, base_output: Option<&Tensor>) -> Result<Tensor>;
fn num_parameters(&self) -> usize;
fn config(&self) -> &Self::Config;
}
// For adapters that can merge into base weights
pub trait Mergeable: Adapter {
fn merge(&self, base_weight: &Tensor) -> Result<Tensor>;
fn unmerge(&self, merged_weight: &Tensor) -> Result<Tensor>;
}
// For trainable adapters
pub trait Trainable: Adapter {
fn register_parameters(&self, var_map: &mut VarMap, prefix: &str) -> Result<()>;
fn freeze(&mut self);
fn unfreeze(&mut self);
fn is_frozen(&self) -> bool;
}
Adding a New Adapter
Step 1: Create Config
// src/adapters/new_adapter.rs
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NewAdapterConfig {
// Hyperparameters with serde defaults
}
impl AdapterConfig for NewAdapterConfig {
fn validate(&self) -> Result<()> { /* validation logic */ }
}
Step 2: Implement Adapter
pub struct NewAdapterLayer {
// Trainable parameters (Tensor)
// Config
}
impl NewAdapterLayer {
pub fn new(config: NewAdapterConfig, device: &Device) -> Result<Self> { }
}
impl Adapter for NewAdapterLayer { /* ... */ }
Step 3: Add Tests
- Unit tests in same file
- Property-based tests for numerical operations
- Shape preservation tests
Step 4: Export from lib.rs
pub use adapters::new_adapter::{NewAdapterConfig, NewAdapterLayer};
Key Files
src/traits.rs- Core trait definitionssrc/adapters/mod.rs- Adapter module exportssrc/adapters/lora.rs- Reference implementation
04 同仓库更多 Skills
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
web-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
slack-gif-creator
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
internal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).