Lily
4 memberslucid.peft.tuners.lilylucid.peft.tuners.lily — Lily: low-rank adapters shared across layers and mixed by a router.
Lily (Zhong et al., 2024, arXiv:2407.09946) shares one low-rank down-projection among several consecutive layers and one pool of up-projections among all layers, mixed in each layer by a learned router. Pick it for fewer, larger adapters than one LoRA per layer, which can then carry a higher rank. The mixture depends on the batch, so a Lily adapter cannot be folded into the weights.
Where the reference library keeps them, so isinstance(m, LilyLayer) and from lucid.peft.tuners.lily import LilyConfig, Linear read as they do there. One layer type for the one
module the method adapts, nn.Linear. LilyConfig and LilyModel (which shares the
projections between layers) are here and exported from lucid.peft. Importing the package
registers the method (its config under PeftType.LILY, its tuner and layer), which is what makes
get_peft_model and PeftModel.from_pretrained know it.
Zhong, Yibo, et al. "Low-Rank Interconnected Adaptation across Layers." [arXiv:2407.09946](https://arxiv.org/abs/2407.09946), 2024.
Lily (Zhong et al., 2024, arXiv:2407.09946 — Low-Rank Interconnected Adaptation across Layers)
breaks LoRA's pairing of a down- and an up-projection to one layer. Every stride_A consecutive layers
share one low-rank projection ; num_B projections are shared by all layers, and a
learned router mixes them with softmax weights into one combined per layer. The layer adds
to its output, so a layer's update draws on adapters
other layers train too.
Classes
LilyConfig9 methodsHow lucid.peft.get_peft_model adapts a model with Lily.
LilyLayer21 methodsAdapter bookkeeping and the routed update shared by the Lily layers.
LinearAn nn.Linear with a Lily update: .
LilyModel15 methodsA model with Lily layers put into it, and the tools to take them out again.