콘텐츠로 이동

Kandinsky V2.2

Kandinsky V2.2는 텍스트-이미지 잠재 확산 모델입니다. RBLN Optimum을 사용하면 RBLN NPU에서 Kandinsky V2.2 파이프라인을 가속할 수 있습니다.

지원 NPU

Diffusers 파이프라인은 ATOM™에서만 실행됩니다. Rebel100™은 아직 지원하지 않습니다.

지원하는 파이프라인

RBLN Optimum은 여러 Kandinsky V2.2 파이프라인을 지원합니다:

파이프라인 클래스 설명
텍스트-이미지 변환(Text-to-Image) RBLNKandinskyV22CombinedPipeline 텍스트 프롬프트에서 이미지 생성(Prior + Decoder 사용).
이미지-이미지 변환(Image-to-Image) RBLNKandinskyV22Img2ImgCombinedPipeline 텍스트 프롬프트를 기반으로 기존 이미지 수정(Prior + Img2Img Decoder 사용).
인페인팅(Inpainting) RBLNKandinskyV22InpaintCombinedPipeline 텍스트 프롬프트에 따라 이미지의 마스킹된 영역 채우기(Prior + Inpaint Decoder 사용).
Prior RBLNKandinskyV22PriorPipeline Decoder 파이프라인이 사용할 이미지 임베딩 생성.
Decoder RBLNKandinskyV22Pipeline, RBLNKandinskyV22Img2ImgPipeline, RBLNKandinskyV22InpaintPipeline Prior가 만든 임베딩에서 이미지 생성. 작업별로 클래스가 하나씩 있습니다.

중요: guidance scale을 위한 배치 크기 설정

배치 크기와 guidance scale

Kandinsky V2.2를 guidance scale > 1.0(기본값)으로 사용할 때, UNet과 Prior 두 구성 요소의 실제 배치 크기는 classifier-free guidance가 적용되어 런타임 중에 두 배가 됩니다.

RBLN NPU는 정적 그래프 컴파일을 사용하기 때문에, 이러한 구성 요소의 컴파일 시 배치 크기가 런타임 배치 크기와 일치해야 합니다. 그렇지 않으면 컴파일된 그래프를 실행할 수 없어 추론이 실패합니다.

기본 동작

UNet이나 Prior의 배치 크기를 명시적으로 지정하지 않으면 RBLN Optimum은 다음과 같이 동작합니다:

  • 기본 guidance scale(1.0보다 큼)을 사용할 것으로 가정
  • UNet과 Prior의 배치 크기를 파이프라인 배치 크기의 2배로 자동 설정

기본 guidance scale을 사용할 계획이라면 이 자동 설정이 정상적으로 작동합니다. 그러나 다른 guidance scale을 사용하거나 더 많은 제어가 필요한 경우, 배치 크기를 명시적으로 설정해야 합니다.

예제: 명시적으로 배치 크기 설정하기(guidance scale = 1.0)

정확히 guidance scale 1.0을 사용할 계획이라면(classifier-free guidance를 사용하지 않음), 배치 크기를 추론 배치 크기와 일치하도록 명시적으로 설정합니다:

사용 예제

방법 1: 개별 Prior 및 Decoder 파이프라인 사용

이 방식에서는 중간 이미지 임베딩을 직접 다룰 수 있습니다:

import torch
from optimum.rbln import RBLNKandinskyV22PriorPipeline, RBLNKandinskyV22Pipeline

# Prior 파이프라인 로드 및 컴파일
prior_pipe = RBLNKandinskyV22PriorPipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-2-prior",
    export=True,  # 첫 번째 컴파일 시 True로 설정
)

# 특정 이미지 크기로 Decoder 파이프라인 로드 및 컴파일
pipe = RBLNKandinskyV22Pipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-2-decoder",
    export=True,
    rbln_img_height=768,
    rbln_img_width=768,
)

# Prior를 사용하여 텍스트 프롬프트에서 이미지 임베딩 생성
prompt = "a cute cat sitting on a beach, 4k photo"
generator = torch.manual_seed(42)  # 재현 가능한 결과를 위해
prior_output = prior_pipe(prompt, generator=generator)
image_emb = prior_output.image_embeds
negative_image_emb = prior_output.negative_image_embeds

# Decoder와 이미지 임베딩을 사용하여 최종 이미지 생성
output = pipe(
    image_embeds=image_emb,
    negative_image_embeds=negative_image_emb,
    height=768,
    width=768,
    num_inference_steps=50,
    generator=generator,
)

# 생성된 이미지 저장
image = output.images[0]
image.save("generated_cat.png")

방법 2: 결합 파이프라인 사용

결합 파이프라인은 Prior와 Decoder를 한 번의 호출로 실행합니다:

import torch
from optimum.rbln import RBLNKandinskyV22CombinedPipeline

# 결합 파이프라인 로드 및 컴파일
pipe = RBLNKandinskyV22CombinedPipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-2-decoder",  # 주 디코더 모델
    export=True,  # 첫 번째 컴파일 시 True로 설정
    rbln_img_height=768,
    rbln_img_width=768,
)

# 이미지 생성 및 저장
prompt = "a cute cat sitting on a beach, 4k photo"
generator = torch.manual_seed(42)  # 재현 가능한 결과를 위해
image = pipe(
    prompt, height=768, width=768, num_inference_steps=50, generator=generator
).images[0]

image.save("generated_cat.png")

API 참조

RBLNKandinskyV22Pipeline

Bases: RBLNDiffusionMixin, KandinskyV22Pipeline

RBLN-accelerated implementation of Kandinsky 2.2 pipeline for text-to-image generation.

This pipeline compiles Kandinsky 2.2 models to run efficiently on RBLN NPUs, enabling high-performance inference for generating images with distinctive artistic style and enhanced visual quality.

from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod

Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.

This method has two distinct operating modes
  • When export=True: Takes a PyTorch-based diffusion model, compiles it for RBLN NPUs, and loads the compiled model
  • When export=False: Loads an already compiled RBLN model from model_id without recompilation

It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.

Parameters:

Name Type Description Default
model_id `str`

The model ID or path to the pretrained model to load. Can be either:

  • A model ID from the HuggingFace Hub
  • A local path to a saved model directory
required
export bool | None

If True, takes a PyTorch model from model_id and compiles it for RBLN NPU execution. If False, loads an already compiled RBLN model from model_id without recompilation.

None
model_save_dir str | PathLike[str] | None

Directory to save the compiled model artifacts. Only used when export=True. If not provided and export=True, a temporary directory is used.

None
rbln_config dict[str, Any] | RBLNModelConfig | None

Configuration options for RBLN compilation. Can include settings for specific submodules such as text_encoder, unet, and vae. Configuration can be tailored to the specific pipeline being compiled.

None
lora_ids str | list[str] | None

LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when export=True.

None
lora_weights_names str | list[str] | None

Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when export=True.

None
lora_scales float | list[float] | None

Scaling factor(s) to apply to the LoRA adapter(s). Only used when export=True.

None
kwargs Any

Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used.

{}

Returns:

Type Description
Self

A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin.

RBLNKandinskyV22PriorPipeline

Bases: RBLNDiffusionMixin, KandinskyV22PriorPipeline

RBLN-accelerated implementation of Kandinsky 2.2 prior pipeline for text and image embedding generation.

This pipeline compiles Kandinsky 2.2 prior models to run efficiently on RBLN NPUs, enabling high-performance inference for generating image embeddings from text prompts and image inputs for downstream generation tasks.

from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod

Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.

This method has two distinct operating modes
  • When export=True: Takes a PyTorch-based diffusion model, compiles it for RBLN NPUs, and loads the compiled model
  • When export=False: Loads an already compiled RBLN model from model_id without recompilation

It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.

Parameters:

Name Type Description Default
model_id `str`

The model ID or path to the pretrained model to load. Can be either:

  • A model ID from the HuggingFace Hub
  • A local path to a saved model directory
required
export bool | None

If True, takes a PyTorch model from model_id and compiles it for RBLN NPU execution. If False, loads an already compiled RBLN model from model_id without recompilation.

None
model_save_dir str | PathLike[str] | None

Directory to save the compiled model artifacts. Only used when export=True. If not provided and export=True, a temporary directory is used.

None
rbln_config dict[str, Any] | RBLNModelConfig | None

Configuration options for RBLN compilation. Can include settings for specific submodules such as text_encoder, unet, and vae. Configuration can be tailored to the specific pipeline being compiled.

None
lora_ids str | list[str] | None

LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when export=True.

None
lora_weights_names str | list[str] | None

Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when export=True.

None
lora_scales float | list[float] | None

Scaling factor(s) to apply to the LoRA adapter(s). Only used when export=True.

None
kwargs Any

Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used.

{}

Returns:

Type Description
Self

A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin.

RBLNKandinskyV22Img2ImgPipeline

Bases: RBLNDiffusionMixin, KandinskyV22Img2ImgPipeline

RBLN-accelerated implementation of Kandinsky 2.2 pipeline for image-to-image generation.

This pipeline compiles Kandinsky 2.2 models to run efficiently on RBLN NPUs, enabling high-performance inference for transforming input images with distinctive artistic style and enhanced visual fidelity.

from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod

Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.

This method has two distinct operating modes
  • When export=True: Takes a PyTorch-based diffusion model, compiles it for RBLN NPUs, and loads the compiled model
  • When export=False: Loads an already compiled RBLN model from model_id without recompilation

It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.

Parameters:

Name Type Description Default
model_id `str`

The model ID or path to the pretrained model to load. Can be either:

  • A model ID from the HuggingFace Hub
  • A local path to a saved model directory
required
export bool | None

If True, takes a PyTorch model from model_id and compiles it for RBLN NPU execution. If False, loads an already compiled RBLN model from model_id without recompilation.

None
model_save_dir str | PathLike[str] | None

Directory to save the compiled model artifacts. Only used when export=True. If not provided and export=True, a temporary directory is used.

None
rbln_config dict[str, Any] | RBLNModelConfig | None

Configuration options for RBLN compilation. Can include settings for specific submodules such as text_encoder, unet, and vae. Configuration can be tailored to the specific pipeline being compiled.

None
lora_ids str | list[str] | None

LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when export=True.

None
lora_weights_names str | list[str] | None

Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when export=True.

None
lora_scales float | list[float] | None

Scaling factor(s) to apply to the LoRA adapter(s). Only used when export=True.

None
kwargs Any

Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used.

{}

Returns:

Type Description
Self

A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin.

RBLNKandinskyV22InpaintPipeline

Bases: RBLNDiffusionMixin, KandinskyV22InpaintPipeline

RBLN-accelerated implementation of Kandinsky 2.2 pipeline for image inpainting.

This pipeline compiles Kandinsky 2.2 models to run efficiently on RBLN NPUs, enabling high-performance inference for filling masked regions with distinctive artistic style and seamless content integration.

from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod

Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.

This method has two distinct operating modes
  • When export=True: Takes a PyTorch-based diffusion model, compiles it for RBLN NPUs, and loads the compiled model
  • When export=False: Loads an already compiled RBLN model from model_id without recompilation

It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.

Parameters:

Name Type Description Default
model_id `str`

The model ID or path to the pretrained model to load. Can be either:

  • A model ID from the HuggingFace Hub
  • A local path to a saved model directory
required
export bool | None

If True, takes a PyTorch model from model_id and compiles it for RBLN NPU execution. If False, loads an already compiled RBLN model from model_id without recompilation.

None
model_save_dir str | PathLike[str] | None

Directory to save the compiled model artifacts. Only used when export=True. If not provided and export=True, a temporary directory is used.

None
rbln_config dict[str, Any] | RBLNModelConfig | None

Configuration options for RBLN compilation. Can include settings for specific submodules such as text_encoder, unet, and vae. Configuration can be tailored to the specific pipeline being compiled.

None
lora_ids str | list[str] | None

LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when export=True.

None
lora_weights_names str | list[str] | None

Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when export=True.

None
lora_scales float | list[float] | None

Scaling factor(s) to apply to the LoRA adapter(s). Only used when export=True.

None
kwargs Any

Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used.

{}

Returns:

Type Description
Self

A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin.

RBLNKandinskyV22CombinedPipeline

Bases: RBLNDiffusionMixin, KandinskyV22CombinedPipeline

RBLN-accelerated implementation of Kandinsky 2.2 combined pipeline for end-to-end text-to-image generation.

This pipeline compiles both prior and decoder Kandinsky 2.2 models to run efficiently on RBLN NPUs, enabling high-performance inference for complete text-to-image generation with distinctive artistic style.

from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod

Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.

This method has two distinct operating modes
  • When export=True: Takes a PyTorch-based diffusion model, compiles it for RBLN NPUs, and loads the compiled model
  • When export=False: Loads an already compiled RBLN model from model_id without recompilation

It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.

Parameters:

Name Type Description Default
model_id `str`

The model ID or path to the pretrained model to load. Can be either:

  • A model ID from the HuggingFace Hub
  • A local path to a saved model directory
required
export bool | None

If True, takes a PyTorch model from model_id and compiles it for RBLN NPU execution. If False, loads an already compiled RBLN model from model_id without recompilation.

None
model_save_dir str | PathLike[str] | None

Directory to save the compiled model artifacts. Only used when export=True. If not provided and export=True, a temporary directory is used.

None
rbln_config dict[str, Any] | RBLNModelConfig | None

Configuration options for RBLN compilation. Can include settings for specific submodules such as text_encoder, unet, and vae. Configuration can be tailored to the specific pipeline being compiled.

None
lora_ids str | list[str] | None

LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when export=True.

None
lora_weights_names str | list[str] | None

Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when export=True.

None
lora_scales float | list[float] | None

Scaling factor(s) to apply to the LoRA adapter(s). Only used when export=True.

None
kwargs Any

Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used.

{}

Returns:

Type Description
Self

A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin.

RBLNKandinskyV22Img2ImgCombinedPipeline

Bases: RBLNDiffusionMixin, KandinskyV22Img2ImgCombinedPipeline

RBLN-accelerated implementation of Kandinsky 2.2 combined pipeline for end-to-end image-to-image generation.

This pipeline compiles both prior and decoder Kandinsky 2.2 models to run efficiently on RBLN NPUs, enabling high-performance inference for complete image-to-image transformation with distinctive artistic style.

from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod

Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.

This method has two distinct operating modes
  • When export=True: Takes a PyTorch-based diffusion model, compiles it for RBLN NPUs, and loads the compiled model
  • When export=False: Loads an already compiled RBLN model from model_id without recompilation

It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.

Parameters:

Name Type Description Default
model_id `str`

The model ID or path to the pretrained model to load. Can be either:

  • A model ID from the HuggingFace Hub
  • A local path to a saved model directory
required
export bool | None

If True, takes a PyTorch model from model_id and compiles it for RBLN NPU execution. If False, loads an already compiled RBLN model from model_id without recompilation.

None
model_save_dir str | PathLike[str] | None

Directory to save the compiled model artifacts. Only used when export=True. If not provided and export=True, a temporary directory is used.

None
rbln_config dict[str, Any] | RBLNModelConfig | None

Configuration options for RBLN compilation. Can include settings for specific submodules such as text_encoder, unet, and vae. Configuration can be tailored to the specific pipeline being compiled.

None
lora_ids str | list[str] | None

LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when export=True.

None
lora_weights_names str | list[str] | None

Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when export=True.

None
lora_scales float | list[float] | None

Scaling factor(s) to apply to the LoRA adapter(s). Only used when export=True.

None
kwargs Any

Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used.

{}

Returns:

Type Description
Self

A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin.

RBLNKandinskyV22InpaintCombinedPipeline

Bases: RBLNDiffusionMixin, KandinskyV22InpaintCombinedPipeline

RBLN-accelerated implementation of Kandinsky 2.2 combined pipeline for end-to-end image inpainting.

This pipeline compiles both prior and decoder Kandinsky 2.2 models to run efficiently on RBLN NPUs, enabling high-performance inference for complete image inpainting with distinctive artistic style and seamless integration.

from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod

Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.

This method has two distinct operating modes
  • When export=True: Takes a PyTorch-based diffusion model, compiles it for RBLN NPUs, and loads the compiled model
  • When export=False: Loads an already compiled RBLN model from model_id without recompilation

It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.

Parameters:

Name Type Description Default
model_id `str`

The model ID or path to the pretrained model to load. Can be either:

  • A model ID from the HuggingFace Hub
  • A local path to a saved model directory
required
export bool | None

If True, takes a PyTorch model from model_id and compiles it for RBLN NPU execution. If False, loads an already compiled RBLN model from model_id without recompilation.

None
model_save_dir str | PathLike[str] | None

Directory to save the compiled model artifacts. Only used when export=True. If not provided and export=True, a temporary directory is used.

None
rbln_config dict[str, Any] | RBLNModelConfig | None

Configuration options for RBLN compilation. Can include settings for specific submodules such as text_encoder, unet, and vae. Configuration can be tailored to the specific pipeline being compiled.

None
lora_ids str | list[str] | None

LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when export=True.

None
lora_weights_names str | list[str] | None

Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when export=True.

None
lora_scales float | list[float] | None

Scaling factor(s) to apply to the LoRA adapter(s). Only used when export=True.

None
kwargs Any

Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used.

{}

Returns:

Type Description
Self

A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin.

RBLNKandinskyV22PipelineBaseConfig

Bases: RBLNModelConfig

__init__(unet=None, movq=None, *, sample_size=None, batch_size=None, guidance_scale=None, image_size=None, img_height=None, img_width=None, height=None, width=None, **kwargs)

Parameters:

Name Type Description Default
unet RBLNUNet2DConditionModelConfig | None

Configuration for the UNet model component. Initialized as RBLNUNet2DConditionModelConfig if not provided.

None
movq RBLNVQModelConfig | None

Configuration for the MoVQ (VQ-GAN) model component. Initialized as RBLNVQModelConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

Raises:

Type Description
ValueError

If both image_size and img_height/img_width are provided.

Note

When guidance_scale > 1.0, the UNet batch size is automatically doubled to accommodate classifier-free guidance.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

RBLNKandinskyV22PipelineConfig

Bases: RBLNKandinskyV22PipelineBaseConfig

Configuration class for the Kandinsky V2.2 text-to-image decoder pipeline.

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

__init__(unet=None, movq=None, *, sample_size=None, batch_size=None, guidance_scale=None, image_size=None, img_height=None, img_width=None, height=None, width=None, **kwargs)

Parameters:

Name Type Description Default
unet RBLNUNet2DConditionModelConfig | None

Configuration for the UNet model component. Initialized as RBLNUNet2DConditionModelConfig if not provided.

None
movq RBLNVQModelConfig | None

Configuration for the MoVQ (VQ-GAN) model component. Initialized as RBLNVQModelConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

Raises:

Type Description
ValueError

If both image_size and img_height/img_width are provided.

Note

When guidance_scale > 1.0, the UNet batch size is automatically doubled to accommodate classifier-free guidance.

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

RBLNKandinskyV22Img2ImgPipelineConfig

Bases: RBLNKandinskyV22PipelineBaseConfig

Configuration class for the Kandinsky V2.2 image-to-image decoder pipeline.

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

__init__(unet=None, movq=None, *, sample_size=None, batch_size=None, guidance_scale=None, image_size=None, img_height=None, img_width=None, height=None, width=None, **kwargs)

Parameters:

Name Type Description Default
unet RBLNUNet2DConditionModelConfig | None

Configuration for the UNet model component. Initialized as RBLNUNet2DConditionModelConfig if not provided.

None
movq RBLNVQModelConfig | None

Configuration for the MoVQ (VQ-GAN) model component. Initialized as RBLNVQModelConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

Raises:

Type Description
ValueError

If both image_size and img_height/img_width are provided.

Note

When guidance_scale > 1.0, the UNet batch size is automatically doubled to accommodate classifier-free guidance.

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

RBLNKandinskyV22InpaintPipelineConfig

Bases: RBLNKandinskyV22PipelineBaseConfig

Configuration class for the Kandinsky V2.2 inpainting decoder pipeline.

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

__init__(unet=None, movq=None, *, sample_size=None, batch_size=None, guidance_scale=None, image_size=None, img_height=None, img_width=None, height=None, width=None, **kwargs)

Parameters:

Name Type Description Default
unet RBLNUNet2DConditionModelConfig | None

Configuration for the UNet model component. Initialized as RBLNUNet2DConditionModelConfig if not provided.

None
movq RBLNVQModelConfig | None

Configuration for the MoVQ (VQ-GAN) model component. Initialized as RBLNVQModelConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

Raises:

Type Description
ValueError

If both image_size and img_height/img_width are provided.

Note

When guidance_scale > 1.0, the UNet batch size is automatically doubled to accommodate classifier-free guidance.

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

RBLNKandinskyV22PriorPipelineConfig

Bases: RBLNModelConfig

Configuration class for the Kandinsky V2.2 Prior pipeline.

__init__(text_encoder=None, image_encoder=None, prior=None, *, batch_size=None, guidance_scale=None, **kwargs)

Initialize a configuration for Kandinsky 2.2 prior pipeline optimized for RBLN NPU.

This configuration sets up the prior components of the Kandinsky 2.2 architecture, which includes text and image encoders along with a prior transformer that maps text/image embeddings to latent representations used to condition the diffusion process.

Parameters:

Name Type Description Default
text_encoder RBLNCLIPTextModelWithProjectionConfig | None

Configuration for the text encoder component. Initialized as RBLNCLIPTextModelWithProjectionConfig if not provided.

None
image_encoder RBLNCLIPVisionModelWithProjectionConfig | None

Configuration for the image encoder component. Initialized as RBLNCLIPVisionModelWithProjectionConfig if not provided.

None
prior RBLNPriorTransformerConfig | None

Configuration for the prior transformer component. Initialized as RBLNPriorTransformerConfig if not provided.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}
Note

When guidance_scale > 1.0, the prior batch size is automatically doubled to accommodate classifier-free guidance.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

RBLNKandinskyV22CombinedPipelineBaseConfig

Bases: RBLNModelConfig

Base configuration class for Kandinsky V2.2 combined pipelines.

__init__(prior_pipe=None, decoder_pipe=None, *, sample_size=None, image_size=None, batch_size=None, img_height=None, img_width=None, height=None, width=None, guidance_scale=None, prior_prior=None, prior_image_encoder=None, prior_text_encoder=None, unet=None, movq=None, **kwargs)

Initialize a configuration for combined Kandinsky 2.2 pipelines optimized for RBLN NPU.

This configuration integrates both the prior and decoder components of Kandinsky 2.2 into a unified pipeline, allowing for end-to-end text-to-image generation in a single model. It combines the text/image encoding, prior mapping, and diffusion steps together.

Parameters:

Name Type Description Default
prior_pipe RBLNKandinskyV22PriorPipelineConfig | None

Configuration for the prior pipeline. Initialized as RBLNKandinskyV22PriorPipelineConfig if not provided.

None
decoder_pipe RBLNKandinskyV22PipelineConfig | None

Configuration for the decoder pipeline. Initialized as RBLNKandinskyV22PipelineConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
prior_prior RBLNPriorTransformerConfig | None

Direct configuration for the prior transformer. Used if prior_pipe is not provided.

None
prior_image_encoder RBLNCLIPVisionModelWithProjectionConfig | None

Direct configuration for the image encoder. Used if prior_pipe is not provided.

None
prior_text_encoder RBLNCLIPTextModelWithProjectionConfig | None

Direct configuration for the text encoder. Used if prior_pipe is not provided.

None
unet RBLNUNet2DConditionModelConfig | None

Direct configuration for the UNet. Used if decoder_pipe is not provided.

None
movq RBLNVQModelConfig | None

Direct configuration for the MoVQ (VQ-GAN) model. Used if decoder_pipe is not provided.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

RBLNKandinskyV22CombinedPipelineConfig

Bases: RBLNKandinskyV22CombinedPipelineBaseConfig

Configuration class for the Kandinsky V2.2 combined text-to-image pipeline.

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

__init__(prior_pipe=None, decoder_pipe=None, *, sample_size=None, image_size=None, batch_size=None, img_height=None, img_width=None, height=None, width=None, guidance_scale=None, prior_prior=None, prior_image_encoder=None, prior_text_encoder=None, unet=None, movq=None, **kwargs)

Initialize a configuration for combined Kandinsky 2.2 pipelines optimized for RBLN NPU.

This configuration integrates both the prior and decoder components of Kandinsky 2.2 into a unified pipeline, allowing for end-to-end text-to-image generation in a single model. It combines the text/image encoding, prior mapping, and diffusion steps together.

Parameters:

Name Type Description Default
prior_pipe RBLNKandinskyV22PriorPipelineConfig | None

Configuration for the prior pipeline. Initialized as RBLNKandinskyV22PriorPipelineConfig if not provided.

None
decoder_pipe RBLNKandinskyV22PipelineConfig | None

Configuration for the decoder pipeline. Initialized as RBLNKandinskyV22PipelineConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
prior_prior RBLNPriorTransformerConfig | None

Direct configuration for the prior transformer. Used if prior_pipe is not provided.

None
prior_image_encoder RBLNCLIPVisionModelWithProjectionConfig | None

Direct configuration for the image encoder. Used if prior_pipe is not provided.

None
prior_text_encoder RBLNCLIPTextModelWithProjectionConfig | None

Direct configuration for the text encoder. Used if prior_pipe is not provided.

None
unet RBLNUNet2DConditionModelConfig | None

Direct configuration for the UNet. Used if decoder_pipe is not provided.

None
movq RBLNVQModelConfig | None

Direct configuration for the MoVQ (VQ-GAN) model. Used if decoder_pipe is not provided.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

RBLNKandinskyV22InpaintCombinedPipelineConfig

Bases: RBLNKandinskyV22CombinedPipelineBaseConfig

Configuration class for the Kandinsky V2.2 combined inpainting pipeline.

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

__init__(prior_pipe=None, decoder_pipe=None, *, sample_size=None, image_size=None, batch_size=None, img_height=None, img_width=None, height=None, width=None, guidance_scale=None, prior_prior=None, prior_image_encoder=None, prior_text_encoder=None, unet=None, movq=None, **kwargs)

Initialize a configuration for combined Kandinsky 2.2 pipelines optimized for RBLN NPU.

This configuration integrates both the prior and decoder components of Kandinsky 2.2 into a unified pipeline, allowing for end-to-end text-to-image generation in a single model. It combines the text/image encoding, prior mapping, and diffusion steps together.

Parameters:

Name Type Description Default
prior_pipe RBLNKandinskyV22PriorPipelineConfig | None

Configuration for the prior pipeline. Initialized as RBLNKandinskyV22PriorPipelineConfig if not provided.

None
decoder_pipe RBLNKandinskyV22PipelineConfig | None

Configuration for the decoder pipeline. Initialized as RBLNKandinskyV22PipelineConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
prior_prior RBLNPriorTransformerConfig | None

Direct configuration for the prior transformer. Used if prior_pipe is not provided.

None
prior_image_encoder RBLNCLIPVisionModelWithProjectionConfig | None

Direct configuration for the image encoder. Used if prior_pipe is not provided.

None
prior_text_encoder RBLNCLIPTextModelWithProjectionConfig | None

Direct configuration for the text encoder. Used if prior_pipe is not provided.

None
unet RBLNUNet2DConditionModelConfig | None

Direct configuration for the UNet. Used if decoder_pipe is not provided.

None
movq RBLNVQModelConfig | None

Direct configuration for the MoVQ (VQ-GAN) model. Used if decoder_pipe is not provided.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")

RBLNKandinskyV22Img2ImgCombinedPipelineConfig

Bases: RBLNKandinskyV22CombinedPipelineBaseConfig

Configuration class for the Kandinsky V2.2 combined image-to-image pipeline.

initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs)

Build the config of a submodule from the parent's runtime options and kwargs.

Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.

__init__(prior_pipe=None, decoder_pipe=None, *, sample_size=None, image_size=None, batch_size=None, img_height=None, img_width=None, height=None, width=None, guidance_scale=None, prior_prior=None, prior_image_encoder=None, prior_text_encoder=None, unet=None, movq=None, **kwargs)

Initialize a configuration for combined Kandinsky 2.2 pipelines optimized for RBLN NPU.

This configuration integrates both the prior and decoder components of Kandinsky 2.2 into a unified pipeline, allowing for end-to-end text-to-image generation in a single model. It combines the text/image encoding, prior mapping, and diffusion steps together.

Parameters:

Name Type Description Default
prior_pipe RBLNKandinskyV22PriorPipelineConfig | None

Configuration for the prior pipeline. Initialized as RBLNKandinskyV22PriorPipelineConfig if not provided.

None
decoder_pipe RBLNKandinskyV22PipelineConfig | None

Configuration for the decoder pipeline. Initialized as RBLNKandinskyV22PipelineConfig if not provided.

None
sample_size tuple[int, int] | None

Spatial dimensions for the UNet model.

None
image_size tuple[int, int] | None

Dimensions for the generated images. Cannot be used together with img_height/img_width.

None
batch_size int | None

Batch size for inference, applied to all submodules.

None
img_height int | None

Height of the generated images.

None
img_width int | None

Width of the generated images.

None
height int | None

Height of the generated images.

None
width int | None

Width of the generated images.

None
guidance_scale float | None

Scale for classifier-free guidance.

None
prior_prior RBLNPriorTransformerConfig | None

Direct configuration for the prior transformer. Used if prior_pipe is not provided.

None
prior_image_encoder RBLNCLIPVisionModelWithProjectionConfig | None

Direct configuration for the image encoder. Used if prior_pipe is not provided.

None
prior_text_encoder RBLNCLIPTextModelWithProjectionConfig | None

Direct configuration for the text encoder. Used if prior_pipe is not provided.

None
unet RBLNUNet2DConditionModelConfig | None

Direct configuration for the UNet. Used if decoder_pipe is not provided.

None
movq RBLNVQModelConfig | None

Direct configuration for the MoVQ (VQ-GAN) model. Used if decoder_pipe is not provided.

None
kwargs Any

Additional arguments passed to the parent RBLNModelConfig.

{}

get_load_overrides()

Extract the options that must cross the load boundary, for passing to from_pretrained.

Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.

Returns:

Type Description
dict[str, Any]

Dictionary of load overrides, keyed like the rbln_config dict accepted by from_pretrained.

from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod

Load a RBLNModelConfig from a path.

Parameters:

Name Type Description Default
path str

Path to the RBLNModelConfig file or directory containing the config file.

required
rbln_config dict[str, Any] | None

Additional configuration to override.

None
return_unused_kwargs bool

Whether to return unused kwargs.

False
kwargs Any

Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration.

{}

Returns:

Name Type Description
RBLNModelConfig Self | tuple[Self, dict[str, Any]]

The loaded configuration instance.

Note

This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.

Examples:

config = RBLNResNetForImageClassificationConfig.from_pretrained("/path/to/model")