pub struct LoraPair {
pub a: DenseWeight,
pub b: DenseWeight,
pub rank: u32,
pub k_in: u32,
pub n_out: u32,
pub scale: f32,
pub max_rank: u32,
}Expand description
One adapted module. A/B are PEFT tensors VERBATIM (host F16->BF16 at load):
a: [rank, k_in] row-major BF16 (PEFT lora_A [r, in_features] — already
the B-operand [N,K] layout dense_* expect)
b: [n_out, rank] row-major BF16 (PEFT lora_B [out_features, r] — likewise)
Both are rank-padded to the pool’s max_rank (zero rows/cols beyond rank),
so kernels may uniformly run at the pool rank — bit-identical to true rank.
scale = lora_alpha/r, or lora_alpha/sqrt(r) under use_rslora — read per
adapter at load, never defaulted. Do NOT pre-fold into B (keeps tensors
verbatim for the M0 offline parity test); it rides the scaled_add for free.
Fields§
§a: DenseWeight§b: DenseWeight§rank: u32§k_in: u32§n_out: u32§scale: f32§max_rank: u32The pool’s padded rank — the ROW STRIDE of b (and row count of a).
Kernels MUST contract/produce at this dim, not rank: B rows are
max_rank elements apart in the pool, so a k = rank expand would
misread every row past the first when rank < max_rank. Pad rows of
A and pad cols of B are zeroed at pack time, so running the shrink at
n = max_rank and the expand at k = max_rank is bit-identical to
the true-rank product.