class
Linear
extends
SupertuningLayerLinear(base_layer: nn.Module, adapter_name: str, config: C)Implementing kernel
C++ engine symbols that back this Python API.An nn.Linear with a Super-Tuning update: .
Parameters
base_ layernn.LinearThe layer to adapt; the other parameters are those of
SupertuningLayer.adapter_ namestrName of the first adapter.
configSupertuningConfigsparsity, select_top, the LoRA options and save_precomputed_indices.Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import SupertuningConfig
>>> from lucid.peft.tuners.supertuning import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", SupertuningConfig(sparsity=0.75, target_modules=["x"]))
>>> tuple(layer.supertuning_values["default"].shape), tuple(layer.supertuning_indices["default"].shape)
((8,), (8,))
>>> x = lucid.randn(3, 8)
>>> bool((layer(x) == base(x)).all().item()) # the values start at zero
True