Buckets:
Components and configs
ComponentSpec[[diffusers.ComponentSpec]]
class diffusers.ComponentSpecdiffusers.ComponentSpec
- type_hint -- Type of the component (e.g. UNet2DConditionModel)
- description -- Optional description of the component
- config -- Optional config dict for init creation
- repo -- Optional repo path for from_pretrained creation
- subfolder -- Optional subfolder in repo
- variant -- Optional variant in repo
- revision -- Optional revision in repo
- default_creation_method -- Preferred creation method - "from_config" or "from_pretrained"0 Specification for a pipeline component.
A component can be created in two ways:
- From scratch using init with a config dict
- using
from_pretrained
creatediffusers.ComponentSpec.create
decode_load_iddiffusers.ComponentSpec.decode_load_idload method).
Decode a load_id string back into a dictionary of loading fields and values.
from_componentdiffusers.ComponentSpec.from_component
- component -- Component object to create spec from0ComponentSpec object-
ValueError-- If component is not supported (e.g. nn.Module without load_id, non-ConfigMixin)ValueErrorCreate a ComponentSpec from a Component.
Currently supports:
- Components created with
ComponentSpec.load()method - Components that are ConfigMixin subclasses but not nn.Modules (e.g. schedulers, guiders)
loaddiffusers.ComponentSpec.load
loading_fieldsdiffusers.ComponentSpec.loading_fields
Return the names of all loading‐related fields (i.e. those whose field.metadata["loading"] is True).
ConfigSpec[[diffusers.modular_pipelines.ConfigSpec]]
class diffusers.modular_pipelines.ConfigSpecdiffusers.modular_pipelines.ConfigSpec
ComponentsManager[[diffusers.ComponentsManager]]
class diffusers.ComponentsManagerdiffusers.ComponentsManager
A central registry and management system for model components across multiple pipelines.
ComponentsManager provides a unified way to register, track, and reuse model components (like UNet, VAE, text encoders, etc.) across different modular pipelines. It includes features for duplicate detection, memory management, and component organization.
> This is an experimental feature and is likely to change in the future.
Example:
from diffusers import ComponentsManager
# Create a components manager
cm = ComponentsManager()
# Add components
cm.add("unet", unet_model, collection="sdxl")
cm.add("vae", vae_model, collection="sdxl")
# Enable auto offloading
cm.enable_auto_cpu_offload()
# Retrieve components
unet = cm.get_one(name="unet", collection="sdxl")
adddiffusers.ComponentsManager.add
- component (Any) -- The component to add
- collection (Optional[str]) -- The collection to add the component to0strThe unique component ID, which is generated as "{name}_{id(component)}" where id(component) is Python's built-in unique identifier for the object
Add a component to the ComponentsManager.
disable_auto_cpu_offloaddiffusers.ComponentsManager.disable_auto_cpu_offload
Disable automatic CPU offloading for all components.
enable_auto_cpu_offloaddiffusers.ComponentsManager.enable_auto_cpu_offload
- memory_reserve_margin (str) -- The memory reserve margin to use, default is 3GB. This is the amount of memory to keep free on the device to avoid running out of memory during model execution (e.g., for intermediate activations, gradients, etc.)0
Enable automatic CPU offloading for all components.
The algorithm works as follows:
- All models start on CPU by default
- When a model's forward pass is called, it's moved to the execution device
- If there's insufficient memory, other models on the device are moved back to CPU
- The system tries to offload the smallest combination of models that frees enough memory
- Models stay on the execution device until another model needs memory and forces them off
get_components_by_idsdiffusers.ComponentsManager.get_components_by_ids
- return_dict_with_names (Optional[bool]) -- Whether to return a dictionary with component names as keys:0Dict[str, Any]Dictionary of components.
- If return_dict_with_names=True, keys are component names.
- If return_dict_with_names=False, keys are component IDs.-
ValueError-- If duplicate component names are found in the search results when return_dict_with_names=TrueValueError
Get components by a list of IDs.
get_components_by_namesdiffusers.ComponentsManager.get_components_by_names
- collection (Optional[str]) -- Optional collection to filter by0Dict[str, Any]Dictionary of components with component names as keys-
ValueError-- If duplicate component names are found in the search resultsValueError
Get components by a list of names, optionally filtered by collection.
get_idsdiffusers.ComponentsManager.get_ids
- collection (Optional[str]) -- Optional collection to filter by0List[str]List of component IDs
Get component IDs by a list of names, optionally filtered by collection.
get_model_infodiffusers.ComponentsManager.get_model_info
- fields (Optional[Union[str, List[str]]]) -- Field(s) to return. Can be a string for single field or list of fields. If None, uses the available_info_fields setting.0Dictionary containing requested component metadata. If fields is specified, returns only those fields. Otherwise, returns all fields. Get comprehensive information about a component.
get_onediffusers.ComponentsManager.get_one
- name (Optional[str]) -- Component name or pattern
- collection (Optional[str]) -- Optional collection to filter by
- load_id (Optional[str]) -- Optional load_id to filter by0A single component-
ValueError-- If no components match or multiple components matchValueError
Get a single component by either:
- searching name (pattern matching), collection, or load_id.
- passing in a component_id Raises an error if multiple components match or none are found.
removediffusers.ComponentsManager.remove
Remove a component from the ComponentsManager.
remove_from_collectiondiffusers.ComponentsManager.remove_from_collection
Remove a component from a collection.
search_componentsdiffusers.ComponentsManager.search_components
- "unet" : match any component with base name "unet" (e.g., unet_123abc)
- "!unet" : everything except components with base name "unet"
- "unet*" : anything with base name starting with "unet"
- "!unet*" : anything with base name NOT starting with "unet"
- "unet" : anything with base name containing "unet"
- "!unet" : anything with base name NOT containing "unet"
- "refiner|vae|unet" : anything with base name exactly matching "refiner", "vae", or "unet"
- "!refiner|vae|unet" : anything with base name NOT exactly matching "refiner", "vae", or "unet"
- "unet*|vae*" : anything with base name starting with "unet" OR starting with "vae"
- collection -- Optional collection to filter by
- load_id -- Optional load_id to filter by
- return_dict_with_names -- If True, returns a dictionary with component names as keys, throw an error if multiple components with the same name are found If False, returns a dictionary with component IDs as keys0Dictionary mapping component names to components if return_dict_with_names=True, or a dictionary mapping component IDs to components if return_dict_with_names=False
Search components by name with simple pattern matching. Optionally filter by collection or load_id.
InsertableDict[[diffusers.modular_pipelines.InsertableDict]]
class diffusers.modular_pipelines.InsertableDictdiffusers.modular_pipelines.InsertableDict
Xet Storage Details
- Size:
- 19.2 kB
- Xet hash:
- 963ebee469a8b588b262bdeebb14245f836f1bfe04a5aaa77b1a3c4b7991bbd4
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.