Skip to content
class

Linear

extendsVBLoRALayer
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 VB-LoRA update: y=Wx+b+B A drop(x)y = W x + b + B\,A\,\mathrm{drop}(x).

Parameters

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

Examples

>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft.tuners.vblora import Linear, VBLoRAConfig
>>> base = nn.Linear(8, 4)
>>> config = VBLoRAConfig(r=2, num_vectors=6, vector_length=4, target_modules=["x"])
>>> layer = Linear(base, "default", config)
>>> tuple(layer.vblora_logits_A["default"].shape), tuple(layer.vblora_logits_B["default"].shape)
((2, 2, 6), (1, 2, 6))
>>> tuple(layer.vblora_vector_bank["default"].shape)
(6, 4)
>>> tuple(layer(lucid.randn(3, 8)).shape)
(3, 4)

Used by 1