Skip to content
class

Linear

extendsWaveFTLayer
Linear(base_layer: nn.Module, adapter_name: str, config: C)

Implementing kernel

C++ engine symbols that back this Python API.

An nn.Linear with a WaveFT update: y=(W+s IDWT2(⋅)) x+by = (W + s\,\mathrm{IDWT}_2(\cdot))\,x + b.

Parameters

base_layernn.Linear
The layer to adapt; the other parameters are those of WaveFTLayer.
adapter_namestr
Name of the first adapter.
The adapter's config (its n_frequency is this layer's).

Examples

>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import WaveFTConfig
>>> from lucid.peft.tuners.waveft import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", WaveFTConfig(n_frequency=5, target_modules=["x"]))
>>> tuple(layer.waveft_spectrum["default"].shape)
(5,)
>>> x = lucid.randn(3, 8)
>>> bool((layer(x) == base(x)).all().item())   # the coefficients start at zero
True

Used by 1