For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Python class
LoRAModel
LoRAModelβ
class max.pipelines.lora.LoRAModel(name, path, base_dtype, max_lora_rank, n_heads, n_kv_heads, head_dim, strict=True)
Bases: object
Manages LoRA weights and configuration for a single adapter.
Initializes a LoRAModel by loading its configuration and weights.
lora = LoRAModel("my_adapter", "/path/to/lora", base_dtype, max_lora_rank,
n_heads=32, n_kv_heads=8, head_dim=128)-
Parameters:
-
- name (str) β A string identifier for this adapter.
- path (str) β Filesystem path is only supported
- base_dtype (DType) β The base model dtype.
- max_lora_rank (int) β The maximum LoRA rank supported by the system.
- n_heads (int) β Number of attention heads in the base model.
- n_kv_heads (int) β Number of key-value heads in the base model.
- head_dim (int) β Dimension of each attention head.
- strict (bool) β Whether to enforce strict validation while loading the adapter.
-
Raises:
-
ValueError β If weight files are not in the supported safetensors format, or if the keys in the weights are malformed or incomplete.
adapter_configβ
A dictionary containing metadata/configuration for the LoRA adapter.
get()β
get(key)
Gets the WeightData from the key. If key doesnβt exist in model, then None is returned.
-
Parameters:
-
key (str) β Key of LoRA
-
Returns:
-
WeightData for the key or None if it doesnβt exist.
-
Return type:
-
WeightData | None
lora_Aβ
property lora_A: dict[str, WeightData]
A dictionary mapping weight keys to LoRA A WeightData.
lora_Bβ
property lora_B: dict[str, WeightData]
A dictionary mapping weight keys to LoRA B WeightData.
lora_biasβ
property lora_bias: dict[str, WeightData]
A dictionary mapping weight keys to LoRA bias WeightData.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!