Apply a shared base linear layer plus a per-row LoRA adapter in one batched call. This is the serving primitive behind Punica and S-LoRA: many requests, one weight matrix , different adapters.
Inputs
x: (batch, in_features)W: (in_features, out_features) — base weights, used as A: (n_lora, rank, in_features)B: (n_lora, out_features, rank)lora_ids: length batch ints; lora_ids[i] selects the adapter for row . Use -1 for "base only" (no adapter on that row)scales: (n_lora,) — usually for each adapterOutput y of shape (batch, out_features):
when id = lora_ids[i] >= 0, and when id == -1.
Here has shape (rank, in_features) and has shape (out_features, rank), so is (rank,) and the second multiply lands in out_features.
Rows may share an adapter. Unused adapters in A/B are ignored.