Implementing kernel
C++ engine symbols that back this Python API.An nn.Linear with a Lily update: .
Parameters
base_ layernn.LinearThe layer to adapt; the other parameters are those of
LilyLayer.adapter_ namestrName of the adapter created at once.
configLilyConfigThe adapter's config.
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import LilyConfig
>>> from lucid.peft.tuners.lily import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", LilyConfig(r=3, num_B=2, target_modules=["x"]))
>>> tuple(layer.lily_A["default"].weight.shape), tuple(layer.lily_B["default"].weight.shape)
((3, 8), (6, 4))
>>> x = lucid.randn(2, 8)
>>> bool((layer(x) == base(x)).all().item()) # the up-projections start at zero
True