Skip to content
module

Lily

4 members
lucid.peft.tuners.lily

lucid.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.

Paper

Zhong, Yibo, et al. "Low-Rank Interconnected Adaptation across Layers." [arXiv:2407.09946](https://arxiv.org/abs/2407.09946), 2024.

Overview

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 AA; num_B projections BB are shared by all layers, and a learned router mixes them with softmax weights into one combined BB per layer. The layer adds scaling⋅A Bcombined\text{scaling} \cdot A\,B_{\text{combined}} to its output, so a layer's update draws on adapters other layers train too.

Classes