optimum-rbln 0.9.3.post1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of optimum-rbln might be problematic. Click here for more details.
- optimum/rbln/__init__.py +505 -0
- optimum/rbln/__version__.py +34 -0
- optimum/rbln/cli.py +660 -0
- optimum/rbln/configuration_utils.py +968 -0
- optimum/rbln/diffusers/__init__.py +198 -0
- optimum/rbln/diffusers/configurations/__init__.py +37 -0
- optimum/rbln/diffusers/configurations/models/__init__.py +10 -0
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl.py +73 -0
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl_cosmos.py +84 -0
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl_temporal_decoder.py +67 -0
- optimum/rbln/diffusers/configurations/models/configuration_controlnet.py +64 -0
- optimum/rbln/diffusers/configurations/models/configuration_prior_transformer.py +59 -0
- optimum/rbln/diffusers/configurations/models/configuration_transformer_cosmos.py +78 -0
- optimum/rbln/diffusers/configurations/models/configuration_transformer_sd3.py +63 -0
- optimum/rbln/diffusers/configurations/models/configuration_unet_2d_condition.py +81 -0
- optimum/rbln/diffusers/configurations/models/configuration_unet_spatio_temporal_condition.py +59 -0
- optimum/rbln/diffusers/configurations/models/configuration_vq_model.py +74 -0
- optimum/rbln/diffusers/configurations/pipelines/__init__.py +34 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_controlnet.py +316 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_cosmos.py +117 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_kandinsky2_2.py +363 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion.py +156 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_3.py +176 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_xl.py +159 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_video_diffusion.py +114 -0
- optimum/rbln/diffusers/modeling_diffusers.py +451 -0
- optimum/rbln/diffusers/models/__init__.py +64 -0
- optimum/rbln/diffusers/models/autoencoders/__init__.py +18 -0
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl.py +255 -0
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl_cosmos.py +245 -0
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +275 -0
- optimum/rbln/diffusers/models/autoencoders/vae.py +178 -0
- optimum/rbln/diffusers/models/autoencoders/vq_model.py +211 -0
- optimum/rbln/diffusers/models/controlnet.py +281 -0
- optimum/rbln/diffusers/models/transformers/__init__.py +17 -0
- optimum/rbln/diffusers/models/transformers/prior_transformer.py +160 -0
- optimum/rbln/diffusers/models/transformers/transformer_cosmos.py +344 -0
- optimum/rbln/diffusers/models/transformers/transformer_sd3.py +191 -0
- optimum/rbln/diffusers/models/unets/__init__.py +16 -0
- optimum/rbln/diffusers/models/unets/unet_2d_condition.py +408 -0
- optimum/rbln/diffusers/models/unets/unet_spatio_temporal_condition.py +201 -0
- optimum/rbln/diffusers/pipelines/__init__.py +113 -0
- optimum/rbln/diffusers/pipelines/auto_pipeline.py +307 -0
- optimum/rbln/diffusers/pipelines/controlnet/__init__.py +19 -0
- optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +139 -0
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py +669 -0
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +640 -0
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +825 -0
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +837 -0
- optimum/rbln/diffusers/pipelines/cosmos/__init__.py +17 -0
- optimum/rbln/diffusers/pipelines/cosmos/configuration_cosmos_guardrail.py +113 -0
- optimum/rbln/diffusers/pipelines/cosmos/cosmos_guardrail.py +425 -0
- optimum/rbln/diffusers/pipelines/cosmos/pipeline_cosmos_text2world.py +128 -0
- optimum/rbln/diffusers/pipelines/cosmos/pipeline_cosmos_video2world.py +128 -0
- optimum/rbln/diffusers/pipelines/kandinsky2_2/__init__.py +23 -0
- optimum/rbln/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py +34 -0
- optimum/rbln/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +207 -0
- optimum/rbln/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +34 -0
- optimum/rbln/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_inpaint.py +34 -0
- optimum/rbln/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_prior.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion/__init__.py +17 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +32 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/__init__.py +17 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/__init__.py +17 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +31 -0
- optimum/rbln/diffusers/pipelines/stable_video_diffusion/__init__.py +15 -0
- optimum/rbln/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +46 -0
- optimum/rbln/modeling.py +364 -0
- optimum/rbln/modeling_base.py +637 -0
- optimum/rbln/ops/__init__.py +19 -0
- optimum/rbln/ops/attn.py +455 -0
- optimum/rbln/ops/flash_attn.py +350 -0
- optimum/rbln/ops/kv_cache_update.py +29 -0
- optimum/rbln/ops/linear.py +32 -0
- optimum/rbln/ops/sliding_window_attn.py +111 -0
- optimum/rbln/transformers/__init__.py +340 -0
- optimum/rbln/transformers/configuration_generic.py +120 -0
- optimum/rbln/transformers/modeling_attention_utils.py +385 -0
- optimum/rbln/transformers/modeling_generic.py +280 -0
- optimum/rbln/transformers/modeling_outputs.py +37 -0
- optimum/rbln/transformers/modeling_rope_utils.py +314 -0
- optimum/rbln/transformers/models/__init__.py +343 -0
- optimum/rbln/transformers/models/audio_spectrogram_transformer/__init__.py +17 -0
- optimum/rbln/transformers/models/audio_spectrogram_transformer/configuration_audio_spectrogram_transformer.py +47 -0
- optimum/rbln/transformers/models/audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.py +91 -0
- optimum/rbln/transformers/models/auto/__init__.py +31 -0
- optimum/rbln/transformers/models/auto/auto_factory.py +267 -0
- optimum/rbln/transformers/models/auto/modeling_auto.py +162 -0
- optimum/rbln/transformers/models/bart/__init__.py +17 -0
- optimum/rbln/transformers/models/bart/bart_architecture.py +163 -0
- optimum/rbln/transformers/models/bart/configuration_bart.py +36 -0
- optimum/rbln/transformers/models/bart/modeling_bart.py +86 -0
- optimum/rbln/transformers/models/bert/__init__.py +16 -0
- optimum/rbln/transformers/models/bert/bert_architecture.py +16 -0
- optimum/rbln/transformers/models/bert/configuration_bert.py +46 -0
- optimum/rbln/transformers/models/bert/modeling_bert.py +148 -0
- optimum/rbln/transformers/models/blip_2/__init__.py +20 -0
- optimum/rbln/transformers/models/blip_2/configuration_blip_2.py +115 -0
- optimum/rbln/transformers/models/blip_2/modeling_blip_2.py +526 -0
- optimum/rbln/transformers/models/clip/__init__.py +26 -0
- optimum/rbln/transformers/models/clip/configuration_clip.py +103 -0
- optimum/rbln/transformers/models/clip/modeling_clip.py +384 -0
- optimum/rbln/transformers/models/colpali/__init__.py +2 -0
- optimum/rbln/transformers/models/colpali/colpali_architecture.py +218 -0
- optimum/rbln/transformers/models/colpali/configuration_colpali.py +84 -0
- optimum/rbln/transformers/models/colpali/modeling_colpali.py +361 -0
- optimum/rbln/transformers/models/colqwen2/__init__.py +2 -0
- optimum/rbln/transformers/models/colqwen2/colqwen2_architecture.py +233 -0
- optimum/rbln/transformers/models/colqwen2/configuration_colqwen2.py +74 -0
- optimum/rbln/transformers/models/colqwen2/modeling_colqwen2.py +446 -0
- optimum/rbln/transformers/models/decoderonly/__init__.py +27 -0
- optimum/rbln/transformers/models/decoderonly/configuration_decoderonly.py +300 -0
- optimum/rbln/transformers/models/decoderonly/configuration_lora.py +411 -0
- optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +1224 -0
- optimum/rbln/transformers/models/decoderonly/decoderonly_runtime_utils.py +508 -0
- optimum/rbln/transformers/models/decoderonly/generation_decoderonly.py +119 -0
- optimum/rbln/transformers/models/decoderonly/lora_architecture.py +204 -0
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +823 -0
- optimum/rbln/transformers/models/depth_anything/__init__.py +16 -0
- optimum/rbln/transformers/models/depth_anything/configuration_depth_anything.py +24 -0
- optimum/rbln/transformers/models/depth_anything/modeling_depth_anything.py +42 -0
- optimum/rbln/transformers/models/distilbert/__init__.py +19 -0
- optimum/rbln/transformers/models/distilbert/configuration_distilbert.py +24 -0
- optimum/rbln/transformers/models/distilbert/modeling_distilbert.py +51 -0
- optimum/rbln/transformers/models/dpt/__init__.py +16 -0
- optimum/rbln/transformers/models/dpt/configuration_dpt.py +24 -0
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +42 -0
- optimum/rbln/transformers/models/exaone/__init__.py +24 -0
- optimum/rbln/transformers/models/exaone/configuration_exaone.py +42 -0
- optimum/rbln/transformers/models/exaone/exaone_architecture.py +77 -0
- optimum/rbln/transformers/models/exaone/modeling_exaone.py +145 -0
- optimum/rbln/transformers/models/gemma/__init__.py +16 -0
- optimum/rbln/transformers/models/gemma/configuration_gemma.py +50 -0
- optimum/rbln/transformers/models/gemma/gemma_architecture.py +27 -0
- optimum/rbln/transformers/models/gemma/modeling_gemma.py +104 -0
- optimum/rbln/transformers/models/gemma3/__init__.py +16 -0
- optimum/rbln/transformers/models/gemma3/configuration_gemma3.py +109 -0
- optimum/rbln/transformers/models/gemma3/gemma3_architecture.py +170 -0
- optimum/rbln/transformers/models/gemma3/gemma3_runtime_utils.py +245 -0
- optimum/rbln/transformers/models/gemma3/modeling_gemma3.py +611 -0
- optimum/rbln/transformers/models/gpt2/__init__.py +16 -0
- optimum/rbln/transformers/models/gpt2/configuration_gpt2.py +50 -0
- optimum/rbln/transformers/models/gpt2/gpt2_architecture.py +93 -0
- optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +55 -0
- optimum/rbln/transformers/models/grounding_dino/__init__.py +10 -0
- optimum/rbln/transformers/models/grounding_dino/configuration_grounding_dino.py +92 -0
- optimum/rbln/transformers/models/grounding_dino/grounding_dino_architecture.py +599 -0
- optimum/rbln/transformers/models/grounding_dino/modeling_grounding_dino.py +1048 -0
- optimum/rbln/transformers/models/idefics3/__init__.py +16 -0
- optimum/rbln/transformers/models/idefics3/configuration_idefics3.py +89 -0
- optimum/rbln/transformers/models/idefics3/modeling_idefics3.py +497 -0
- optimum/rbln/transformers/models/llama/__init__.py +16 -0
- optimum/rbln/transformers/models/llama/configuration_llama.py +50 -0
- optimum/rbln/transformers/models/llama/llama_architecture.py +19 -0
- optimum/rbln/transformers/models/llama/modeling_llama.py +104 -0
- optimum/rbln/transformers/models/llava/__init__.py +16 -0
- optimum/rbln/transformers/models/llava/configuration_llava.py +72 -0
- optimum/rbln/transformers/models/llava/modeling_llava.py +490 -0
- optimum/rbln/transformers/models/llava_next/__init__.py +16 -0
- optimum/rbln/transformers/models/llava_next/configuration_llava_next.py +69 -0
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +493 -0
- optimum/rbln/transformers/models/midm/__init__.py +24 -0
- optimum/rbln/transformers/models/midm/configuration_midm.py +42 -0
- optimum/rbln/transformers/models/midm/midm_architecture.py +144 -0
- optimum/rbln/transformers/models/midm/modeling_midm.py +144 -0
- optimum/rbln/transformers/models/mistral/__init__.py +16 -0
- optimum/rbln/transformers/models/mistral/configuration_mistral.py +50 -0
- optimum/rbln/transformers/models/mistral/mistral_architecture.py +19 -0
- optimum/rbln/transformers/models/mistral/modeling_mistral.py +115 -0
- optimum/rbln/transformers/models/opt/__init__.py +16 -0
- optimum/rbln/transformers/models/opt/configuration_opt.py +29 -0
- optimum/rbln/transformers/models/opt/modeling_opt.py +102 -0
- optimum/rbln/transformers/models/opt/opt_architecture.py +74 -0
- optimum/rbln/transformers/models/pegasus/__init__.py +17 -0
- optimum/rbln/transformers/models/pegasus/configuration_pegasus.py +38 -0
- optimum/rbln/transformers/models/pegasus/modeling_pegasus.py +71 -0
- optimum/rbln/transformers/models/pegasus/pegasus_architecture.py +161 -0
- optimum/rbln/transformers/models/phi/__init__.py +16 -0
- optimum/rbln/transformers/models/phi/configuration_phi.py +50 -0
- optimum/rbln/transformers/models/phi/modeling_phi.py +92 -0
- optimum/rbln/transformers/models/phi/phi_architecture.py +115 -0
- optimum/rbln/transformers/models/pixtral/__init__.py +16 -0
- optimum/rbln/transformers/models/pixtral/configuration_pixtral.py +43 -0
- optimum/rbln/transformers/models/pixtral/modeling_pixtral.py +322 -0
- optimum/rbln/transformers/models/pixtral/pixtral_architecture.py +73 -0
- optimum/rbln/transformers/models/qwen2/__init__.py +16 -0
- optimum/rbln/transformers/models/qwen2/configuration_qwen2.py +50 -0
- optimum/rbln/transformers/models/qwen2/modeling_qwen2.py +123 -0
- optimum/rbln/transformers/models/qwen2/qwen2_architecture.py +19 -0
- optimum/rbln/transformers/models/qwen2_5_vl/__init__.py +19 -0
- optimum/rbln/transformers/models/qwen2_5_vl/configuration_qwen2_5_vl.py +111 -0
- optimum/rbln/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py +636 -0
- optimum/rbln/transformers/models/qwen2_5_vl/qwen2_5_vl_architecture.py +220 -0
- optimum/rbln/transformers/models/qwen2_vl/__init__.py +19 -0
- optimum/rbln/transformers/models/qwen2_vl/configuration_qwen2_vl.py +88 -0
- optimum/rbln/transformers/models/qwen2_vl/modeling_qwen2_vl.py +513 -0
- optimum/rbln/transformers/models/qwen2_vl/qwen2_vl_architecture.py +165 -0
- optimum/rbln/transformers/models/qwen3/__init__.py +16 -0
- optimum/rbln/transformers/models/qwen3/configuration_qwen3.py +71 -0
- optimum/rbln/transformers/models/qwen3/modeling_qwen3.py +133 -0
- optimum/rbln/transformers/models/qwen3/qwen3_architecture.py +31 -0
- optimum/rbln/transformers/models/resnet/__init__.py +23 -0
- optimum/rbln/transformers/models/resnet/configuration_resnet.py +42 -0
- optimum/rbln/transformers/models/resnet/modeling_resnet.py +99 -0
- optimum/rbln/transformers/models/roberta/__init__.py +24 -0
- optimum/rbln/transformers/models/roberta/configuration_roberta.py +33 -0
- optimum/rbln/transformers/models/roberta/modeling_roberta.py +72 -0
- optimum/rbln/transformers/models/seq2seq/__init__.py +16 -0
- optimum/rbln/transformers/models/seq2seq/configuration_seq2seq.py +71 -0
- optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +477 -0
- optimum/rbln/transformers/models/seq2seq/seq2seq_architecture.py +527 -0
- optimum/rbln/transformers/models/siglip/__init__.py +16 -0
- optimum/rbln/transformers/models/siglip/configuration_siglip.py +76 -0
- optimum/rbln/transformers/models/siglip/modeling_siglip.py +199 -0
- optimum/rbln/transformers/models/swin/__init__.py +16 -0
- optimum/rbln/transformers/models/swin/configuration_swin.py +42 -0
- optimum/rbln/transformers/models/swin/modeling_swin.py +354 -0
- optimum/rbln/transformers/models/t5/__init__.py +17 -0
- optimum/rbln/transformers/models/t5/configuration_t5.py +36 -0
- optimum/rbln/transformers/models/t5/modeling_t5.py +130 -0
- optimum/rbln/transformers/models/t5/t5_architecture.py +264 -0
- optimum/rbln/transformers/models/time_series_transformer/__init__.py +26 -0
- optimum/rbln/transformers/models/time_series_transformer/configuration_time_series_transformer.py +41 -0
- optimum/rbln/transformers/models/time_series_transformer/modeling_time_series_transformer.py +435 -0
- optimum/rbln/transformers/models/time_series_transformer/time_series_transformers_architecture.py +337 -0
- optimum/rbln/transformers/models/vit/__init__.py +19 -0
- optimum/rbln/transformers/models/vit/configuration_vit.py +24 -0
- optimum/rbln/transformers/models/vit/modeling_vit.py +44 -0
- optimum/rbln/transformers/models/wav2vec2/__init__.py +16 -0
- optimum/rbln/transformers/models/wav2vec2/configuration_wav2vec2.py +38 -0
- optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py +104 -0
- optimum/rbln/transformers/models/whisper/__init__.py +17 -0
- optimum/rbln/transformers/models/whisper/configuration_whisper.py +72 -0
- optimum/rbln/transformers/models/whisper/generation_whisper.py +159 -0
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +475 -0
- optimum/rbln/transformers/models/whisper/whisper_architecture.py +349 -0
- optimum/rbln/transformers/models/xlm_roberta/__init__.py +24 -0
- optimum/rbln/transformers/models/xlm_roberta/configuration_xlm_roberta.py +32 -0
- optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +82 -0
- optimum/rbln/transformers/utils/__init__.py +0 -0
- optimum/rbln/transformers/utils/rbln_quantization.py +589 -0
- optimum/rbln/transformers/utils/rbln_runtime_wrapper.py +79 -0
- optimum/rbln/utils/__init__.py +16 -0
- optimum/rbln/utils/decorator_utils.py +86 -0
- optimum/rbln/utils/deprecation.py +213 -0
- optimum/rbln/utils/hub.py +94 -0
- optimum/rbln/utils/import_utils.py +170 -0
- optimum/rbln/utils/logging.py +110 -0
- optimum/rbln/utils/model_utils.py +63 -0
- optimum/rbln/utils/runtime_utils.py +249 -0
- optimum/rbln/utils/save_utils.py +102 -0
- optimum/rbln/utils/submodule.py +152 -0
- optimum_rbln-0.9.3.post1.dist-info/METADATA +124 -0
- optimum_rbln-0.9.3.post1.dist-info/RECORD +264 -0
- optimum_rbln-0.9.3.post1.dist-info/WHEEL +4 -0
- optimum_rbln-0.9.3.post1.dist-info/entry_points.txt +2 -0
- optimum_rbln-0.9.3.post1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import TYPE_CHECKING
|
|
16
|
+
|
|
17
|
+
from diffusers.pipelines.pipeline_utils import ALL_IMPORTABLE_CLASSES, LOADABLE_CLASSES
|
|
18
|
+
from transformers.utils import _LazyModule
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
LOADABLE_CLASSES["optimum.rbln"] = {
|
|
22
|
+
"RBLNBaseModel": ["save_pretrained", "from_pretrained"],
|
|
23
|
+
"RBLNCosmosSafetyChecker": ["save_pretrained", "from_pretrained"],
|
|
24
|
+
}
|
|
25
|
+
ALL_IMPORTABLE_CLASSES.update(LOADABLE_CLASSES["optimum.rbln"])
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_import_structure = {
|
|
29
|
+
"configurations": [
|
|
30
|
+
"RBLNAutoencoderKLConfig",
|
|
31
|
+
"RBLNAutoencoderKLCosmosConfig",
|
|
32
|
+
"RBLNControlNetModelConfig",
|
|
33
|
+
"RBLNCosmosTextToWorldPipelineConfig",
|
|
34
|
+
"RBLNCosmosVideoToWorldPipelineConfig",
|
|
35
|
+
"RBLNCosmosTransformer3DModelConfig",
|
|
36
|
+
"RBLNKandinskyV22CombinedPipelineConfig",
|
|
37
|
+
"RBLNKandinskyV22Img2ImgCombinedPipelineConfig",
|
|
38
|
+
"RBLNKandinskyV22Img2ImgPipelineConfig",
|
|
39
|
+
"RBLNKandinskyV22InpaintCombinedPipelineConfig",
|
|
40
|
+
"RBLNKandinskyV22InpaintPipelineConfig",
|
|
41
|
+
"RBLNKandinskyV22PipelineConfig",
|
|
42
|
+
"RBLNKandinskyV22PriorPipelineConfig",
|
|
43
|
+
"RBLNPriorTransformerConfig",
|
|
44
|
+
"RBLNStableDiffusionControlNetPipelineConfig",
|
|
45
|
+
"RBLNStableDiffusionControlNetImg2ImgPipelineConfig",
|
|
46
|
+
"RBLNStableDiffusionImg2ImgPipelineConfig",
|
|
47
|
+
"RBLNStableDiffusionInpaintPipelineConfig",
|
|
48
|
+
"RBLNStableDiffusionPipelineConfig",
|
|
49
|
+
"RBLNStableDiffusionXLControlNetPipelineConfig",
|
|
50
|
+
"RBLNStableDiffusionXLControlNetImg2ImgPipelineConfig",
|
|
51
|
+
"RBLNStableDiffusionXLImg2ImgPipelineConfig",
|
|
52
|
+
"RBLNStableDiffusionXLInpaintPipelineConfig",
|
|
53
|
+
"RBLNStableDiffusionXLPipelineConfig",
|
|
54
|
+
"RBLNStableDiffusion3PipelineConfig",
|
|
55
|
+
"RBLNStableDiffusion3Img2ImgPipelineConfig",
|
|
56
|
+
"RBLNStableDiffusion3InpaintPipelineConfig",
|
|
57
|
+
"RBLNSD3Transformer2DModelConfig",
|
|
58
|
+
"RBLNUNet2DConditionModelConfig",
|
|
59
|
+
"RBLNVQModelConfig",
|
|
60
|
+
"RBLNUNetSpatioTemporalConditionModelConfig",
|
|
61
|
+
"RBLNStableVideoDiffusionPipelineConfig",
|
|
62
|
+
"RBLNAutoencoderKLTemporalDecoderConfig",
|
|
63
|
+
],
|
|
64
|
+
"pipelines": [
|
|
65
|
+
"RBLNAutoPipelineForImage2Image",
|
|
66
|
+
"RBLNAutoPipelineForInpainting",
|
|
67
|
+
"RBLNAutoPipelineForText2Image",
|
|
68
|
+
"RBLNCosmosTextToWorldPipeline",
|
|
69
|
+
"RBLNCosmosVideoToWorldPipeline",
|
|
70
|
+
"RBLNCosmosSafetyChecker",
|
|
71
|
+
"RBLNKandinskyV22CombinedPipeline",
|
|
72
|
+
"RBLNKandinskyV22Img2ImgCombinedPipeline",
|
|
73
|
+
"RBLNKandinskyV22InpaintCombinedPipeline",
|
|
74
|
+
"RBLNKandinskyV22InpaintPipeline",
|
|
75
|
+
"RBLNKandinskyV22Img2ImgPipeline",
|
|
76
|
+
"RBLNKandinskyV22PriorPipeline",
|
|
77
|
+
"RBLNKandinskyV22Pipeline",
|
|
78
|
+
"RBLNStableDiffusionPipeline",
|
|
79
|
+
"RBLNStableDiffusionXLPipeline",
|
|
80
|
+
"RBLNStableDiffusionImg2ImgPipeline",
|
|
81
|
+
"RBLNStableDiffusionInpaintPipeline",
|
|
82
|
+
"RBLNStableDiffusionControlNetImg2ImgPipeline",
|
|
83
|
+
"RBLNMultiControlNetModel",
|
|
84
|
+
"RBLNStableDiffusionXLImg2ImgPipeline",
|
|
85
|
+
"RBLNStableDiffusionXLInpaintPipeline",
|
|
86
|
+
"RBLNStableDiffusionControlNetPipeline",
|
|
87
|
+
"RBLNStableDiffusionXLControlNetPipeline",
|
|
88
|
+
"RBLNStableDiffusionXLControlNetImg2ImgPipeline",
|
|
89
|
+
"RBLNStableDiffusion3Pipeline",
|
|
90
|
+
"RBLNStableDiffusion3Img2ImgPipeline",
|
|
91
|
+
"RBLNStableDiffusion3InpaintPipeline",
|
|
92
|
+
"RBLNStableVideoDiffusionPipeline",
|
|
93
|
+
],
|
|
94
|
+
"models": [
|
|
95
|
+
"RBLNAutoencoderKL",
|
|
96
|
+
"RBLNAutoencoderKLCosmos",
|
|
97
|
+
"RBLNUNet2DConditionModel",
|
|
98
|
+
"RBLNUNetSpatioTemporalConditionModel",
|
|
99
|
+
"RBLNControlNetModel",
|
|
100
|
+
"RBLNCosmosTransformer3DModel",
|
|
101
|
+
"RBLNSD3Transformer2DModel",
|
|
102
|
+
"RBLNAutoencoderKLTemporalDecoder",
|
|
103
|
+
"RBLNPriorTransformer",
|
|
104
|
+
"RBLNVQModel",
|
|
105
|
+
],
|
|
106
|
+
"modeling_diffusers": [
|
|
107
|
+
"RBLNDiffusionMixin",
|
|
108
|
+
],
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if TYPE_CHECKING:
|
|
112
|
+
from .configurations import (
|
|
113
|
+
RBLNAutoencoderKLConfig,
|
|
114
|
+
RBLNAutoencoderKLCosmosConfig,
|
|
115
|
+
RBLNAutoencoderKLTemporalDecoderConfig,
|
|
116
|
+
RBLNControlNetModelConfig,
|
|
117
|
+
RBLNCosmosTextToWorldPipelineConfig,
|
|
118
|
+
RBLNCosmosTransformer3DModelConfig,
|
|
119
|
+
RBLNCosmosVideoToWorldPipelineConfig,
|
|
120
|
+
RBLNKandinskyV22CombinedPipelineConfig,
|
|
121
|
+
RBLNKandinskyV22Img2ImgCombinedPipelineConfig,
|
|
122
|
+
RBLNKandinskyV22Img2ImgPipelineConfig,
|
|
123
|
+
RBLNKandinskyV22InpaintCombinedPipelineConfig,
|
|
124
|
+
RBLNKandinskyV22InpaintPipelineConfig,
|
|
125
|
+
RBLNKandinskyV22PipelineConfig,
|
|
126
|
+
RBLNKandinskyV22PriorPipelineConfig,
|
|
127
|
+
RBLNPriorTransformerConfig,
|
|
128
|
+
RBLNSD3Transformer2DModelConfig,
|
|
129
|
+
RBLNStableDiffusion3Img2ImgPipelineConfig,
|
|
130
|
+
RBLNStableDiffusion3InpaintPipelineConfig,
|
|
131
|
+
RBLNStableDiffusion3PipelineConfig,
|
|
132
|
+
RBLNStableDiffusionControlNetImg2ImgPipelineConfig,
|
|
133
|
+
RBLNStableDiffusionControlNetPipelineConfig,
|
|
134
|
+
RBLNStableDiffusionImg2ImgPipelineConfig,
|
|
135
|
+
RBLNStableDiffusionInpaintPipelineConfig,
|
|
136
|
+
RBLNStableDiffusionPipelineConfig,
|
|
137
|
+
RBLNStableDiffusionXLControlNetImg2ImgPipelineConfig,
|
|
138
|
+
RBLNStableDiffusionXLControlNetPipelineConfig,
|
|
139
|
+
RBLNStableDiffusionXLImg2ImgPipelineConfig,
|
|
140
|
+
RBLNStableDiffusionXLInpaintPipelineConfig,
|
|
141
|
+
RBLNStableDiffusionXLPipelineConfig,
|
|
142
|
+
RBLNStableVideoDiffusionPipelineConfig,
|
|
143
|
+
RBLNUNet2DConditionModelConfig,
|
|
144
|
+
RBLNUNetSpatioTemporalConditionModelConfig,
|
|
145
|
+
RBLNVQModelConfig,
|
|
146
|
+
)
|
|
147
|
+
from .modeling_diffusers import RBLNDiffusionMixin
|
|
148
|
+
from .models import (
|
|
149
|
+
RBLNAutoencoderKL,
|
|
150
|
+
RBLNAutoencoderKLCosmos,
|
|
151
|
+
RBLNAutoencoderKLTemporalDecoder,
|
|
152
|
+
RBLNControlNetModel,
|
|
153
|
+
RBLNCosmosTransformer3DModel,
|
|
154
|
+
RBLNPriorTransformer,
|
|
155
|
+
RBLNSD3Transformer2DModel,
|
|
156
|
+
RBLNUNet2DConditionModel,
|
|
157
|
+
RBLNUNetSpatioTemporalConditionModel,
|
|
158
|
+
RBLNVQModel,
|
|
159
|
+
)
|
|
160
|
+
from .pipelines import (
|
|
161
|
+
RBLNAutoPipelineForImage2Image,
|
|
162
|
+
RBLNAutoPipelineForInpainting,
|
|
163
|
+
RBLNAutoPipelineForText2Image,
|
|
164
|
+
RBLNCosmosSafetyChecker,
|
|
165
|
+
RBLNCosmosTextToWorldPipeline,
|
|
166
|
+
RBLNCosmosVideoToWorldPipeline,
|
|
167
|
+
RBLNKandinskyV22CombinedPipeline,
|
|
168
|
+
RBLNKandinskyV22Img2ImgCombinedPipeline,
|
|
169
|
+
RBLNKandinskyV22Img2ImgPipeline,
|
|
170
|
+
RBLNKandinskyV22InpaintCombinedPipeline,
|
|
171
|
+
RBLNKandinskyV22InpaintPipeline,
|
|
172
|
+
RBLNKandinskyV22Pipeline,
|
|
173
|
+
RBLNKandinskyV22PriorPipeline,
|
|
174
|
+
RBLNMultiControlNetModel,
|
|
175
|
+
RBLNStableDiffusion3Img2ImgPipeline,
|
|
176
|
+
RBLNStableDiffusion3InpaintPipeline,
|
|
177
|
+
RBLNStableDiffusion3Pipeline,
|
|
178
|
+
RBLNStableDiffusionControlNetImg2ImgPipeline,
|
|
179
|
+
RBLNStableDiffusionControlNetPipeline,
|
|
180
|
+
RBLNStableDiffusionImg2ImgPipeline,
|
|
181
|
+
RBLNStableDiffusionInpaintPipeline,
|
|
182
|
+
RBLNStableDiffusionPipeline,
|
|
183
|
+
RBLNStableDiffusionXLControlNetImg2ImgPipeline,
|
|
184
|
+
RBLNStableDiffusionXLControlNetPipeline,
|
|
185
|
+
RBLNStableDiffusionXLImg2ImgPipeline,
|
|
186
|
+
RBLNStableDiffusionXLInpaintPipeline,
|
|
187
|
+
RBLNStableDiffusionXLPipeline,
|
|
188
|
+
RBLNStableVideoDiffusionPipeline,
|
|
189
|
+
)
|
|
190
|
+
else:
|
|
191
|
+
import sys
|
|
192
|
+
|
|
193
|
+
sys.modules[__name__] = _LazyModule(
|
|
194
|
+
__name__,
|
|
195
|
+
globals()["__file__"],
|
|
196
|
+
_import_structure,
|
|
197
|
+
module_spec=__spec__,
|
|
198
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from .models import (
|
|
2
|
+
RBLNAutoencoderKLConfig,
|
|
3
|
+
RBLNAutoencoderKLCosmosConfig,
|
|
4
|
+
RBLNAutoencoderKLTemporalDecoderConfig,
|
|
5
|
+
RBLNControlNetModelConfig,
|
|
6
|
+
RBLNCosmosTransformer3DModelConfig,
|
|
7
|
+
RBLNPriorTransformerConfig,
|
|
8
|
+
RBLNSD3Transformer2DModelConfig,
|
|
9
|
+
RBLNUNet2DConditionModelConfig,
|
|
10
|
+
RBLNUNetSpatioTemporalConditionModelConfig,
|
|
11
|
+
RBLNVQModelConfig,
|
|
12
|
+
)
|
|
13
|
+
from .pipelines import (
|
|
14
|
+
RBLNCosmosTextToWorldPipelineConfig,
|
|
15
|
+
RBLNCosmosVideoToWorldPipelineConfig,
|
|
16
|
+
RBLNKandinskyV22CombinedPipelineConfig,
|
|
17
|
+
RBLNKandinskyV22Img2ImgCombinedPipelineConfig,
|
|
18
|
+
RBLNKandinskyV22Img2ImgPipelineConfig,
|
|
19
|
+
RBLNKandinskyV22InpaintCombinedPipelineConfig,
|
|
20
|
+
RBLNKandinskyV22InpaintPipelineConfig,
|
|
21
|
+
RBLNKandinskyV22PipelineConfig,
|
|
22
|
+
RBLNKandinskyV22PriorPipelineConfig,
|
|
23
|
+
RBLNStableDiffusion3Img2ImgPipelineConfig,
|
|
24
|
+
RBLNStableDiffusion3InpaintPipelineConfig,
|
|
25
|
+
RBLNStableDiffusion3PipelineConfig,
|
|
26
|
+
RBLNStableDiffusionControlNetImg2ImgPipelineConfig,
|
|
27
|
+
RBLNStableDiffusionControlNetPipelineConfig,
|
|
28
|
+
RBLNStableDiffusionImg2ImgPipelineConfig,
|
|
29
|
+
RBLNStableDiffusionInpaintPipelineConfig,
|
|
30
|
+
RBLNStableDiffusionPipelineConfig,
|
|
31
|
+
RBLNStableDiffusionXLControlNetImg2ImgPipelineConfig,
|
|
32
|
+
RBLNStableDiffusionXLControlNetPipelineConfig,
|
|
33
|
+
RBLNStableDiffusionXLImg2ImgPipelineConfig,
|
|
34
|
+
RBLNStableDiffusionXLInpaintPipelineConfig,
|
|
35
|
+
RBLNStableDiffusionXLPipelineConfig,
|
|
36
|
+
RBLNStableVideoDiffusionPipelineConfig,
|
|
37
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from .configuration_autoencoder_kl import RBLNAutoencoderKLConfig
|
|
2
|
+
from .configuration_autoencoder_kl_cosmos import RBLNAutoencoderKLCosmosConfig
|
|
3
|
+
from .configuration_autoencoder_kl_temporal_decoder import RBLNAutoencoderKLTemporalDecoderConfig
|
|
4
|
+
from .configuration_controlnet import RBLNControlNetModelConfig
|
|
5
|
+
from .configuration_prior_transformer import RBLNPriorTransformerConfig
|
|
6
|
+
from .configuration_transformer_cosmos import RBLNCosmosTransformer3DModelConfig
|
|
7
|
+
from .configuration_transformer_sd3 import RBLNSD3Transformer2DModelConfig
|
|
8
|
+
from .configuration_unet_2d_condition import RBLNUNet2DConditionModelConfig
|
|
9
|
+
from .configuration_unet_spatio_temporal_condition import RBLNUNetSpatioTemporalConditionModelConfig
|
|
10
|
+
from .configuration_vq_model import RBLNVQModelConfig
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Optional, Tuple
|
|
16
|
+
|
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RBLNAutoencoderKLConfig(RBLNModelConfig):
|
|
21
|
+
"""
|
|
22
|
+
Configuration class for RBLN Variational Autoencoder (VAE) models.
|
|
23
|
+
|
|
24
|
+
This class inherits from RBLNModelConfig and provides specific configuration options
|
|
25
|
+
for VAE models used in diffusion-based image generation.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
batch_size: Optional[int] = None,
|
|
31
|
+
sample_size: Optional[Tuple[int, int]] = None,
|
|
32
|
+
uses_encoder: Optional[bool] = None,
|
|
33
|
+
vae_scale_factor: Optional[float] = None, # TODO: rename to scaling_factor
|
|
34
|
+
in_channels: Optional[int] = None,
|
|
35
|
+
latent_channels: Optional[int] = None,
|
|
36
|
+
**kwargs: Any,
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Args:
|
|
40
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
|
41
|
+
sample_size (Optional[Tuple[int, int]]): The spatial dimensions (height, width) of the input/output images.
|
|
42
|
+
If an integer is provided, it's used for both height and width.
|
|
43
|
+
uses_encoder (Optional[bool]): Whether to include the encoder part of the VAE in the model.
|
|
44
|
+
When False, only the decoder is used (for latent-to-image conversion).
|
|
45
|
+
vae_scale_factor (Optional[float]): The scaling factor between pixel space and latent space.
|
|
46
|
+
Determines how much smaller the latent representations are compared to the original images.
|
|
47
|
+
in_channels (Optional[int]): Number of input channels for the model.
|
|
48
|
+
latent_channels (Optional[int]): Number of channels in the latent space.
|
|
49
|
+
kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
ValueError: If batch_size is not a positive integer.
|
|
53
|
+
"""
|
|
54
|
+
super().__init__(**kwargs)
|
|
55
|
+
self.batch_size = batch_size or 1
|
|
56
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
|
57
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
|
58
|
+
|
|
59
|
+
self.uses_encoder = uses_encoder
|
|
60
|
+
self.vae_scale_factor = vae_scale_factor
|
|
61
|
+
self.in_channels = in_channels
|
|
62
|
+
self.latent_channels = latent_channels
|
|
63
|
+
self.sample_size = sample_size
|
|
64
|
+
if isinstance(sample_size, int):
|
|
65
|
+
self.sample_size = (sample_size, sample_size)
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def image_size(self):
|
|
69
|
+
return self.sample_size
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def latent_sample_size(self):
|
|
73
|
+
return (self.image_size[0] // self.vae_scale_factor, self.image_size[1] // self.vae_scale_factor)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, Optional
|
|
16
|
+
|
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
|
18
|
+
from ....utils.logging import get_logger
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
logger = get_logger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class RBLNAutoencoderKLCosmosConfig(RBLNModelConfig):
|
|
25
|
+
"""Configuration class for RBLN Cosmos Variational Autoencoder (VAE) models."""
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
batch_size: Optional[int] = None,
|
|
30
|
+
uses_encoder: Optional[bool] = None,
|
|
31
|
+
num_frames: Optional[int] = None,
|
|
32
|
+
height: Optional[int] = None,
|
|
33
|
+
width: Optional[int] = None,
|
|
34
|
+
num_channels_latents: Optional[int] = None,
|
|
35
|
+
vae_scale_factor_temporal: Optional[int] = None,
|
|
36
|
+
vae_scale_factor_spatial: Optional[int] = None,
|
|
37
|
+
use_slicing: Optional[bool] = None,
|
|
38
|
+
**kwargs: Dict[str, Any],
|
|
39
|
+
):
|
|
40
|
+
"""
|
|
41
|
+
Args:
|
|
42
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
|
43
|
+
uses_encoder (Optional[bool]): Whether to include the encoder part of the VAE in the model.
|
|
44
|
+
When False, only the decoder is used (for latent-to-video conversion).
|
|
45
|
+
num_frames (Optional[int]): The number of frames in the generated video. Defaults to 121.
|
|
46
|
+
height (Optional[int]): The height in pixels of the generated video. Defaults to 704.
|
|
47
|
+
width (Optional[int]): The width in pixels of the generated video. Defaults to 1280.
|
|
48
|
+
num_channels_latents (Optional[int]): The number of channels in latent space.
|
|
49
|
+
vae_scale_factor_temporal (Optional[int]): The scaling factor between time space and latent space.
|
|
50
|
+
Determines how much shorter the latent representations are compared to the original videos.
|
|
51
|
+
vae_scale_factor_spatial (Optional[int]): The scaling factor between pixel space and latent space.
|
|
52
|
+
Determines how much smaller the latent representations are compared to the original videos.
|
|
53
|
+
use_slicing (Optional[bool]): Enable sliced VAE encoding and decoding.
|
|
54
|
+
If True, the VAE will split the input tensor in slices to compute encoding or decoding in several steps.
|
|
55
|
+
kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
|
56
|
+
|
|
57
|
+
Raises:
|
|
58
|
+
ValueError: If batch_size is not a positive integer.
|
|
59
|
+
"""
|
|
60
|
+
super().__init__(**kwargs)
|
|
61
|
+
# Since the Cosmos VAE Decoder already requires approximately 7.9 GiB of memory,
|
|
62
|
+
# Optimum-rbln cannot execute this model on RBLN-CA12 when the batch size > 1.
|
|
63
|
+
# However, the Cosmos VAE Decoder propose batch slicing when the batch size is greater than 1,
|
|
64
|
+
# Optimum-rbln utilize this method by compiling with batch_size=1 to enable batch slicing.
|
|
65
|
+
self.batch_size = batch_size or 1
|
|
66
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
|
67
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
|
68
|
+
elif self.batch_size > 1:
|
|
69
|
+
logger.warning("The batch size of Cosmos VAE Decoder will be explicitly 1 for memory efficiency.")
|
|
70
|
+
self.batch_size = 1
|
|
71
|
+
|
|
72
|
+
self.uses_encoder = uses_encoder
|
|
73
|
+
self.num_frames = num_frames or 121
|
|
74
|
+
self.height = height or 704
|
|
75
|
+
self.width = width or 1280
|
|
76
|
+
|
|
77
|
+
self.num_channels_latents = num_channels_latents
|
|
78
|
+
self.vae_scale_factor_temporal = vae_scale_factor_temporal
|
|
79
|
+
self.vae_scale_factor_spatial = vae_scale_factor_spatial
|
|
80
|
+
self.use_slicing = use_slicing or False
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def image_size(self):
|
|
84
|
+
return (self.height, self.width)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Optional, Tuple
|
|
16
|
+
|
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RBLNAutoencoderKLTemporalDecoderConfig(RBLNModelConfig):
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
batch_size: Optional[int] = None,
|
|
24
|
+
sample_size: Optional[Tuple[int, int]] = None,
|
|
25
|
+
uses_encoder: Optional[bool] = None,
|
|
26
|
+
num_frames: Optional[int] = None,
|
|
27
|
+
decode_chunk_size: Optional[int] = None,
|
|
28
|
+
vae_scale_factor: Optional[float] = None,
|
|
29
|
+
**kwargs: Any,
|
|
30
|
+
):
|
|
31
|
+
"""
|
|
32
|
+
Args:
|
|
33
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
|
34
|
+
sample_size (Optional[Tuple[int, int]]): The spatial dimensions (height, width) of the input/output images.
|
|
35
|
+
If an integer is provided, it's used for both height and width.
|
|
36
|
+
uses_encoder (Optional[bool]): Whether to include the encoder part of the VAE in the model.
|
|
37
|
+
When False, only the decoder is used (for latent-to-image conversion).
|
|
38
|
+
num_frames (Optional[int]): The number of frames in the generated video.
|
|
39
|
+
decode_chunk_size (Optional[int]): The number of frames to decode at once during VAE decoding.
|
|
40
|
+
Useful for managing memory usage during video generation.
|
|
41
|
+
vae_scale_factor (Optional[float]): The scaling factor between pixel space and latent space.
|
|
42
|
+
Determines how much smaller the latent representations are compared to the original images.
|
|
43
|
+
kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
|
44
|
+
|
|
45
|
+
Raises:
|
|
46
|
+
ValueError: If batch_size is not a positive integer.
|
|
47
|
+
"""
|
|
48
|
+
super().__init__(**kwargs)
|
|
49
|
+
self.batch_size = batch_size or 1
|
|
50
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
|
51
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
|
52
|
+
|
|
53
|
+
self.uses_encoder = uses_encoder
|
|
54
|
+
self.num_frames = num_frames
|
|
55
|
+
self.decode_chunk_size = decode_chunk_size
|
|
56
|
+
self.vae_scale_factor = vae_scale_factor
|
|
57
|
+
self.sample_size = sample_size
|
|
58
|
+
if isinstance(sample_size, int):
|
|
59
|
+
self.sample_size = (sample_size, sample_size)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def image_size(self):
|
|
63
|
+
return self.sample_size
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def latent_sample_size(self):
|
|
67
|
+
return (self.image_size[0] // self.vae_scale_factor, self.image_size[1] // self.vae_scale_factor)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Optional, Tuple
|
|
16
|
+
|
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RBLNControlNetModelConfig(RBLNModelConfig):
|
|
21
|
+
"""Configuration class for RBLN ControlNet models."""
|
|
22
|
+
|
|
23
|
+
subclass_non_save_attributes = ["_batch_size_is_specified"]
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
batch_size: Optional[int] = None,
|
|
28
|
+
max_seq_len: Optional[int] = None,
|
|
29
|
+
unet_sample_size: Optional[Tuple[int, int]] = None,
|
|
30
|
+
vae_sample_size: Optional[Tuple[int, int]] = None,
|
|
31
|
+
text_model_hidden_size: Optional[int] = None,
|
|
32
|
+
**kwargs: Any,
|
|
33
|
+
):
|
|
34
|
+
"""
|
|
35
|
+
Args:
|
|
36
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
|
37
|
+
max_seq_len (Optional[int]): Maximum sequence length for text inputs when used
|
|
38
|
+
with cross-attention.
|
|
39
|
+
unet_sample_size (Optional[Tuple[int, int]]): The spatial dimensions (height, width)
|
|
40
|
+
of the UNet output samples.
|
|
41
|
+
vae_sample_size (Optional[Tuple[int, int]]): The spatial dimensions (height, width)
|
|
42
|
+
of the VAE input/output images.
|
|
43
|
+
text_model_hidden_size (Optional[int]): Hidden size of the text encoder model used
|
|
44
|
+
for conditioning.
|
|
45
|
+
kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
|
46
|
+
|
|
47
|
+
Raises:
|
|
48
|
+
ValueError: If batch_size is not a positive integer.
|
|
49
|
+
"""
|
|
50
|
+
super().__init__(**kwargs)
|
|
51
|
+
self._batch_size_is_specified = batch_size is not None
|
|
52
|
+
|
|
53
|
+
self.batch_size = batch_size or 1
|
|
54
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
|
55
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
|
56
|
+
|
|
57
|
+
self.max_seq_len = max_seq_len
|
|
58
|
+
self.unet_sample_size = unet_sample_size
|
|
59
|
+
self.vae_sample_size = vae_sample_size
|
|
60
|
+
self.text_model_hidden_size = text_model_hidden_size
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def batch_size_is_specified(self):
|
|
64
|
+
return self._batch_size_is_specified
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Optional
|
|
16
|
+
|
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RBLNPriorTransformerConfig(RBLNModelConfig):
|
|
21
|
+
"""
|
|
22
|
+
Configuration class for RBLN Prior Transformer models.
|
|
23
|
+
|
|
24
|
+
This class inherits from RBLNModelConfig and provides specific configuration options
|
|
25
|
+
for Transformer models used in diffusion models like Kandinsky V2.2.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
subclass_non_save_attributes = ["_batch_size_is_specified"]
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
batch_size: Optional[int] = None,
|
|
33
|
+
embedding_dim: Optional[int] = None,
|
|
34
|
+
num_embeddings: Optional[int] = None,
|
|
35
|
+
**kwargs: Any,
|
|
36
|
+
):
|
|
37
|
+
"""
|
|
38
|
+
Args:
|
|
39
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
|
40
|
+
embedding_dim (Optional[int]): Dimension of the embedding vectors in the model.
|
|
41
|
+
num_embeddings (Optional[int]): Number of discrete embeddings in the codebook.
|
|
42
|
+
kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
|
43
|
+
|
|
44
|
+
Raises:
|
|
45
|
+
ValueError: If batch_size is not a positive integer.
|
|
46
|
+
"""
|
|
47
|
+
super().__init__(**kwargs)
|
|
48
|
+
self._batch_size_is_specified = batch_size is not None
|
|
49
|
+
|
|
50
|
+
self.batch_size = batch_size or 1
|
|
51
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
|
52
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
|
53
|
+
|
|
54
|
+
self.embedding_dim = embedding_dim
|
|
55
|
+
self.num_embeddings = num_embeddings
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def batch_size_is_specified(self):
|
|
59
|
+
return self._batch_size_is_specified
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Any, Optional
|
|
16
|
+
|
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RBLNCosmosTransformer3DModelConfig(RBLNModelConfig):
|
|
21
|
+
"""
|
|
22
|
+
Configuration class for RBLN Cosmos Transformer models.
|
|
23
|
+
|
|
24
|
+
This class inherits from RBLNModelConfig and provides specific configuration options
|
|
25
|
+
for Transformer models used in diffusion models like Cosmos.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
batch_size: Optional[int] = None,
|
|
31
|
+
num_frames: Optional[int] = None,
|
|
32
|
+
height: Optional[int] = None,
|
|
33
|
+
width: Optional[int] = None,
|
|
34
|
+
fps: Optional[int] = None,
|
|
35
|
+
max_seq_len: Optional[int] = None,
|
|
36
|
+
embedding_dim: Optional[int] = None,
|
|
37
|
+
num_channels_latents: Optional[int] = None,
|
|
38
|
+
num_latent_frames: Optional[int] = None,
|
|
39
|
+
latent_height: Optional[int] = None,
|
|
40
|
+
latent_width: Optional[int] = None,
|
|
41
|
+
**kwargs: Any,
|
|
42
|
+
):
|
|
43
|
+
"""
|
|
44
|
+
Args:
|
|
45
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
|
46
|
+
num_frames (Optional[int]): The number of frames in the generated video. Defaults to 121.
|
|
47
|
+
height (Optional[int]): The height in pixels of the generated video. Defaults to 704.
|
|
48
|
+
width (Optional[int]): The width in pixels of the generated video. Defaults to 1280.
|
|
49
|
+
fps (Optional[int]): The frames per second of the generated video. Defaults to 30.
|
|
50
|
+
max_seq_len (Optional[int]): Maximum sequence length of prompt embeds.
|
|
51
|
+
embedding_dim (Optional[int]): Embedding vector dimension of prompt embeds.
|
|
52
|
+
num_channels_latents (Optional[int]): The number of channels in latent space.
|
|
53
|
+
latent_height (Optional[int]): The height in pixels in latent space.
|
|
54
|
+
latent_width (Optional[int]): The width in pixels in latent space.
|
|
55
|
+
kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
|
56
|
+
|
|
57
|
+
Raises:
|
|
58
|
+
ValueError: If batch_size is not a positive integer.
|
|
59
|
+
"""
|
|
60
|
+
if kwargs.get("timeout") is None:
|
|
61
|
+
kwargs["timeout"] = 80
|
|
62
|
+
|
|
63
|
+
super().__init__(**kwargs)
|
|
64
|
+
self.batch_size = batch_size or 1
|
|
65
|
+
self.num_frames = num_frames or 121
|
|
66
|
+
self.height = height or 704
|
|
67
|
+
self.width = width or 1280
|
|
68
|
+
self.fps = fps or 30
|
|
69
|
+
|
|
70
|
+
self.max_seq_len = max_seq_len
|
|
71
|
+
self.num_channels_latents = num_channels_latents
|
|
72
|
+
self.num_latent_frames = num_latent_frames
|
|
73
|
+
self.latent_height = latent_height
|
|
74
|
+
self.latent_width = latent_width
|
|
75
|
+
self.embedding_dim = embedding_dim
|
|
76
|
+
|
|
77
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
|
78
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|