caikit.core.model_management
The model management abstractions manage the key lifecycle phases of a concrete model instance and are used by the ModelManager to handle each phase of the model lifecycle.
For architectural details, see docs/adrs/020-model-management-abstractions.md
Submodules
- caikit.core.model_management.factories
- caikit.core.model_management.job_base
- caikit.core.model_management.job_predictor_base
- caikit.core.model_management.local_job_base
- caikit.core.model_management.local_job_predictor
- caikit.core.model_management.local_model_finder
- caikit.core.model_management.local_model_initializer
- caikit.core.model_management.local_model_trainer
- caikit.core.model_management.model_finder_base
- caikit.core.model_management.model_initializer_base
- caikit.core.model_management.model_trainer_base
- caikit.core.model_management.multi_model_finder
- caikit.core.model_management.multi_model_initializer
Attributes
Classes
A class can be constructed by a factory if its constructor takes exactly |
|
Every JobBase implementation must have a JobFutureBase class that can access the |
|
A class can be constructed by a factory if its constructor takes exactly |
|
Subclass of JobFutureBase for Job Predictions |
|
JobPredictorInfo is a remap of JobInfo but for predictors |
|
A class can be constructed by a factory if its constructor takes exactly |
|
A class can be constructed by a factory if its constructor takes exactly |
|
A class can be constructed by a factory if its constructor takes exactly |
|
Every JobBase implementation must have a JobFutureBase class that can access the |
|
Package Contents
- caikit.core.model_management.job_predictor_factory
- caikit.core.model_management.model_finder_factory
- caikit.core.model_management.model_initializer_factory
- caikit.core.model_management.model_trainer_factory
- class caikit.core.model_management.JobBase(config: aconfig.Config, instance_name: str)[source]
Bases:
caikit.core.toolkit.factory.FactoryConstructibleA class can be constructed by a factory if its constructor takes exactly one argument that is an aconfig.Config object and it has a name to identify itself with the factory.
- abstract get_future(job_id: str) JobFutureBase[source]
Look up the model future for the given id
- class caikit.core.model_management.JobFutureBase(future_name: str, future_id: str, use_reversible_hash: bool = True, **kwargs)[source]
Bases:
abc.ABCEvery JobBase implementation must have a JobFutureBase class that can access the job information in the infrastructure managed by the task.
- ID_DELIMITER = ':'
- _id = ''
- property id: str
Every job future must have a unique ID that can be used to look up the in-flight background task
- class caikit.core.model_management.JobPredictorBase(config: aconfig.Config, instance_name: str)[source]
Bases:
caikit.core.model_management.job_base.JobBaseA class can be constructed by a factory if its constructor takes exactly one argument that is an aconfig.Config object and it has a name to identify itself with the factory.
- __doc__ = Multiline-String
Show Value
""" A Job Predictor is responsible for managing execution of a prediction jobs running in the background for a given task method Configuration for Job Predictors lives under the config as follows: model_management: job_predictors: <predictor name>: type: <predictor type name> config: <config option>: <value> """
- abstract predict(model_instance: caikit.core.modules.ModuleBase, prediction_func_name: str, *args, external_inference_id: str | None = None, **kwargs) JobPredictorFutureBase[source]
Start a prediction with the given model instance and function and return a future to the prediction result
- abstract get_prediction_future(future_id: str) JobPredictorFutureBase[source]
Look up the jobs future for the given id
- get_future(prediction_id: str) caikit.core.model_management.job_base.JobFutureBase[source]
Look up the job future for the given id
- class caikit.core.model_management.JobPredictorFutureBase(future_name: str, future_id: str, use_reversible_hash: bool = True, **kwargs)[source]
Bases:
caikit.core.model_management.job_base.JobFutureBaseSubclass of JobFutureBase for Job Predictions
- abstract result() caikit.core.data_model.DataObjectBase[source]
The result of a JobPredictorFutureBase is the result object
- class caikit.core.model_management.JobPredictorInfo[source]
Bases:
caikit.core.model_management.job_base.JobInfoJobPredictorInfo is a remap of JobInfo but for predictors
- class caikit.core.model_management.ModelFinderBase(config: aconfig.Config, instance_name: str)[source]
Bases:
caikit.core.toolkit.factory.FactoryConstructibleA class can be constructed by a factory if its constructor takes exactly one argument that is an aconfig.Config object and it has a name to identify itself with the factory.
- __doc__ = Multiline-String
Show Value
""" A ModelFinder is responsible for finding models based on a unique input string which may be a path, id, or other identifier. Configuration for ModelFinders lives under the config as follows: model_management: finders: <finder name>: type: <finder type name> config: <config option>: <value> """
- abstract find_model(model_path: str, **kwargs) caikit.core.modules.ModuleConfig | None[source]
Find any model that can be uniquely identified by the given (logical) path. If found, return the in-memory ModuleConfig.
- Args:
- model_path (str): The logical path to the model (name, id, file
path, etc…)
- **kwargs: All finders must allow additional kwargs through so that
specific finders and loaders can support additional optional arguments.
- Returns:
- result (Optional[ModuleConfig]): If found, the in-memory config
object for the model. If the model cannot be found, an exception may be raised or None returned.
- class caikit.core.model_management.ModelInitializerBase(config: aconfig.Config, instance_name: str)[source]
Bases:
caikit.core.toolkit.factory.FactoryConstructibleA class can be constructed by a factory if its constructor takes exactly one argument that is an aconfig.Config object and it has a name to identify itself with the factory.
- __doc__ = Multiline-String
Show Value
""" A ModelInitializer is responsible for taking an in-memory ModuleConfig and producing a usable Module instance. Configuration for ModelInitializers lives under the config as follows: model_management: initializers: <initializer name>: type: <initializer type name> config: <config option>: <value> """
- abstract init(model_config: caikit.core.modules.ModuleConfig, **kwargs) caikit.core.modules.ModuleBase | None[source]
Given a ModelConfig, attempt to initialize it for running
- Args:
- model_config (ModuleConfig): The in-memory model config object for
the model to be loaded
- **kwargs: All loaders must allow additional kwargs through so that
specific finders and loaders can support additional optional arguments.
- Returns:
- model (Optional[ModuleBase]): The in-memory ModuleBase instance that
is ready to run if successful. If unable to load, an exception may be raised, or None may be returned.
- class caikit.core.model_management.ModelTrainerBase(config: aconfig.Config, instance_name: str)[source]
Bases:
caikit.core.model_management.job_base.JobBaseA class can be constructed by a factory if its constructor takes exactly one argument that is an aconfig.Config object and it has a name to identify itself with the factory.
- __doc__ = Multiline-String
Show Value
""" A Trainer is responsible for managing execution of a training job for a given module class Configuration for ModelTrainers lives under the config as follows: model_management: trainers: <trainer name>: type: <trainer type name> config: <config option>: <value> """
- ModelFutureBase
- abstract train(module_class: Type[caikit.core.modules.ModuleBase], *args, save_path: str | caikit.interfaces.common.data_model.stream_sources.S3Path | None = None, save_with_id: bool = False, model_name: str | None = None, **kwargs) ModelFutureBase[source]
Start training the given module and return a future to the trained model instance
- abstract get_model_future(training_id: str) ModelFutureBase[source]
Look up the model future for the given id
- get_future(job_id: str) caikit.core.model_management.job_base.JobFutureBase[source]
Look up the model future for the given id
- class caikit.core.model_management.ModelTrainerFutureBase(*args, **kwargs)[source]
Bases:
caikit.core.model_management.job_base.JobFutureBaseEvery JobBase implementation must have a JobFutureBase class that can access the job information in the infrastructure managed by the task.
- _save_path
- property save_path: str | None
If created with a save path, the future must expose it, including any injected background id
- abstract load() caikit.core.modules.ModuleBase[source]
A model future must be loadable with no additional arguments. Mainly useful in train results
- result() caikit.core.modules.ModuleBase[source]
The result of a model train future is the loaded model