LoraWeights

Struct LoraWeights 

Source
pub struct LoraWeights {
Show 17 fields pub name: String, pub adapter_config: PeftAdapterConfig, pub max_rank: usize, pub max_loras: usize, pub pool: DevicePtr, pub pool_bytes: usize, pub expert_pool: Option<DevicePtr>, pub expert_pool_bytes: usize, pub slots: Vec<AdapterSlot>, pub active: usize, pub tables: BTreeMap<(usize, LoraModule), (DevicePtr, DevicePtr)>, pub scale_table: DevicePtr, pub ref_counts: Vec<AtomicUsize>, pub pinned: usize, pub last_used: Vec<AtomicU64>, pub lru_tick: AtomicU64, pub overlay_raw: Vec<Option<OverlayRawSlot>>,
}
Expand description

2026-09-25: The loaded adapter set: one fixed-address pool of max_loras equal-size slots padded to max_rank, one AdapterSlot per pool slot, and per-(layer, module) [max_loras] device pointer tables.

Fields§

§name: String

2026-09-25: Name of the active adapter, for logs and status.

§adapter_config: PeftAdapterConfig

2026-09-25: Config of the adapter made active at load or by the last rotation, for logs. A swap into the active slot updates name but not this.

§max_rank: usize§max_loras: usize§pool: DevicePtr

2026-09-25: One allocation holding every slot’s padded A and B.

§pool_bytes: usize§expert_pool: Option<DevicePtr>

2026-09-25: A separate allocation for the router and routed-expert padded A and B, sized from the audited keys of the startup adapters. None when no adapter targets experts or the router.

§expert_pool_bytes: usize§slots: Vec<AdapterSlot>

2026-09-25: Slot-indexed, len() == max_loras: the startup adapters, then placeholders. Slot k’s pairs live from pool byte offset k * pool_slot_bytes.

§active: usize

2026-09-25: Index into slots of the active adapter; 0 at load.

§tables: BTreeMap<(usize, LoraModule), (DevicePtr, DevicePtr)>

2026-09-25: (global layer, module) to (a_table, b_table). Each table is a device [max_loras] u64 array; 0 means that slot does not adapt the module.

§scale_table: DevicePtr

2026-09-25: Device [max_loras] f32 table: entry k is slot k’s PeftAdapterConfig::scaling() (alpha/r, or alpha/sqrt(r) with rsLoRA), the same scale its LoraPairs carry, and 0.0 for an unpacked slot. Its address is fixed at load; a swap rewrites one entry.

§ref_counts: Vec<AtomicUsize>

2026-09-25: In-flight sequence count per pool index, len() == max_loras. A sequence takes a count through Self::acquire_slot and returns it when it is freed. A swap into a slot whose count is above 0, or a rotation away from one, is refused. It is a parallel Vec because AdapterSlot derives Clone and AtomicUsize is not Clone.

§pinned: usize

2026-09-25: Slots [0, pinned) hold the startup adapters and are never eviction candidates. Slots [pinned, max_loras) are the promotion cache, placeholders at load.

§last_used: Vec<AtomicU64>

2026-09-25: Last-used tick per pool index, len() == max_loras, set by Self::acquire_slot on the resolved index and by Self::touch_slot.

§lru_tick: AtomicU64

2026-09-25: Source of the last_used ticks; incremented by each acquire and touch.

§overlay_raw: Vec<Option<OverlayRawSlot>>

2026-09-25: Raw token-overlay uploads, one per startup adapter (None when it ships no overlay tensors). The model’s set_lora_weights takes them and builds the overlay tables, which need the served embed and lm_head tables.

Implementations§

Source§

impl LoraWeights

Source

pub fn acquire_slot(&self, slot: i32) -> i32

2026-09-25: Resolve slot (>= 0 that slot, -1 the active one), increment its ref count and stamp it most recently used. Returns the resolved index, which the caller passes to Self::release_slot even if active changes meanwhile, or -1 when the index is out of range.

Source

pub fn touch_slot(&self, slot: usize)

2026-09-25: Stamp slot most recently used without taking a ref. A promote calls it on the slot it just filled, so a second promote before the first request acquires does not pick that idle slot while an older idle slot exists.

Source

pub fn slot_last_used(&self, slot: usize) -> u64

2026-09-25: Last-used tick of pool slot; larger is more recent, and an out-of-range slot reads 0.

Source

pub fn refresh_slot_tables( &self, slot: usize, layers: &[Option<LoraLayerWeights>], scale: f32, gpu: &dyn GpuBackend, ) -> Result<()>

2026-09-25: Rewrite slot’s entry in every [max_loras] a/b pointer table from layers, 0 where the new adapter does not adapt the module, and its scale-table entry from scale. Without it a swapped-in adapter with different module coverage would keep the old adapter’s entries. Both swaps call it: the disk swap (pack_store_into_slot) and the model’s peer swap. Only the [slot] entries are written.

Source

pub fn cache_slot_views(&self) -> Vec<(usize, SlotView)>

2026-09-25: (slot_index, SlotView) for each cache slot [pinned, max_loras), the input of select_victim_slot.

Source

pub fn release_slot(&self, resolved: i32)

2026-09-25: Release a ref taken by Self::acquire_slot, given the index it returned. -1 is a no-op, and the count saturates at 0.

Source

pub fn slot_ref_count(&self, slot: usize) -> usize

2026-09-25: In-flight ref count of pool slot, which the swaps and rotation check before replacing or leaving a slot; an out-of-range slot reads 0.

Source§

impl LoraWeights

Source

pub fn active_layers(&self) -> &[Option<LoraLayerWeights>]

2026-09-25: The active slot’s pairs, indexed by global layer.

Source

pub fn routed_prefill_slot(&self, adapter_slot: i32) -> Option<usize>

2026-09-25: Resolve a request’s adapter_slot (>= 0 that slot, -1 the active one) and return it only when it is an in-range slot other than the active one; None otherwise. See routed_prefill_slot_of.

Source

pub fn slot_of(&self, name: &str) -> Option<usize>

2026-09-25: The slot holding adapter name; placeholders never match.

Source

pub fn adapter_names(&self) -> Vec<String>

2026-09-25: The names of all resident adapters, in slot order.

Source

pub fn adapter_id_for_slot(&self, slot: i32) -> u64

2026-09-25: Cache identity for a request’s adapter_slot (>= 0 that slot, -1 the active one): adapter_id_hash of the resolved slot’s name and generation, or the base sentinel 0 when the slot is out of range or a placeholder.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,