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: String2026-09-25: Name of the active adapter, for logs and status.
adapter_config: PeftAdapterConfig2026-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: DevicePtr2026-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: usize2026-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: DevicePtr2026-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: usize2026-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: AtomicU642026-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
impl LoraWeights
Sourcepub fn acquire_slot(&self, slot: i32) -> i32
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.
Sourcepub fn touch_slot(&self, slot: usize)
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.
Sourcepub fn slot_last_used(&self, slot: usize) -> u64
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.
Sourcepub fn refresh_slot_tables(
&self,
slot: usize,
layers: &[Option<LoraLayerWeights>],
scale: f32,
gpu: &dyn GpuBackend,
) -> Result<()>
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.
Sourcepub fn cache_slot_views(&self) -> Vec<(usize, SlotView)>
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.
Sourcepub fn release_slot(&self, resolved: i32)
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.
Sourcepub fn slot_ref_count(&self, slot: usize) -> usize
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
impl LoraWeights
Sourcepub fn active_layers(&self) -> &[Option<LoraLayerWeights>]
pub fn active_layers(&self) -> &[Option<LoraLayerWeights>]
2026-09-25: The active slot’s pairs, indexed by global layer.
Sourcepub fn routed_prefill_slot(&self, adapter_slot: i32) -> Option<usize>
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.
Sourcepub fn slot_of(&self, name: &str) -> Option<usize>
pub fn slot_of(&self, name: &str) -> Option<usize>
2026-09-25: The slot holding adapter name; placeholders never match.
Sourcepub fn adapter_names(&self) -> Vec<String>
pub fn adapter_names(&self) -> Vec<String>
2026-09-25: The names of all resident adapters, in slot order.
Sourcepub fn adapter_id_for_slot(&self, slot: i32) -> u64
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.