PeftAdapterConfig

Struct PeftAdapterConfig 

Source
pub struct PeftAdapterConfig {
    pub r: usize,
    pub lora_alpha: f64,
    pub target_modules: Vec<String>,
    pub target_modules_pattern: Option<String>,
    pub use_rslora: bool,
    pub layers_to_transform: Option<Vec<usize>>,
    pub trainable_token_indices: Vec<u32>,
    pub modules_to_save: Vec<String>,
    pub lora_embedding: bool,
}
Expand description

Parsed subset of a PEFT adapter_config.json that Atlas consumes.

lora_dropout is intentionally ignored (train-time only, inference no-op). Everything else PEFT can emit that would change inference output is validated in parse_peft_adapter_config and rejected by name if unsupported.

Fields§

§r: usize

LoRA rank. Must be > 0.

§lora_alpha: f64

LoRA alpha. PEFT serializes int or float; both accepted.

§target_modules: Vec<String>

Verbatim target_modules entries (bare module names, or full paths which are validated on their final .-segment). The weight loader’s bidirectional audit is the authority on actual per-layer matching.

§target_modules_pattern: Option<String>

PEFT’s REGEX form of target_modules (a JSON string rather than a list) — e.g. Dxniz/Novelist1.0-27b-Adapter, whose pattern matches q|k|v|o_proj and gate|up|down_proj under several possible parent-module spellings.

Held verbatim and NOT expanded: expanding it would mean resolving a Python-flavoured regex against a module tree this layer cannot see. It does not need to be. The adapter’s own TENSOR NAMES are ground truth for what it targets, and every one of them still goes through classify_key, which is strictly stricter than the name-level allow-list a pattern bypasses. A pattern therefore DEFERS module validation to the per-tensor gate rather than skipping it.

§use_rslora: bool

rsLoRA flag: switches scaling from alpha/r to alpha/sqrt(r). Hard-required in the on-disk config (never defaulted — a wrong scale is silent quality loss).

§layers_to_transform: Option<Vec<usize>>

Informational: the layers_to_transform restriction if present. The weight loader’s per-LayerType gate is the real authority on which layers receive deltas; this is kept only for the startup log.

§trainable_token_indices: Vec<u32>

Vocab-extension / trainable-token ids for the token overlay (Feature 2). Unique ascending order from the config’s trainable_token_indices list, or the common order declared for embed_tokens and lm_head. Empty ⇒ no trainable_tokens overlay.

§modules_to_save: Vec<String>

Accepted modules_to_save leaves — the subset Atlas can apply as a token overlay (embed_tokens / lm_head full-row replacement). Anything else is still a hard REJECT(modules_to_save). Empty ⇒ no full-module overlay.

§lora_embedding: bool

Classic low-rank embedding LoRA (lora_embedding_A/B) present. Tier-2: parse-accepted here so the adapter is not silently dropped, but the loader rejects it until the embedding-LoRA kernel lands. Reserved — always false today (detection is at the tensor level).

Implementations§

Source§

impl PeftAdapterConfig

Source

pub fn scaling(&self) -> f32

Delta scale applied at merge: y += scaling() * (x @ Aᵀ) @ Bᵀ.

alpha/r, or alpha/sqrt(r) when use_rslora — read from the adapter’s own config, NEVER defaulted (a wrong scale is silent quality loss, not an error).

Trait Implementations§

Source§

impl Clone for PeftAdapterConfig

Source§

fn clone(&self) -> PeftAdapterConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeftAdapterConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.