Skip to content
module

Poly

4 members
lucid.peft.tuners.poly

lucid.peft.tuners.poly — Poly and Multi-Head Routing: low-rank skills mixed per task by a learned router.

Polytropon (Ponti et al., 2022, arXiv:2202.13914) gives every adapted linear layer n_skills low-rank adapters and a router with one learned logit vector per task. A batch row's update is the mixture of the skills its task's logits weight, y=Wx+1r x AtBty = Wx + \tfrac{1}{r}\,x\,A_t B_t with At=∑smt,sAsA_t = \sum_s m_{t,s}A_s and likewise BtB_t. Multi-Head Routing (Caccia et al., 2022, arXiv:2211.03831) routes each of n_splits blocks of the features separately. The router logits start near zero, so every skill is mixed equally, and BB starts at zero, so the adapted model starts as the base. Pick it for multitask fine-tuning where tasks should share some skills and a new task can be learned by routing alone; each call names its tasks (task_ids).

The update depends on the task of each row, so it does not fold into the weights and nothing merges. The layer type is Linear (an nn.Linear); PolyConfig and PolyModel are here and exported from lucid.peft. Importing the package registers the method under PeftType.POLY.

Paper

Ponti, Edoardo M., et al. "Combining Modular Skills in Multitask Learning." [arXiv:2202.13914](https://arxiv.org/abs/2202.13914), 2022.

Overview

Polytropon (Ponti et al., 2022, arXiv:2202.13914) gives each targeted layer n_skills low-rank adapters (skills) and a router that holds one learned logit vector per task; the layer's update for a task is the router-weighted mixture of the skills, y=Wx+1r x (∑smsAs)(∑smsBs)y = W x + \tfrac{1}{r}\,x\,(\sum_s m_s A_s)(\sum_s m_s B_s). Multi-Head Routing (Caccia et al., 2022, arXiv:2211.03831) splits every skill into n_splits blocks along the feature axis, each routed on its own: n_splits > 1. The weights mm are the sigmoid of the task's logits, normalised to sum to one — in training a relaxed Bernoulli sample of them instead, which makes the routing stochastic.

Classes