SHiRA
5 memberslucid.peft.tuners.shiralucid.peft.tuners.shira — SHiRA: train a sparse subset of the weight itself.
SHiRA (Bhardwaj et al., 2024, arXiv:2406.13175 — Sparse High Rank Adapters) fixes a mask of
entries of each adapted weight — as many as a rank- LoRA pair
has — and trains the values of those entries alone. The update is sparse but not low rank. The
mask is a function of the weight's shape and random_seed (or of your own mask_fn, see
random_mask), so an adapter is a short list of indices and values. Pick it when a high-rank,
sparse change suits the task.
Where the reference library keeps them, so isinstance(m, ShiraLayer) and from lucid.peft.tuners.shira import ShiraConfig, Linear read as they do there. One layer type for the
one module the method adapts, nn.Linear. ShiraConfig and ShiraModel are here and
exported from lucid.peft. Importing the package registers the method (its config under
PeftType.SHIRA, its tuner and layer), which is what makes get_peft_model and
PeftModel.from_pretrained know it.
Bhardwaj, Kartikeya, et al. "Sparse High Rank Adapters." [arXiv:2406.13175](https://arxiv.org/abs/2406.13175), 2024.
SHiRA (Bhardwaj et al., 2024, arXiv:2406.13175 — Sparse High Rank Adapters) trains a
sparse subset of the weight itself: a fixed mask picks
entries of each targeted nn.Linear weight (as many parameters as a rank-
LoRA pair has, hence the name of r), and the adapter is the values of those
entries,
Classes
ShiraConfig9 methodsHow lucid.peft.get_peft_model adapts a model with SHiRA.
LinearAn nn.Linear with a SHiRA update: .
ShiraLayer22 methodsAdapter bookkeeping and the values-to-weight map shared by the SHiRA layers.
ShiraModel15 methodsA model with SHiRA layers in it, and the tools to take them out again.