struct LoraMlp {
&Mlp base;
struct Vec<&FloatTensor> A;
struct Vec<&FloatTensor> B;
struct LoraConfig cfg;
float scale;
struct Rng rng;
}Borrows the base Mlp and freezes its parameters (requiresGrad = 0) until LoraMlp::detach; the base must outlive the adapter.
Fields
per layer [in, r]
per layer [r, out]
alpha / r
Methods
Parameterized (module.h): the adapters (A_0, B_0, A_1, B_1, ...), which are all that trains and all a LoRA file holds.
W += scale * A B in the base for every layer, then B = 0: the base alone now computes what the adapted network did.
Frees the adapters and unfreezes the base.