optimum-rbln 0.7.4a3__py3-none-any.whl → 0.7.4a5__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.
- optimum/rbln/__init__.py +156 -36
- optimum/rbln/__version__.py +1 -1
- optimum/rbln/configuration_utils.py +772 -0
- optimum/rbln/diffusers/__init__.py +56 -0
- optimum/rbln/diffusers/configurations/__init__.py +30 -0
- optimum/rbln/diffusers/configurations/models/__init__.py +6 -0
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl.py +66 -0
- optimum/rbln/diffusers/configurations/models/configuration_controlnet.py +54 -0
- optimum/rbln/diffusers/configurations/models/configuration_prior_transformer.py +44 -0
- optimum/rbln/diffusers/configurations/models/configuration_transformer_sd3.py +48 -0
- optimum/rbln/diffusers/configurations/models/configuration_unet_2d_condition.py +66 -0
- optimum/rbln/diffusers/configurations/models/configuration_vq_model.py +67 -0
- optimum/rbln/diffusers/configurations/pipelines/__init__.py +30 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_controlnet.py +221 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_kandinsky2_2.py +285 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion.py +118 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_3.py +143 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_xl.py +124 -0
- optimum/rbln/diffusers/modeling_diffusers.py +63 -122
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl.py +109 -128
- optimum/rbln/diffusers/models/autoencoders/vae.py +4 -6
- optimum/rbln/diffusers/models/autoencoders/vq_model.py +84 -85
- optimum/rbln/diffusers/models/controlnet.py +55 -70
- optimum/rbln/diffusers/models/transformers/prior_transformer.py +40 -77
- optimum/rbln/diffusers/models/transformers/transformer_sd3.py +43 -68
- optimum/rbln/diffusers/models/unets/unet_2d_condition.py +110 -113
- optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +3 -4
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +2 -1
- optimum/rbln/modeling.py +58 -39
- optimum/rbln/modeling_base.py +85 -80
- optimum/rbln/transformers/__init__.py +79 -8
- optimum/rbln/transformers/configuration_alias.py +49 -0
- optimum/rbln/transformers/configuration_generic.py +142 -0
- optimum/rbln/transformers/modeling_generic.py +193 -280
- optimum/rbln/transformers/models/__init__.py +96 -34
- optimum/rbln/transformers/models/auto/auto_factory.py +3 -3
- optimum/rbln/transformers/models/bart/__init__.py +1 -0
- optimum/rbln/transformers/models/bart/configuration_bart.py +24 -0
- optimum/rbln/transformers/models/bart/modeling_bart.py +10 -84
- optimum/rbln/transformers/models/bert/__init__.py +1 -0
- optimum/rbln/transformers/models/bert/configuration_bert.py +31 -0
- optimum/rbln/transformers/models/bert/modeling_bert.py +7 -80
- optimum/rbln/transformers/models/clip/__init__.py +6 -0
- optimum/rbln/transformers/models/clip/configuration_clip.py +79 -0
- optimum/rbln/transformers/models/clip/modeling_clip.py +72 -75
- optimum/rbln/transformers/models/decoderonly/__init__.py +1 -0
- optimum/rbln/transformers/models/decoderonly/configuration_decoderonly.py +90 -0
- optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +50 -43
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +114 -141
- optimum/rbln/transformers/models/dpt/__init__.py +1 -0
- optimum/rbln/transformers/models/dpt/configuration_dpt.py +19 -0
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +3 -76
- optimum/rbln/transformers/models/exaone/__init__.py +1 -0
- optimum/rbln/transformers/models/exaone/configuration_exaone.py +19 -0
- optimum/rbln/transformers/models/gemma/__init__.py +1 -0
- optimum/rbln/transformers/models/gemma/configuration_gemma.py +19 -0
- optimum/rbln/transformers/models/gpt2/__init__.py +1 -0
- optimum/rbln/transformers/models/gpt2/configuration_gpt2.py +19 -0
- optimum/rbln/transformers/models/llama/__init__.py +1 -0
- optimum/rbln/transformers/models/llama/configuration_llama.py +19 -0
- optimum/rbln/transformers/models/llava_next/__init__.py +1 -0
- optimum/rbln/transformers/models/llava_next/configuration_llava_next.py +46 -0
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +12 -23
- optimum/rbln/transformers/models/midm/__init__.py +1 -0
- optimum/rbln/transformers/models/midm/configuration_midm.py +19 -0
- optimum/rbln/transformers/models/mistral/__init__.py +1 -0
- optimum/rbln/transformers/models/mistral/configuration_mistral.py +19 -0
- optimum/rbln/transformers/models/phi/__init__.py +1 -0
- optimum/rbln/transformers/models/phi/configuration_phi.py +19 -0
- optimum/rbln/transformers/models/qwen2/__init__.py +1 -0
- optimum/rbln/transformers/models/qwen2/configuration_qwen2.py +19 -0
- optimum/rbln/transformers/models/seq2seq/__init__.py +1 -0
- optimum/rbln/transformers/models/seq2seq/configuration_seq2seq2.py +66 -0
- optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +80 -97
- optimum/rbln/transformers/models/t5/__init__.py +1 -0
- optimum/rbln/transformers/models/t5/configuration_t5.py +24 -0
- optimum/rbln/transformers/models/t5/modeling_t5.py +22 -150
- optimum/rbln/transformers/models/time_series_transformers/__init__.py +1 -0
- optimum/rbln/transformers/models/time_series_transformers/configuration_time_series_transformer.py +34 -0
- optimum/rbln/transformers/models/time_series_transformers/modeling_time_series_transformers.py +52 -54
- optimum/rbln/transformers/models/wav2vec2/__init__.py +1 -0
- optimum/rbln/transformers/models/wav2vec2/configuration_wav2vec.py +19 -0
- optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py +9 -72
- optimum/rbln/transformers/models/whisper/__init__.py +1 -0
- optimum/rbln/transformers/models/whisper/configuration_whisper.py +64 -0
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +57 -72
- optimum/rbln/transformers/models/xlm_roberta/__init__.py +1 -0
- optimum/rbln/transformers/models/xlm_roberta/configuration_xlm_roberta.py +19 -0
- optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +3 -83
- optimum/rbln/utils/submodule.py +26 -43
- {optimum_rbln-0.7.4a3.dist-info → optimum_rbln-0.7.4a5.dist-info}/METADATA +1 -1
- optimum_rbln-0.7.4a5.dist-info/RECORD +162 -0
- optimum/rbln/modeling_config.py +0 -310
- optimum_rbln-0.7.4a3.dist-info/RECORD +0 -126
- {optimum_rbln-0.7.4a3.dist-info → optimum_rbln-0.7.4a5.dist-info}/WHEEL +0 -0
- {optimum_rbln-0.7.4a3.dist-info → optimum_rbln-0.7.4a5.dist-info}/licenses/LICENSE +0 -0
@@ -23,6 +23,34 @@ ALL_IMPORTABLE_CLASSES.update(LOADABLE_CLASSES["optimum.rbln"])
|
|
23
23
|
|
24
24
|
|
25
25
|
_import_structure = {
|
26
|
+
"configurations": [
|
27
|
+
"RBLNAutoencoderKLConfig",
|
28
|
+
"RBLNControlNetModelConfig",
|
29
|
+
"RBLNKandinskyV22CombinedPipelineConfig",
|
30
|
+
"RBLNKandinskyV22Img2ImgCombinedPipelineConfig",
|
31
|
+
"RBLNKandinskyV22Img2ImgPipelineConfig",
|
32
|
+
"RBLNKandinskyV22InpaintCombinedPipelineConfig",
|
33
|
+
"RBLNKandinskyV22InpaintPipelineConfig",
|
34
|
+
"RBLNKandinskyV22PipelineConfig",
|
35
|
+
"RBLNKandinskyV22PriorPipelineConfig",
|
36
|
+
"RBLNPriorTransformerConfig",
|
37
|
+
"RBLNStableDiffusionControlNetPipelineConfig",
|
38
|
+
"RBLNStableDiffusionControlNetImg2ImgPipelineConfig",
|
39
|
+
"RBLNStableDiffusionImg2ImgPipelineConfig",
|
40
|
+
"RBLNStableDiffusionInpaintPipelineConfig",
|
41
|
+
"RBLNStableDiffusionPipelineConfig",
|
42
|
+
"RBLNStableDiffusionXLControlNetPipelineConfig",
|
43
|
+
"RBLNStableDiffusionXLControlNetImg2ImgPipelineConfig",
|
44
|
+
"RBLNStableDiffusionXLImg2ImgPipelineConfig",
|
45
|
+
"RBLNStableDiffusionXLInpaintPipelineConfig",
|
46
|
+
"RBLNStableDiffusionXLPipelineConfig",
|
47
|
+
"RBLNStableDiffusion3PipelineConfig",
|
48
|
+
"RBLNStableDiffusion3Img2ImgPipelineConfig",
|
49
|
+
"RBLNStableDiffusion3InpaintPipelineConfig",
|
50
|
+
"RBLNSD3Transformer2DModelConfig",
|
51
|
+
"RBLNUNet2DConditionModelConfig",
|
52
|
+
"RBLNVQModelConfig",
|
53
|
+
],
|
26
54
|
"pipelines": [
|
27
55
|
"RBLNKandinskyV22CombinedPipeline",
|
28
56
|
"RBLNKandinskyV22Img2ImgCombinedPipeline",
|
@@ -60,6 +88,34 @@ _import_structure = {
|
|
60
88
|
}
|
61
89
|
|
62
90
|
if TYPE_CHECKING:
|
91
|
+
from .configurations import (
|
92
|
+
RBLNAutoencoderKLConfig,
|
93
|
+
RBLNControlNetModelConfig,
|
94
|
+
RBLNKandinskyV22CombinedPipelineConfig,
|
95
|
+
RBLNKandinskyV22Img2ImgCombinedPipelineConfig,
|
96
|
+
RBLNKandinskyV22Img2ImgPipelineConfig,
|
97
|
+
RBLNKandinskyV22InpaintCombinedPipelineConfig,
|
98
|
+
RBLNKandinskyV22InpaintPipelineConfig,
|
99
|
+
RBLNKandinskyV22PipelineConfig,
|
100
|
+
RBLNKandinskyV22PriorPipelineConfig,
|
101
|
+
RBLNPriorTransformerConfig,
|
102
|
+
RBLNSD3Transformer2DModelConfig,
|
103
|
+
RBLNStableDiffusion3Img2ImgPipelineConfig,
|
104
|
+
RBLNStableDiffusion3InpaintPipelineConfig,
|
105
|
+
RBLNStableDiffusion3PipelineConfig,
|
106
|
+
RBLNStableDiffusionControlNetImg2ImgPipelineConfig,
|
107
|
+
RBLNStableDiffusionControlNetPipelineConfig,
|
108
|
+
RBLNStableDiffusionImg2ImgPipelineConfig,
|
109
|
+
RBLNStableDiffusionInpaintPipelineConfig,
|
110
|
+
RBLNStableDiffusionPipelineConfig,
|
111
|
+
RBLNStableDiffusionXLControlNetImg2ImgPipelineConfig,
|
112
|
+
RBLNStableDiffusionXLControlNetPipelineConfig,
|
113
|
+
RBLNStableDiffusionXLImg2ImgPipelineConfig,
|
114
|
+
RBLNStableDiffusionXLInpaintPipelineConfig,
|
115
|
+
RBLNStableDiffusionXLPipelineConfig,
|
116
|
+
RBLNUNet2DConditionModelConfig,
|
117
|
+
RBLNVQModelConfig,
|
118
|
+
)
|
63
119
|
from .modeling_diffusers import RBLNDiffusionMixin
|
64
120
|
from .models import (
|
65
121
|
RBLNAutoencoderKL,
|
@@ -0,0 +1,30 @@
|
|
1
|
+
from .models import (
|
2
|
+
RBLNAutoencoderKLConfig,
|
3
|
+
RBLNControlNetModelConfig,
|
4
|
+
RBLNPriorTransformerConfig,
|
5
|
+
RBLNSD3Transformer2DModelConfig,
|
6
|
+
RBLNUNet2DConditionModelConfig,
|
7
|
+
RBLNVQModelConfig,
|
8
|
+
)
|
9
|
+
from .pipelines import (
|
10
|
+
RBLNKandinskyV22CombinedPipelineConfig,
|
11
|
+
RBLNKandinskyV22Img2ImgCombinedPipelineConfig,
|
12
|
+
RBLNKandinskyV22Img2ImgPipelineConfig,
|
13
|
+
RBLNKandinskyV22InpaintCombinedPipelineConfig,
|
14
|
+
RBLNKandinskyV22InpaintPipelineConfig,
|
15
|
+
RBLNKandinskyV22PipelineConfig,
|
16
|
+
RBLNKandinskyV22PriorPipelineConfig,
|
17
|
+
RBLNStableDiffusion3Img2ImgPipelineConfig,
|
18
|
+
RBLNStableDiffusion3InpaintPipelineConfig,
|
19
|
+
RBLNStableDiffusion3PipelineConfig,
|
20
|
+
RBLNStableDiffusionControlNetImg2ImgPipelineConfig,
|
21
|
+
RBLNStableDiffusionControlNetPipelineConfig,
|
22
|
+
RBLNStableDiffusionImg2ImgPipelineConfig,
|
23
|
+
RBLNStableDiffusionInpaintPipelineConfig,
|
24
|
+
RBLNStableDiffusionPipelineConfig,
|
25
|
+
RBLNStableDiffusionXLControlNetImg2ImgPipelineConfig,
|
26
|
+
RBLNStableDiffusionXLControlNetPipelineConfig,
|
27
|
+
RBLNStableDiffusionXLImg2ImgPipelineConfig,
|
28
|
+
RBLNStableDiffusionXLInpaintPipelineConfig,
|
29
|
+
RBLNStableDiffusionXLPipelineConfig,
|
30
|
+
)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
from .configuration_autoencoder_kl import RBLNAutoencoderKLConfig
|
2
|
+
from .configuration_controlnet import RBLNControlNetModelConfig
|
3
|
+
from .configuration_prior_transformer import RBLNPriorTransformerConfig
|
4
|
+
from .configuration_transformer_sd3 import RBLNSD3Transformer2DModelConfig
|
5
|
+
from .configuration_unet_2d_condition import RBLNUNet2DConditionModelConfig
|
6
|
+
from .configuration_vq_model import RBLNVQModelConfig
|
@@ -0,0 +1,66 @@
|
|
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 Optional, Tuple
|
16
|
+
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
18
|
+
|
19
|
+
|
20
|
+
class RBLNAutoencoderKLConfig(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
|
+
vae_scale_factor: Optional[float] = None, # TODO: rename to scaling_factor
|
27
|
+
in_channels: Optional[int] = None,
|
28
|
+
latent_channels: Optional[int] = None,
|
29
|
+
**kwargs,
|
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
|
+
vae_scale_factor (Optional[float]): The scaling factor between pixel space and latent space.
|
39
|
+
Determines how much smaller the latent representations are compared to the original images.
|
40
|
+
in_channels (Optional[int]): Number of input channels for the model.
|
41
|
+
latent_channels (Optional[int]): Number of channels in the latent space.
|
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 = batch_size or 1
|
49
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
50
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
51
|
+
|
52
|
+
self.uses_encoder = uses_encoder
|
53
|
+
self.vae_scale_factor = vae_scale_factor
|
54
|
+
self.in_channels = in_channels
|
55
|
+
self.latent_channels = latent_channels
|
56
|
+
self.sample_size = sample_size
|
57
|
+
if isinstance(sample_size, int):
|
58
|
+
self.sample_size = (sample_size, sample_size)
|
59
|
+
|
60
|
+
@property
|
61
|
+
def image_size(self):
|
62
|
+
return self.sample_size
|
63
|
+
|
64
|
+
@property
|
65
|
+
def latent_sample_size(self):
|
66
|
+
return (self.image_size[0] // self.vae_scale_factor, self.image_size[1] // self.vae_scale_factor)
|
@@ -0,0 +1,54 @@
|
|
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 Optional, Tuple
|
16
|
+
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
18
|
+
|
19
|
+
|
20
|
+
class RBLNControlNetModelConfig(RBLNModelConfig):
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
batch_size: Optional[int] = None,
|
24
|
+
max_seq_len: Optional[int] = None,
|
25
|
+
unet_sample_size: Optional[Tuple[int, int]] = None,
|
26
|
+
vae_sample_size: Optional[Tuple[int, int]] = None,
|
27
|
+
text_model_hidden_size: Optional[int] = None,
|
28
|
+
**kwargs,
|
29
|
+
):
|
30
|
+
"""
|
31
|
+
Args:
|
32
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
33
|
+
max_seq_len (Optional[int]): Maximum sequence length for text inputs when used
|
34
|
+
with cross-attention.
|
35
|
+
unet_sample_size (Optional[Tuple[int, int]]): The spatial dimensions (height, width)
|
36
|
+
of the UNet output samples.
|
37
|
+
vae_sample_size (Optional[Tuple[int, int]]): The spatial dimensions (height, width)
|
38
|
+
of the VAE input/output images.
|
39
|
+
text_model_hidden_size (Optional[int]): Hidden size of the text encoder model used
|
40
|
+
for conditioning.
|
41
|
+
**kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
42
|
+
|
43
|
+
Raises:
|
44
|
+
ValueError: If batch_size is not a positive integer.
|
45
|
+
"""
|
46
|
+
super().__init__(**kwargs)
|
47
|
+
self.batch_size = batch_size or 1
|
48
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
49
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
50
|
+
|
51
|
+
self.max_seq_len = max_seq_len
|
52
|
+
self.unet_sample_size = unet_sample_size
|
53
|
+
self.vae_sample_size = vae_sample_size
|
54
|
+
self.text_model_hidden_size = text_model_hidden_size
|
@@ -0,0 +1,44 @@
|
|
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 Optional
|
16
|
+
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
18
|
+
|
19
|
+
|
20
|
+
class RBLNPriorTransformerConfig(RBLNModelConfig):
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
batch_size: Optional[int] = None,
|
24
|
+
embedding_dim: Optional[int] = None,
|
25
|
+
num_embeddings: Optional[int] = None,
|
26
|
+
**kwargs,
|
27
|
+
):
|
28
|
+
"""
|
29
|
+
Args:
|
30
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
31
|
+
embedding_dim (Optional[int]): Dimension of the embedding vectors in the model.
|
32
|
+
num_embeddings (Optional[int]): Number of discrete embeddings in the codebook.
|
33
|
+
**kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
34
|
+
|
35
|
+
Raises:
|
36
|
+
ValueError: If batch_size is not a positive integer.
|
37
|
+
"""
|
38
|
+
super().__init__(**kwargs)
|
39
|
+
self.batch_size = batch_size or 1
|
40
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
41
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
42
|
+
|
43
|
+
self.embedding_dim = embedding_dim
|
44
|
+
self.num_embeddings = num_embeddings
|
@@ -0,0 +1,48 @@
|
|
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 Optional, Tuple, Union
|
16
|
+
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
18
|
+
|
19
|
+
|
20
|
+
class RBLNSD3Transformer2DModelConfig(RBLNModelConfig):
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
batch_size: Optional[int] = None,
|
24
|
+
sample_size: Optional[Union[int, Tuple[int, int]]] = None,
|
25
|
+
prompt_embed_length: Optional[int] = None,
|
26
|
+
**kwargs,
|
27
|
+
):
|
28
|
+
"""
|
29
|
+
Args:
|
30
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
31
|
+
sample_size (Optional[Union[int, Tuple[int, int]]]): The spatial dimensions (height, width)
|
32
|
+
of the generated samples. If an integer is provided, it's used for both height and width.
|
33
|
+
prompt_embed_length (Optional[int]): The length of the embedded prompt vectors that
|
34
|
+
will be used to condition the transformer model.
|
35
|
+
**kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
36
|
+
|
37
|
+
Raises:
|
38
|
+
ValueError: If batch_size is not a positive integer.
|
39
|
+
"""
|
40
|
+
super().__init__(**kwargs)
|
41
|
+
self.batch_size = batch_size or 1
|
42
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
43
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
44
|
+
|
45
|
+
self.prompt_embed_length = prompt_embed_length
|
46
|
+
self.sample_size = sample_size
|
47
|
+
if isinstance(self.sample_size, int):
|
48
|
+
self.sample_size = (self.sample_size, self.sample_size)
|
@@ -0,0 +1,66 @@
|
|
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 Optional, Tuple
|
16
|
+
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
18
|
+
|
19
|
+
|
20
|
+
class RBLNUNet2DConditionModelConfig(RBLNModelConfig):
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
batch_size: Optional[int] = None,
|
24
|
+
sample_size: Optional[Tuple[int, int]] = None,
|
25
|
+
in_channels: Optional[int] = None,
|
26
|
+
cross_attention_dim: Optional[int] = None,
|
27
|
+
use_additional_residuals: Optional[bool] = None,
|
28
|
+
max_seq_len: Optional[int] = None,
|
29
|
+
in_features: Optional[int] = None,
|
30
|
+
text_model_hidden_size: Optional[int] = None,
|
31
|
+
image_model_hidden_size: Optional[int] = None,
|
32
|
+
**kwargs,
|
33
|
+
):
|
34
|
+
"""
|
35
|
+
Args:
|
36
|
+
batch_size (Optional[int]): The batch size for inference. Defaults to 1.
|
37
|
+
sample_size (Optional[Tuple[int, int]]): The spatial dimensions (height, width) of the generated samples.
|
38
|
+
If an integer is provided, it's used for both height and width.
|
39
|
+
in_channels (Optional[int]): Number of input channels for the UNet.
|
40
|
+
cross_attention_dim (Optional[int]): Dimension of the cross-attention features.
|
41
|
+
use_additional_residuals (Optional[bool]): Whether to use additional residual connections in the model.
|
42
|
+
max_seq_len (Optional[int]): Maximum sequence length for text inputs when used with cross-attention.
|
43
|
+
in_features (Optional[int]): Number of input features for the model.
|
44
|
+
text_model_hidden_size (Optional[int]): Hidden size of the text encoder model.
|
45
|
+
image_model_hidden_size (Optional[int]): Hidden size of the image encoder model.
|
46
|
+
**kwargs: Additional arguments passed to the parent RBLNModelConfig.
|
47
|
+
|
48
|
+
Raises:
|
49
|
+
ValueError: If batch_size is not a positive integer.
|
50
|
+
"""
|
51
|
+
super().__init__(**kwargs)
|
52
|
+
self.batch_size = batch_size or 1
|
53
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
54
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
55
|
+
|
56
|
+
self.in_channels = in_channels
|
57
|
+
self.cross_attention_dim = cross_attention_dim
|
58
|
+
self.use_additional_residuals = use_additional_residuals
|
59
|
+
self.max_seq_len = max_seq_len
|
60
|
+
self.in_features = in_features
|
61
|
+
self.text_model_hidden_size = text_model_hidden_size
|
62
|
+
self.image_model_hidden_size = image_model_hidden_size
|
63
|
+
|
64
|
+
self.sample_size = sample_size
|
65
|
+
if isinstance(sample_size, int):
|
66
|
+
self.sample_size = (sample_size, sample_size)
|
@@ -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 Optional, Tuple
|
16
|
+
|
17
|
+
from ....configuration_utils import RBLNModelConfig
|
18
|
+
|
19
|
+
|
20
|
+
class RBLNVQModelConfig(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
|
+
vqmodel_scale_factor: Optional[float] = None, # TODO: rename to scaling_factor
|
27
|
+
in_channels: Optional[int] = None,
|
28
|
+
latent_channels: Optional[int] = None,
|
29
|
+
**kwargs,
|
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
|
+
vqmodel_scale_factor (Optional[float]): The scaling factor between pixel space and latent space.
|
39
|
+
Determines the downsampling ratio between original images and latent representations.
|
40
|
+
in_channels (Optional[int]): Number of input channels for the model.
|
41
|
+
latent_channels (Optional[int]): Number of channels in the latent space.
|
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 = batch_size or 1
|
49
|
+
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
50
|
+
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
51
|
+
|
52
|
+
self.uses_encoder = uses_encoder
|
53
|
+
self.sample_size = sample_size
|
54
|
+
if isinstance(self.sample_size, int):
|
55
|
+
self.sample_size = (self.sample_size, self.sample_size)
|
56
|
+
|
57
|
+
self.vqmodel_scale_factor = vqmodel_scale_factor
|
58
|
+
self.in_channels = in_channels
|
59
|
+
self.latent_channels = latent_channels
|
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.vqmodel_scale_factor, self.image_size[1] // self.vqmodel_scale_factor)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
from .configuration_controlnet import (
|
2
|
+
RBLNStableDiffusionControlNetImg2ImgPipelineConfig,
|
3
|
+
RBLNStableDiffusionControlNetPipelineConfig,
|
4
|
+
RBLNStableDiffusionXLControlNetImg2ImgPipelineConfig,
|
5
|
+
RBLNStableDiffusionXLControlNetPipelineConfig,
|
6
|
+
)
|
7
|
+
from .configuration_kandinsky2_2 import (
|
8
|
+
RBLNKandinskyV22CombinedPipelineConfig,
|
9
|
+
RBLNKandinskyV22Img2ImgCombinedPipelineConfig,
|
10
|
+
RBLNKandinskyV22Img2ImgPipelineConfig,
|
11
|
+
RBLNKandinskyV22InpaintCombinedPipelineConfig,
|
12
|
+
RBLNKandinskyV22InpaintPipelineConfig,
|
13
|
+
RBLNKandinskyV22PipelineConfig,
|
14
|
+
RBLNKandinskyV22PriorPipelineConfig,
|
15
|
+
)
|
16
|
+
from .configuration_stable_diffusion import (
|
17
|
+
RBLNStableDiffusionImg2ImgPipelineConfig,
|
18
|
+
RBLNStableDiffusionInpaintPipelineConfig,
|
19
|
+
RBLNStableDiffusionPipelineConfig,
|
20
|
+
)
|
21
|
+
from .configuration_stable_diffusion_3 import (
|
22
|
+
RBLNStableDiffusion3Img2ImgPipelineConfig,
|
23
|
+
RBLNStableDiffusion3InpaintPipelineConfig,
|
24
|
+
RBLNStableDiffusion3PipelineConfig,
|
25
|
+
)
|
26
|
+
from .configuration_stable_diffusion_xl import (
|
27
|
+
RBLNStableDiffusionXLImg2ImgPipelineConfig,
|
28
|
+
RBLNStableDiffusionXLInpaintPipelineConfig,
|
29
|
+
RBLNStableDiffusionXLPipelineConfig,
|
30
|
+
)
|