XLoraConfig
PeftConfigXLoraConfig(task_type: TaskType | str | None = None, peft_type: PeftType | str | None = None, auto_mapping: dict[str, str] | None = None, peft_version: str | None = None, base_model_name_or_path: str | None = None, revision: str | None = None, inference_mode: bool = False, hidden_size: int | None = None, adapters: dict[str, str] | None = None, enable_softmax: bool = True, enable_softmax_topk: bool = False, layerwise_scalings: bool = False, xlora_depth: int = 1, xlora_size: int = 2048, xlora_dropout_p: float = 0.2, use_trainable_adapters: bool = False, softmax_temperature: float = 1.0, top_k_lora: int | None = None, scaling_pass_value: float = 0.0, global_scaling_weight: float = 1.0)How lucid.peft.get_peft_model mixes LoRA adapters with X-LoRA.
X-LoRA (Buehler & Buehler, 2024, arXiv:2402.07148) keeps several trained LoRA adapters (the
experts) and a small classifier on the base model's final hidden states that scales each
expert per token: a scalings pass computes the hidden states with the experts held at a
fixed value, the classifier turns them into one weight per expert (per adapted layer if
layerwise_scalings), and the real pass adds each expert's update with its weight. Only the
classifier trains unless use_trainable_adapters.
Field names, their order, defaults and adapter_config.json are the reference adapter library's. Unlike the reference's, hidden_size left unset is read off the model
rather than guessed, and an empty adapters is refused when the model is built.
Parameters
lucid.peft.PeftConfig.lucid.peft.PeftConfig.lucid.peft.PeftConfig.lucid.peft.PeftConfig.lucid.peft.PeftConfig.lucid.peft.PeftConfig.lucid.peft.PeftConfig.hidden_ sizeint= NoneNone.adaptersdict of str to str= None"0", "1", ... in this order, which is also the order of the
classifier's outputs. Needed when the model is built.enable_ softmaxbool= Trueenable_ softmax_ topkbool= Falsetop_k_lora kept experts instead; set enable_softmax off with it.layerwise_ scalingsbool= Falsen_experts * n_layers)
instead of one set shared by every layer.xlora_ depthint= 1xlora_ sizeint= 2048xlora_ dropout_ pfloat= 0.2use_ trainable_ adaptersbool= Falsesoftmax_ temperaturefloat= 1.0top_ k_ loraint= Nonescaling_ pass_ valuefloat= 0.00 makes that pass the base model.global_ scaling_ weightfloat= 1.0Raises
TypeErrorValueErrortop_k_lora is below one.Examples
>>> from lucid.peft import XLoraConfig
>>> config = XLoraConfig(hidden_size=64, adapters={"a": "/tmp/a", "b": "/tmp/b"}, xlora_depth=2)
>>> config.peft_type, sorted(config.adapters)
(<PeftType.XLORA: 'XLORA'>, ['a', 'b'])
>>> XLoraConfig.from_dict(config.to_dict()) == config
True