data
BdLoraConfig
BdLoraConfig(target_modules_bd_a: list[str] | None = None, target_modules_bd_b: list[str] | None = None, nblocks: int = 1, match_strict: bool = True)Options of block-diagonal LoRA, which makes chosen LoRA factors block-diagonal.
In BD-LoRA a LoRA factor or is a block-diagonal matrix of nblocks
blocks, so the adapter splits across devices (or serving shards) without communication.
target_modules_bd_a names the modules whose is block-diagonal (the query, key,
value, up and gate projections) and target_modules_bd_b those whose is (the
output and down projections). LoraConfig(use_bdlora=...) is refused: the extension is
not implemented.
Parameters
target_ modules_ bd_ alist of str= NoneModules whose LoRA-A is block-diagonal; a pattern matches a module whose name contains it.
target_ modules_ bd_ blist of str= NoneModules whose LoRA-B is block-diagonal, matched the same way.
nblocksint= 1Blocks per block-diagonal matrix. Set it to the sharding degree to serve with.
match_ strictbool= TrueRequire every targeted module to have a block-diagonal A or B and raise otherwise.
False allows mixing plain LoRA and BD-LoRA layers.Raises
ValueErrorA module is listed for both A and B.
Examples
>>> from lucid.peft import BdLoraConfig
>>> config = BdLoraConfig(target_modules_bd_a=["q_proj"], target_modules_bd_b=["o_proj"], nblocks=2)
>>> config.nblocks, config.match_strict
(2, True)