loaders.constants
+loaders.constants
Shared constants for axolotl.loaders module
+ + +diff --git a/.nojekyll b/.nojekyll index cb54a878f..01b3f75e6 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -e07abf35 \ No newline at end of file +4fb42e45 \ No newline at end of file diff --git a/docs/api/index.html b/docs/api/index.html index 13d3a976a..3f1f280c0 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -416,6 +416,7 @@ ul.task-list li input[type="checkbox"] {
Functionality for loading and patching models, tokenizers, etc.
+| loaders.model | +Model loader class implementation for loading, configuring, and patching various | +
| loaders.tokenizer | +Tokenizer loading functionality and associated utils | +
| loaders.processor | +Processor loading functionality for multi-modal models | +
| loaders.adapter | +Adapter loading functionality, including LoRA / QLoRA and associated utils | +
| loaders.patch_manager | +Patch manager class implementation to complement axolotl.loaders.ModelLoader. |
+
| loaders.constants | +Shared constants for axolotl.loaders module | +
Mixin classes for augmenting trainers
@@ -853,6 +886,14 @@ ul.task-list li input[type="checkbox"] {| utils.models | -Module for models and model loading | -||
| utils.tokenization | Module for tokenization utilities | ||
| utils.chat_templates | This module provides functionality for selecting chat templates based on user choices. | ||
| utils.lora | module to get the state dict of a merged lora model | ||
| utils.lora_embeddings | -helpers for lora embeddings | -||
| utils.model_shard_quant | module to handle loading model on cpu/meta device for FSDP | @@ -921,14 +954,6 @@ ul.task-list li input[type="checkbox"] {utils.data.sft | data handling specific to SFT |
| utils.gradient_checkpointing.offload_cpu | -CPU offloaded checkpointing | -||
| utils.gradient_checkpointing.offload_disk | -DISCO - DIsk-based Storage and Checkpointing with Optimized prefetching | -
PluginManager class is responsible for loading and managing plugins. Itintegrations.base.BasePlugin(self)Base class for all plugins. Defines the interface for plugin methods.
-Attributes: -None
-Methods: -register(cfg): Registers the plugin with the given configuration. -load_datasets(cfg): Loads and preprocesses the dataset for training. -pre_model_load(cfg): Performs actions before the model is loaded. -post_model_build(cfg, model): Performs actions after the model is loaded, but before LoRA adapters are applied. -pre_lora_load(cfg, model): Performs actions before LoRA weights are loaded. -post_lora_load(cfg, model): Performs actions after LoRA weights are loaded. -post_model_load(cfg, model): Performs actions after the model is loaded, inclusive of any adapters. -post_trainer_create(cfg, trainer): Performs actions after the trainer is created. -create_optimizer(cfg, trainer): Creates and returns an optimizer for training. -create_lr_scheduler(cfg, trainer, optimizer, num_training_steps): Creates and returns a learning rate scheduler. -add_callbacks_pre_trainer(cfg, model): Adds callbacks to the trainer before training. -add_callbacks_post_trainer(cfg, trainer): Adds callbacks to the trainer after training.
+A plugin is a reusable, modular, and self-contained piece of code that extends +the functionality of Axolotl. Plugins can be used to integrate third-party models, +modify the training process, or add new features.
+To create a new plugin, you need to inherit from the BasePlugin class and +implement the required methods.
+Plugin methods include: +- register(cfg): Registers the plugin with the given configuration. +- load_datasets(cfg): Loads and preprocesses the dataset for training. +- pre_model_load(cfg): Performs actions before the model is loaded. +- post_model_build(cfg, model): Performs actions after the model is loaded, but +before LoRA adapters are applied. +- pre_lora_load(cfg, model): Performs actions before LoRA weights are loaded. +- post_lora_load(cfg, model): Performs actions after LoRA weights are loaded. +- post_model_load(cfg, model): Performs actions after the model is loaded, +inclusive of any adapters. +- post_trainer_create(cfg, trainer): Performs actions after the trainer is +created. +- create_optimizer(cfg, trainer): Creates and returns an optimizer for training. +- create_lr_scheduler(cfg, trainer, optimizer, num_training_steps): Creates and +returns a learning rate scheduler. +- add_callbacks_pre_trainer(cfg, model): Adds callbacks to the trainer before +training. +- add_callbacks_post_trainer(cfg, trainer): Adds callbacks to the trainer after +training.
+| add_callbacks_post_trainer | -Adds callbacks to the trainer after creating the trainer. | +Adds callbacks to the trainer after creating the trainer. This is useful for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add_callbacks_pre_trainer | -setup callbacks before creating the trainer. | +Set up callbacks before creating the trainer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create_lr_scheduler | @@ -602,11 +614,17 @@ add_callbacks_post_trainer(cfg, trainer): Adds callbacks to the trainer after tr
| Name | @@ -618,13 +636,13 @@ This is useful for callbacks that require access to the model or trainer.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trainer | -object | +Trainer | The trainer object for training. | required |
| Name | @@ -649,8 +662,8 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| - | - | List[callable]: A list of callback functions to be added | +list[Callable] | +A list of callback functions to be added |
integrations.base.BasePlugin.add_callbacks_pre_trainer(cfg, model)setup callbacks before creating the trainer.
+Set up callbacks before creating the trainer.
| Name | @@ -674,13 +693,13 @@ This is useful for callbacks that require access to the model or trainer.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model | -object | +PreTrainedModel | The loaded model. | required |
| - | - | List[callable]: A list of callback functions to be added to the TrainingArgs | +list[Callable] | +A list of callback functions to be added to the TrainingArgs. |
| cfg | -dict | +DictDefault | The configuration for the plugin. | required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trainer | -object | +Trainer | The trainer object for training. | required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optimizer | -object | +Optimizer | The optimizer for training. | required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| object | -LRScheduler | ++ | LRScheduler | None | The created learning rate scheduler. |
| Name | @@ -804,13 +829,13 @@ This is useful for callbacks that require access to the model or trainer.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trainer | -object | +Trainer | The trainer object for training. | required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| object | + | Optimizer | None | The created optimizer. |
| Name | @@ -860,7 +891,7 @@ This is useful for callbacks that require access to the model or trainer.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cfg | -dict | +DictDefault | The global axolotl configuration. | required |
| Name | @@ -879,9 +915,9 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| class | - | The class for the trainer. | +Trainer | None | +The first non-None trainer class returned by a plugin. |
| Name | @@ -937,7 +978,7 @@ This is useful for callbacks that require access to the model or trainer.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| dataset_meta | -+ | Union['TrainDatasetMeta', None] | The metadata for the training dataset. |
| Name | @@ -962,38 +1009,19 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required |
| model | -object | +PreTrainedModel | PeftModel | The loaded model. | required |
| Name | -Type | -Description | -
|---|---|---|
| - | - | None | -
| Name | @@ -1013,7 +1047,7 @@ This is useful for callbacks that require access to the model or trainer.||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required |
| Name | @@ -1039,38 +1079,19 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required |
| model | -object | +PreTrainedModel | PeftModel | The loaded model. | required |
| Name | -Type | -Description | -
|---|---|---|
| - | - | None | -
| Name | @@ -1090,38 +1117,19 @@ This is useful for callbacks that require access to the model or trainer.|||||
|---|---|---|---|---|---|
| cfg | -dict | -The axolotl configuration | +DictDefault | +The axolotl configuration. | required |
| model | -object | +PreTrainedModel | PeftModel | The loaded model. | required |
| Name | -Type | -Description | -
|---|---|---|
| - | - | None | -
| Name | @@ -1141,32 +1155,13 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required |
| Name | -Type | -Description | -
|---|---|---|
| - | - | None | -
| Name | @@ -1186,38 +1187,19 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required |
| trainer | -object | +Trainer | The trainer object for training. | required |
| Name | -Type | -Description | -
|---|---|---|
| - | - | None | -
| Name | @@ -1237,38 +1225,19 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required |
| model | -object | +PreTrainedModel | The loaded model. | required |
| Name | -Type | -Description | -
|---|---|---|
| - | - | None | -
| Name | @@ -1288,15 +1263,55 @@ This is useful for callbacks that require access to the model or trainer.||||
|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugin. | required |
integrations.base.BasePlugin.register(cfg)Registers the plugin with the given configuration.
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugin. | +required | +
integrations.base.PluginManager()The PluginManager class is responsible for loading and managing plugins. It
+should be a singleton so it can be accessed from anywhere in the codebase.
| - | - | None | +plugins | +OrderedDict[str, BasePlugin] | +A list of loaded plugins. |
Key methods include:
+- get_instance(): Static method to get the singleton instance of PluginManager.
+- register(plugin_name: str): Registers a new plugin by its name.
+- pre_model_load(cfg): Calls the pre_model_load method of all registered plugins.
integrations.base.BasePlugin.register(cfg)Registers the plugin with the given configuration.
-Parameters: -cfg (dict): The configuration for the plugin.
-Returns: -None
-integrations.base.PluginManager()The PluginManager class is responsible for loading and managing plugins. -It should be a singleton so it can be accessed from anywhere in the codebase.
-Attributes: -plugins (ListBasePlugin): A list of loaded plugins.
-Methods: -get_instance(): Static method to get the singleton instance of PluginManager. -register(plugin_name: str): Registers a new plugin by its name. -pre_model_load(cfg): Calls the pre_model_load method of all registered plugins.
| add_callbacks_post_trainer | -Calls the add_callbacks_post_trainer method of all registered plugins. | +Calls the add_callbacks_post_trainer method of all registered plugins. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add_callbacks_pre_trainer | @@ -1357,11 +1356,11 @@ pre_model_load(cfg): Calls the pre_model_load method of all registered plugins.<||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create_lr_scheduler | -Calls the create_lr_scheduler method of all registered plugins and returns the first non-None scheduler. | +Calls the create_lr_scheduler method of all registered plugins and returns |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create_optimizer | -Calls the create_optimizer method of all registered plugins and returns the first non-None optimizer. | +Calls the create_optimizer method of all registered plugins and returns |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get_input_args | @@ -1369,11 +1368,11 @@ pre_model_load(cfg): Calls the pre_model_load method of all registered plugins.<||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get_instance | -Returns the singleton instance of PluginManager. | +Returns the singleton instance of PluginManager. If the instance doesn’t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get_trainer_cls | -Calls the get_trainer_cls method of all registered plugins and returns the first non-None trainer class. | +Calls the get_trainer_cls method of all registered plugins and returns the |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| load_datasets | @@ -1381,15 +1380,15 @@ pre_model_load(cfg): Calls the pre_model_load method of all registered plugins.<||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| post_lora_load | -Calls the post_lora_load method of all registered plugins. | +Calls the post_lora_load method of all registered plugins. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| post_model_build | -Calls the post_model_build method of all registered plugins after the model has been built/loaded, | +Calls the post_model_build method of all registered plugins after the |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| post_model_load | -Calls the post_model_load method of all registered plugins after the model has been loaded | +Calls the post_model_load method of all registered plugins after the model |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| post_train | @@ -1401,11 +1400,11 @@ pre_model_load(cfg): Calls the pre_model_load method of all registered plugins.<||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| post_trainer_create | -Calls the post_trainer_create method of all registered plugins. | +Calls the post_trainer_create method of all registered plugins. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pre_lora_load | -Calls the pre_lora_load method of all registered plugins. | +Calls the pre_lora_load method of all registered plugins. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pre_model_load | @@ -1420,80 +1419,15 @@ pre_model_load(cfg): Calls the pre_model_load method of all registered plugins.<
| cfg | -+ | DictDefault | The configuration for the plugins. | required | |||
| preprocess | -- | Whether this is preprocess step of the datasets. | -False |
+trainer | +Trainer | +The trainer object for training. | +required |
| dataset_meta | + | list[Callable] | +A list of callback functions to be added to the TrainingArgs. |
+
integrations.base.PluginManager.add_callbacks_pre_trainer(cfg, model)Calls the add_callbacks_pre_trainer method of all registered plugins.
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| model | +PreTrainedModel | +The loaded model. | +required | +
| Name | +Type | +Description | +
|---|---|---|
| + | list[Callable] | +A list of callback functions to be added to the TrainingArgs. |
+
integrations.base.PluginManager.create_lr_scheduler(
+ trainer,
+ optimizer,
+ num_training_steps,
+)Calls the create_lr_scheduler method of all registered plugins and returns
+the first non-None scheduler.
| Name | +Type | +Description | +Default | +
|---|---|---|---|
| trainer | +Trainer | +The trainer object for training. | +required | +
| optimizer | +Optimizer | +The optimizer for training. | +required | +
| Name | +Type | +Description | +
|---|---|---|
| + | LRScheduler | None | +The created learning rate scheduler, or None if not found. |
+
integrations.base.PluginManager.create_optimizer(trainer)Calls the create_optimizer method of all registered plugins and returns
+the first non-None optimizer.
| Name | +Type | +Description | +Default | +
|---|---|---|---|
| trainer | +Trainer | +The trainer object for training. | +required | +
| Name | +Type | +Description | +
|---|---|---|
| + | Optimizer | None | +The created optimizer, or None if none was found. |
+
integrations.base.PluginManager.get_input_args()Returns a list of Pydantic classes for all registered plugins’ input arguments.’
+| Name | +Type | +Description | +
|---|---|---|
| + | list[str] | +A list of Pydantic classes for all registered plugins’ input arguments.’ | +
integrations.base.PluginManager.get_instance()Returns the singleton instance of PluginManager. If the instance doesn’t +exist, it creates a new one.
+integrations.base.PluginManager.get_trainer_cls(cfg)Calls the get_trainer_cls method of all registered plugins and returns the
+first non-None trainer class.
| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| Name | +Type | +Description | +
|---|---|---|
| + | Trainer | None | +The first non-None trainer class returned by a plugin. |
+
integrations.base.PluginManager.load_datasets(cfg, preprocess=False)Calls the load_datasets method of each registered plugin.
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| preprocess | +bool | +Whether this is preprocess step of the datasets. | +False |
+
| Name | +Type | +Description | +||
|---|---|---|---|---|
| + | Union['TrainDatasetMeta', None] | The dataset metadata loaded from all registered plugins. |
| Name | @@ -1573,13 +1836,52 @@ but before any adapters have been applied.||||
|---|---|---|---|---|
| cfg | -dict | +DictDefault | The configuration for the plugins. | required |
| model | -object | +PreTrainedModel | PeftModel | +The loaded model. | +required | +
integrations.base.PluginManager.post_model_build(cfg, model)Calls the post_model_build method of all registered plugins after the
+model has been built / loaded, but before any adapters have been applied.
| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| model | +PreTrainedModel | The loaded model. | required |
| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| model | +PreTrainedModel | PeftModel | +The loaded model. | +required | +
integrations.base.PluginManager.post_train(cfg, model)Calls the post_train method of all registered plugins.
-Parameters: -cfg (dict): The configuration for the plugins. -model (object): The loaded model.
-Returns: -None
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| model | +PreTrainedModel | PeftModel | +The loaded model. | +required | +
integrations.base.PluginManager.post_train_unload(cfg)Calls the post_train_unload method of all registered plugins.
-Parameters: -cfg (dict): The configuration for the plugins. -model (object): The loaded model.
-Returns: -None
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
integrations.base.PluginManager.post_trainer_create(cfg, trainer)Calls the post_trainer_create method of all registered plugins.
-Parameters: -cfg (dict): The configuration for the plugins. -trainer (object): The trainer object for training.
-Returns: -None
+Calls the post_trainer_create method of all registered plugins.
| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| trainer | +Trainer | +The trainer object for training. | +required | +
integrations.base.PluginManager.pre_lora_load(cfg, model)Calls the pre_lora_load method of all registered plugins.
-Parameters: -cfg (dict): The configuration for the plugins. -model (object): The loaded model.
-Returns: -None
+Calls the pre_lora_load method of all registered plugins.
| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
| model | +PreTrainedModel | +The loaded model. | +required | +
integrations.base.PluginManager.pre_model_load(cfg)Calls the pre_model_load method of all registered plugins.
-Parameters: -cfg (dict): The configuration for the plugins.
-Returns: -None
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| cfg | +DictDefault | +The configuration for the plugins. | +required | +
integrations.base.PluginManager.register(plugin_name)Registers a new plugin by its name.
-Parameters: -plugin_name (str): The name of the plugin to be registered.
-Returns: -None
-Raises: -ImportError: If the plugin module cannot be imported.
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| plugin_name | +str | +The name of the plugin to be registered. | +required | +
| Name | +Type | +Description | +
|---|---|---|
| + | ImportError | +If the plugin module cannot be imported. | +
integrations.base.load_plugin(plugin_name)Loads a plugin based on the given plugin name.
-The plugin name should be in the format “module_name.class_name”. -This function splits the plugin name into module and class, imports the module, -retrieves the class from the module, and creates an instance of the class.
-Parameters: -plugin_name (str): The name of the plugin to be loaded. The name should be in the format “module_name.class_name”.
-Returns: -BasePlugin: An instance of the loaded plugin.
-Raises: -ImportError: If the plugin module cannot be imported.
+The plugin name should be in the format “module_name.class_name”. This function +splits the plugin name into module and class, imports the module, retrieves the +class from the module, and creates an instance of the class.
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
| plugin_name | +str | +The name of the plugin to be loaded. The name should be in the format “module_name.class_name”. | +required | +
| Name | +Type | +Description | +
|---|---|---|
| + | BasePlugin | +An instance of the loaded plugin. | +
| Name | +Type | +Description | +
|---|---|---|
| + | ImportError | +If the plugin module cannot be imported. | +