Skip to content
data

VeloraConfig

VeloraConfig(num_groups: int = 64, scale: float = 1.0, init_type: Literal['batch_average', 'batch_average_once', 'random'] = 'batch_average')

Options of VeLoRA, which keeps a compressed copy of each activation for the backward pass.

VeLoRA (Miles et al., 2024, arXiv:2405.17991) trains with less memory by splitting each layer's input activation into num_groups sub-tokens along its depth and storing only a rank-1 projection of every group; the backward pass reconstructs the activation from it, scaled by scale. LoraConfig(velora_config=...) is refused: the extension is not implemented.

Parameters

num_groupsint= 64
How many groups the input activation's depth is cut into before it is compressed.
scalefloat= 1.0
Multiplier applied to the reconstructed activations in the backward pass.
init_type(batch_average, batch_average_once, random)= "batch_average"
How the projection is set. "batch_average" takes it from the batch's statistics in every forward pass; "batch_average_once" does so in the first pass only (cheaper, a less exact gradient); "random" draws it at random.

Raises

ValueError
num_groups or scale is not positive, or init_type is not one of the three.

Examples

>>> from lucid.peft import VeloraConfig
>>> config = VeloraConfig(num_groups=32, init_type="random")
>>> config.num_groups, config.scale
(32, 1.0)

Used by 2