loaders.adapter
loaders.adapter
Adapter loading functionality, including LoRA / QLoRA and associated utils
Functions
| Name | Description |
|---|---|
| read_saved_adapter_config | The adapter config saved under lora_model_dir, or None when it is not readable. |
| reinit_lora_from_seed | Re-draw every fresh lora_A from a generator seeded by the module name. |
| setup_quantized_meta_for_peft | Replaces quant_state.to with a dummy function to prevent PEFT from moving quant_state to meta device |
| setup_quantized_peft_meta_for_training | Replaces dummy quant_state.to method with the original function to allow training to continue |
read_saved_adapter_config
loaders.adapter.read_saved_adapter_config(lora_model_dir, from_hub=False)The adapter config saved under lora_model_dir, or None when it is not readable.
A hub id has no local file; with from_hub the config is fetched the way PEFT will.
reinit_lora_from_seed
loaders.adapter.reinit_lora_from_seed(model, seed)Re-draw every fresh lora_A from a generator seeded by the module name.
PEFT draws the adapters from the process RNG in module order, so a value depends on
everything drawn before it: the rank, the parallel layout (expert parallelism sizes the
expert adapter locally, shifting the stream for every later module) and the model’s
module order. Seeding per module makes the init a function of the seed alone. Expert
(target_parameters) adapters are drawn over the GLOBAL expert count and sliced to
this rank’s experts. Returns the number of adapters re-initialised.
setup_quantized_meta_for_peft
loaders.adapter.setup_quantized_meta_for_peft(model)Replaces quant_state.to with a dummy function to prevent PEFT from moving quant_state to meta device
setup_quantized_peft_meta_for_training
loaders.adapter.setup_quantized_peft_meta_for_training(model)Replaces dummy quant_state.to method with the original function to allow training to continue