pub struct LoraAdapter {
pub a: Param<Tensor<2>>,
pub b: Param<Tensor<2>>,
pub scale: f64,
}Expand description
A LoRA (Low-Rank Adaptation) adapter attached to a frozen weight parameter.
When present on a Param<Tensor<2>>, the parameter materializes its effective value as
base + scale * (a @ b), where base is the frozen (and optionally quantized) weight and
a/b are the trainable low-rank factors. The frozen base is the stored value of the
parameter; the adapter factors are surfaced to the optimizer, autodiff and record systems as
regular parameters with their own ParamIds through the module
visitor/mapper traversal.
Fields§
§a: Param<Tensor<2>>Down-projection factor with shape [d_in, rank] (trainable).
b: Param<Tensor<2>>Up-projection factor with shape [rank, d_out] (trainable).
scale: f64Scaling factor applied to the low-rank product, typically alpha / rank.
Implementations§
Source§impl LoraAdapter
impl LoraAdapter
Sourcepub fn delta(&self) -> Tensor<2>
pub fn delta(&self) -> Tensor<2>
Compute the low-rank delta scale * (a @ b) with shape [d_in, d_out].
a and b are read through Param::val, so the delta always reflects the current
(optimizer-updated) factors and keeps them as autodiff leaves for backpropagation.
Trait Implementations§
Source§impl Clone for LoraAdapter
impl Clone for LoraAdapter
Source§fn clone(&self) -> LoraAdapter
fn clone(&self) -> LoraAdapter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for LoraAdapter
impl !UnwindSafe for LoraAdapter
impl Freeze for LoraAdapter
impl Send for LoraAdapter
impl Sync for LoraAdapter
impl Unpin for LoraAdapter
impl UnsafeUnpin for LoraAdapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more