credit.models#

Submodules#

Attributes#

Functions#

__getattr__(name)

register_model(model_type[, message])

Decorator that adds an external PyTorch model class to the model registry.

_load_model_entry(model_type)

Lazily import and return (model_class, log_message) for a registered model type.

load_fsdp_or_checkpoint_policy(conf)

load_custom_model_modules(conf)

Import every file listed under custom_models in the config.

load_model(conf[, load_weights, model_name])

load_model_name(conf, model_name[, load_weights])

Package Contents#

credit.models.logger#
credit.models._MODEL_REGISTRY#
credit.models._CLASS_SOURCES#
credit.models.__getattr__(name)#
credit.models.register_model(model_type, message=None)#

Decorator that adds an external PyTorch model class to the model registry.

Parameters:
  • model_type – Key used in the config model.type field.

  • message – Optional log message shown when the model is loaded.

Example:

@register_model("my_model", "Loading my custom model ...")
class MyModel(torch.nn.Module):
    ...
credit.models._load_model_entry(model_type)#

Lazily import and return (model_class, log_message) for a registered model type.

credit.models.load_fsdp_or_checkpoint_policy(conf)#
credit.models.load_custom_model_modules(conf)#

Import every file listed under custom_models in the config.

Each file is executed as a standalone module. The expected use-case is that each file contains one or more classes decorated with @register_model, so the import triggers registration as a side-effect.

Parameters:

conf (dict) – Top-level config dict. If custom_models is absent or empty this function is a no-op.

Raises:

FileNotFoundError – If a listed path does not exist on disk.

credit.models.load_model(conf, load_weights=False, model_name=False)#
credit.models.load_model_name(conf, model_name, load_weights=False)#