class
Linear
extends
IA3LayerLinear(base_layer: nn.Module, adapter_name: str, config: IA3Config, is_feedforward: bool = False)Implementing kernel
C++ engine symbols that back this Python API.An nn.Linear with an (IA)^3 vector: , or .
The vector is (out_features, 1) for an output-side layer and (1, in_features) for a
feed-forward one, as in the reference; merging multiplies it into the weight's rows or
columns.
Stackable: the vector scales the output (or input) of whatever layer it stands on, and merging multiplies it into the weight the layers below have already folded.
Parameters
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import IA3Config
>>> from lucid.peft.tuners.ia3 import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", IA3Config(target_modules=["x"]))
>>> tuple(layer.ia3_l["default"].shape)
(4, 1)
>>> x = lucid.randn(3, 8)
>>> bool((layer(x) == base(x)).all().item()) # the vector starts at ones
True