Skip to content
class

Linear

extendsMissLayer
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 MiSS update: y=(W+ΔW) x+by = (W + \Delta W)\,x + b.

Parameters

base_layernn.Linear
The layer to adapt; the other parameters are those of MissLayer.
adapter_namestr
Name of the adapter created at once.
The adapter's config.

Examples

>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import MissConfig
>>> from lucid.peft.tuners.miss import Linear
>>> base = nn.Linear(8, 4)
>>> layer = Linear(base, "default", MissConfig(r=2, target_modules=["x"]))
>>> tuple(layer.miss_block["default"].shape)
(2, 4)
>>> x = lucid.randn(3, 8)
>>> bool((layer(x) == base(x)).all().item())   # the block starts at zero
True

Used by 2

Instance methods

1
fn

supports_lora_conversion

→bool
supports_lora_conversion(adapter_name: str = 'default')

Whether adapter_name on this MiSS linear layer can be converted to LoRA.