Implementing kernel
C++ engine symbols that back this Python API.An nn.Linear with an OFT rotation of its input: .
The rotation is applied block by block to the input, which costs for rows of width and blocks of size instead of the of building .
With several active adapters the weight is for the adapters
listed [1, 2], which merging writes, so the input is turned by the last one listed
first. Rotations do not commute: the order the adapters are listed in matters, and the
adapted layer equals the merged one in each.
Stackable: it rotates the input and then calls the layer below it, once. The
convolution does not (Conv2d computes from the weight and may not stand on a layer).
Parameters
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import OFTConfig
>>> from lucid.peft.tuners.oft import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", OFTConfig(oft_block_size=4, target_modules=["x"]))
>>> layer.r["default"], tuple(layer.oft_R["default"].shape)
(2, (2, 6))
>>> x = lucid.randn(3, 8)
>>> bool((layer(x) == base(x)).all().item()) # the rotation starts at the identity
True