Python class
DiffusionPipeline
DiffusionPipeline
class max.pipelines.lib.interfaces.DiffusionPipeline(pipeline_config, session, devices, weight_paths, cache_config=None, **kwargs)
Bases: ABC
Base class for diffusion pipelines.
Subclasses must define components mapping component names to ComponentModel types.
-
Parameters:
-
- pipeline_config (PipelineConfig)
- session (InferenceSession)
- devices (list[Device])
- weight_paths (list[Path])
- cache_config (DenoisingCacheConfig | None)
- kwargs (Any)
components
components: dict[str, type[ComponentModel]] | None = None
default_num_inference_steps
default_num_inference_steps: int = 50
Default number of denoising steps when the user does not specify one.
Subclasses may override this to provide a model-appropriate default.
execute()
abstract execute(model_inputs, **kwargs)
Execute the pipeline with the given model inputs.
-
Parameters:
-
- model_inputs (PixelModelInputs) – Prepared model inputs from prepare_inputs.
- **kwargs (Any) – Additional pipeline-specific execution parameters.
-
Returns:
-
Pipeline-specific output (e.g., generated images).
-
Return type:
init_remaining_components()
abstract init_remaining_components()
Initialize non-ComponentModel components (e.g., image processors).
-
Return type:
-
None
prepare_inputs()
abstract prepare_inputs(context)
Prepare inputs for the pipeline.
-
Parameters:
-
context (PixelGenerationContext)
-
Return type:
run_denoising_step()
run_denoising_step(step, cache_state, device, **kwargs)
Execute one denoising step with caching logic.
Delegates the actual transformer call to self.run_transformer(),
which subclasses override with model-specific arguments.
run_transformer()
run_transformer(cache_state, **kwargs)
Run the transformer for one denoising step.
Subclasses must override this to call their transformer with the
appropriate model-specific arguments. The method should return
(noise_pred,) when first_block_caching is disabled, or
(new_residual, noise_pred) when first_block_caching is enabled.
unprefixed_weight_component
When set, weight files without a <component>/ prefix are assigned to
this component. This supports multi-repo layouts where quantized weights
for one component (e.g. the transformer) are shipped as flat files in a
separate repo while the remaining components use the base model repo.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!