optimum-rbln 0.8.1rc0__py3-none-any.whl → 0.8.2__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 +58 -9
- optimum/rbln/__version__.py +2 -2
- optimum/rbln/configuration_utils.py +24 -5
- optimum/rbln/diffusers/configurations/models/__init__.py +1 -1
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl.py +2 -2
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl_cosmos.py +5 -3
- optimum/rbln/diffusers/configurations/models/configuration_controlnet.py +2 -2
- optimum/rbln/diffusers/configurations/models/configuration_prior_transformer.py +2 -2
- optimum/rbln/diffusers/configurations/models/{configuration_cosmos_transformer.py → configuration_transformer_cosmos.py} +7 -2
- optimum/rbln/diffusers/configurations/models/configuration_transformer_sd3.py +2 -2
- optimum/rbln/diffusers/configurations/models/configuration_unet_2d_condition.py +2 -2
- optimum/rbln/diffusers/configurations/models/configuration_vq_model.py +2 -2
- optimum/rbln/diffusers/configurations/pipelines/configuration_controlnet.py +3 -3
- optimum/rbln/diffusers/configurations/pipelines/configuration_cosmos.py +10 -6
- optimum/rbln/diffusers/configurations/pipelines/configuration_kandinsky2_2.py +4 -4
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion.py +2 -2
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_3.py +2 -2
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_xl.py +2 -2
- optimum/rbln/diffusers/modeling_diffusers.py +4 -5
- optimum/rbln/diffusers/models/__init__.py +3 -13
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl.py +1 -0
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl_cosmos.py +1 -0
- optimum/rbln/diffusers/models/autoencoders/vq_model.py +1 -0
- optimum/rbln/diffusers/models/transformers/transformer_cosmos.py +1 -1
- optimum/rbln/diffusers/pipelines/__init__.py +1 -5
- optimum/rbln/diffusers/pipelines/cosmos/configuration_cosmos_guardrail.py +12 -4
- optimum/rbln/diffusers/pipelines/cosmos/cosmos_guardrail.py +4 -26
- optimum/rbln/diffusers/pipelines/cosmos/pipeline_cosmos_text2world.py +2 -2
- optimum/rbln/diffusers/pipelines/cosmos/pipeline_cosmos_video2world.py +2 -2
- optimum/rbln/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +1 -6
- optimum/rbln/modeling.py +4 -5
- optimum/rbln/modeling_base.py +18 -14
- optimum/rbln/ops/kv_cache_update.py +5 -0
- optimum/rbln/ops/linear.py +7 -0
- optimum/rbln/transformers/__init__.py +60 -0
- optimum/rbln/transformers/configuration_generic.py +4 -4
- optimum/rbln/transformers/modeling_attention_utils.py +252 -0
- optimum/rbln/transformers/modeling_generic.py +1 -4
- optimum/rbln/transformers/models/__init__.py +45 -30
- optimum/rbln/transformers/models/bart/bart_architecture.py +2 -7
- optimum/rbln/transformers/models/blip_2/configuration_blip_2.py +2 -2
- optimum/rbln/transformers/models/blip_2/modeling_blip_2.py +1 -5
- optimum/rbln/transformers/models/clip/configuration_clip.py +14 -3
- optimum/rbln/transformers/models/clip/modeling_clip.py +123 -28
- optimum/rbln/transformers/models/colpali/colpali_architecture.py +1 -4
- optimum/rbln/transformers/models/colpali/configuration_colpali.py +2 -2
- optimum/rbln/transformers/models/colpali/modeling_colpali.py +2 -10
- optimum/rbln/transformers/models/decoderonly/__init__.py +2 -2
- optimum/rbln/transformers/models/decoderonly/configuration_decoderonly.py +214 -45
- optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +323 -454
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +579 -362
- optimum/rbln/transformers/models/exaone/exaone_architecture.py +17 -42
- optimum/rbln/transformers/models/gemma/__init__.py +2 -2
- optimum/rbln/transformers/models/gemma/configuration_gemma.py +9 -1
- optimum/rbln/transformers/models/gemma/gemma_architecture.py +3 -44
- optimum/rbln/transformers/models/gemma/modeling_gemma.py +22 -1
- optimum/rbln/transformers/models/gemma3/configuration_gemma3.py +21 -9
- optimum/rbln/transformers/models/gemma3/gemma3_architecture.py +9 -63
- optimum/rbln/transformers/models/gemma3/modeling_gemma3.py +200 -292
- optimum/rbln/transformers/models/gpt2/__init__.py +2 -2
- optimum/rbln/transformers/models/gpt2/configuration_gpt2.py +31 -3
- optimum/rbln/transformers/models/gpt2/gpt2_architecture.py +19 -24
- optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +18 -1
- optimum/rbln/transformers/models/idefics3/configuration_idefics3.py +2 -2
- optimum/rbln/transformers/models/idefics3/modeling_idefics3.py +3 -9
- optimum/rbln/transformers/models/llama/__init__.py +2 -2
- optimum/rbln/transformers/models/llama/configuration_llama.py +9 -1
- optimum/rbln/transformers/models/llama/modeling_llama.py +22 -1
- optimum/rbln/transformers/models/llava/__init__.py +16 -0
- optimum/rbln/transformers/models/llava/configuration_llava.py +54 -0
- optimum/rbln/transformers/models/llava/modeling_llava.py +419 -0
- optimum/rbln/transformers/models/llava_next/configuration_llava_next.py +20 -3
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +6 -16
- optimum/rbln/transformers/models/midm/midm_architecture.py +14 -22
- optimum/rbln/transformers/models/mistral/__init__.py +2 -2
- optimum/rbln/transformers/models/mistral/configuration_mistral.py +9 -1
- optimum/rbln/transformers/models/mistral/mistral_architecture.py +1 -1
- optimum/rbln/transformers/models/mistral/modeling_mistral.py +26 -3
- optimum/rbln/transformers/models/opt/__init__.py +2 -2
- optimum/rbln/transformers/models/opt/configuration_opt.py +8 -1
- optimum/rbln/transformers/models/opt/modeling_opt.py +41 -1
- optimum/rbln/transformers/models/opt/opt_architecture.py +16 -25
- optimum/rbln/transformers/models/pegasus/__init__.py +17 -0
- optimum/rbln/transformers/models/pegasus/configuration_pegasus.py +34 -0
- optimum/rbln/transformers/models/pegasus/modeling_pegasus.py +69 -0
- optimum/rbln/transformers/models/pegasus/pegasus_architecture.py +161 -0
- optimum/rbln/transformers/models/phi/__init__.py +2 -2
- optimum/rbln/transformers/models/phi/configuration_phi.py +9 -1
- optimum/rbln/transformers/models/phi/modeling_phi.py +10 -1
- optimum/rbln/transformers/models/phi/phi_architecture.py +16 -22
- 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 +315 -0
- optimum/rbln/transformers/models/pixtral/pixtral_architecture.py +73 -0
- optimum/rbln/transformers/models/qwen2/__init__.py +2 -2
- optimum/rbln/transformers/models/qwen2/configuration_qwen2.py +9 -1
- optimum/rbln/transformers/models/qwen2/modeling_qwen2.py +27 -1
- optimum/rbln/transformers/models/qwen2_5_vl/configuration_qwen2_5_vl.py +3 -3
- optimum/rbln/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py +5 -15
- optimum/rbln/transformers/models/qwen2_5_vl/qwen2_5_vl_architecture.py +1 -4
- 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/seq2seq/configuration_seq2seq.py +2 -12
- optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +3 -1
- optimum/rbln/transformers/models/siglip/__init__.py +2 -6
- optimum/rbln/transformers/models/siglip/modeling_siglip.py +2 -2
- optimum/rbln/transformers/models/time_series_transformer/configuration_time_series_transformer.py +2 -2
- optimum/rbln/transformers/models/time_series_transformer/modeling_time_series_transformer.py +3 -5
- optimum/rbln/transformers/models/whisper/configuration_whisper.py +3 -12
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +8 -2
- optimum/rbln/transformers/models/xlm_roberta/__init__.py +2 -8
- optimum/rbln/utils/depreacate_utils.py +16 -0
- optimum/rbln/utils/hub.py +8 -47
- optimum/rbln/utils/runtime_utils.py +31 -5
- {optimum_rbln-0.8.1rc0.dist-info → optimum_rbln-0.8.2.dist-info}/METADATA +1 -1
- {optimum_rbln-0.8.1rc0.dist-info → optimum_rbln-0.8.2.dist-info}/RECORD +120 -103
- {optimum_rbln-0.8.1rc0.dist-info → optimum_rbln-0.8.2.dist-info}/WHEEL +0 -0
- {optimum_rbln-0.8.1rc0.dist-info → optimum_rbln-0.8.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,419 @@
|
|
|
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
|
+
import inspect
|
|
16
|
+
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, Union
|
|
17
|
+
|
|
18
|
+
import torch
|
|
19
|
+
from transformers import AutoModelForImageTextToText, LlavaForConditionalGeneration, PretrainedConfig, PreTrainedModel
|
|
20
|
+
from transformers.modeling_outputs import BaseModelOutputWithPooling
|
|
21
|
+
from transformers.models.llava.modeling_llava import LlavaCausalLMOutputWithPast
|
|
22
|
+
|
|
23
|
+
from ....configuration_utils import RBLNCompileConfig, RBLNModelConfig
|
|
24
|
+
from ....modeling import RBLNModel
|
|
25
|
+
from ....utils.logging import get_logger
|
|
26
|
+
from ..decoderonly.modeling_decoderonly import RBLNDecoderOnlyForCausalLMOutput
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
logger = get_logger(__name__)
|
|
30
|
+
|
|
31
|
+
if TYPE_CHECKING:
|
|
32
|
+
from transformers import AutoFeatureExtractor, AutoProcessor, AutoTokenizer, PretrainedConfig
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class LoopVisionTower:
|
|
36
|
+
def __init__(self, vision_tower: RBLNModel) -> None:
|
|
37
|
+
self.vision_tower = vision_tower
|
|
38
|
+
|
|
39
|
+
def forward(self, pixel_values, image_sizes: Optional[torch.Tensor] = None, **kwargs):
|
|
40
|
+
outputs = []
|
|
41
|
+
for i in range(pixel_values.shape[0]):
|
|
42
|
+
outputs.append(
|
|
43
|
+
self.vision_tower(
|
|
44
|
+
pixel_values[i : i + 1], image_sizes[i : i + 1] if image_sizes is not None else None, **kwargs
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
if hasattr(self.vision_tower.rbln_config, "max_image_size"):
|
|
49
|
+
last_hidden_states = [output.last_hidden_state for output in outputs]
|
|
50
|
+
last_hidden_states = torch.cat(last_hidden_states, dim=1)
|
|
51
|
+
hidden_states = tuple(
|
|
52
|
+
torch.cat(
|
|
53
|
+
[output.hidden_states[layer_idx] for output in outputs],
|
|
54
|
+
dim=1,
|
|
55
|
+
)
|
|
56
|
+
for layer_idx in range(len(outputs[0].hidden_states))
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
else:
|
|
60
|
+
last_hidden_states = [output.last_hidden_state for output in outputs]
|
|
61
|
+
last_hidden_states = torch.cat(last_hidden_states, dim=0)
|
|
62
|
+
hidden_states = [output.hidden_states for output in outputs]
|
|
63
|
+
hidden_states = tuple(
|
|
64
|
+
torch.cat(tuple((hidden_states[n][i] for n in range(pixel_values.shape[0]))), dim=0)
|
|
65
|
+
for i in range(len(hidden_states[0]))
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return BaseModelOutputWithPooling(
|
|
69
|
+
last_hidden_state=last_hidden_states,
|
|
70
|
+
hidden_states=hidden_states,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def __call__(self, *args: Any, **kwds: Any) -> Any:
|
|
74
|
+
return self.forward(*args, **kwds)
|
|
75
|
+
|
|
76
|
+
def __repr__(self) -> str:
|
|
77
|
+
return repr(self.vision_tower)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class LoopProjector:
|
|
81
|
+
def __init__(self, multi_modal_projector) -> None:
|
|
82
|
+
self.multi_modal_projector = multi_modal_projector
|
|
83
|
+
|
|
84
|
+
def forward(self, *args, **kwargs):
|
|
85
|
+
# Loop instead of batch
|
|
86
|
+
image_feature = args[0]
|
|
87
|
+
|
|
88
|
+
outputs = []
|
|
89
|
+
for i in range(image_feature.shape[0]):
|
|
90
|
+
outputs.append(self.multi_modal_projector(image_feature[i : i + 1]))
|
|
91
|
+
|
|
92
|
+
# FIXME:: This can be optimized using out= API of rbln runtime.
|
|
93
|
+
outputs = torch.cat(outputs, dim=0)
|
|
94
|
+
return outputs
|
|
95
|
+
|
|
96
|
+
def __call__(self, *args: Any, **kwds: Any) -> Any:
|
|
97
|
+
return self.forward(*args, **kwds)
|
|
98
|
+
|
|
99
|
+
def __repr__(self) -> str:
|
|
100
|
+
return repr(self.multi_modal_projector)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class RBLNLlavaForConditionalGeneration(RBLNModel):
|
|
104
|
+
"""
|
|
105
|
+
RBLNLlavaForConditionalGeneration is a multi-modal model that combines vision and language processing capabilities,
|
|
106
|
+
optimized for RBLN NPUs. It is designed for conditional generation tasks that involve both image and text inputs.
|
|
107
|
+
This model inherits from [`RBLNModel`]. Check the superclass documentation for the generic methods the library implements for all its models.
|
|
108
|
+
Important Note:
|
|
109
|
+
This model includes a Large Language Model (LLM) as a submodule. For optimal performance, it is highly recommended to use
|
|
110
|
+
tensor parallelism for the language model. This can be achieved by using the `rbln_config` parameter in the
|
|
111
|
+
`from_pretrained` method. Refer to the `from_pretrained` documentation and the RBLNLlavaForConditionalGeneration class for details.
|
|
112
|
+
Examples:
|
|
113
|
+
```python
|
|
114
|
+
from optimum.rbln import RBLNLlavaForConditionalGeneration
|
|
115
|
+
model = RBLNLlavaForConditionalGeneration.from_pretrained(
|
|
116
|
+
"llava-hf/llava-1.5-7b-hf",
|
|
117
|
+
export=True,
|
|
118
|
+
rbln_config={
|
|
119
|
+
"vision_tower": {"output_hidden_states": True},
|
|
120
|
+
"language_model": {
|
|
121
|
+
"tensor_parallel_size": 4,
|
|
122
|
+
"use_inputs_embeds": True, # In Llava, language model must use inputs_embeds as input.
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
)
|
|
126
|
+
model.save_pretrained("compiled-llava-1.5-7b-hf")
|
|
127
|
+
|
|
128
|
+
# Using a RBLNLlavaForConditionalGenerationConfig instance (recommended for type checking)
|
|
129
|
+
from optimum.rbln import RBLNLlavaForConditionalGenerationConfig
|
|
130
|
+
vision_config = RBLNCLIPVisionModelConfig(
|
|
131
|
+
batch_size=1,
|
|
132
|
+
output_hidden_states=True
|
|
133
|
+
)
|
|
134
|
+
language_model_config = RBLNLlamaForCausalLMConfig(
|
|
135
|
+
batch_size=1,
|
|
136
|
+
max_seq_len=4096,
|
|
137
|
+
use_inputs_embeds=True,
|
|
138
|
+
tensor_parallel_size=4
|
|
139
|
+
)
|
|
140
|
+
llava_config = RBLNLlavaForConditionalGenerationConfig(
|
|
141
|
+
batch_size=1,
|
|
142
|
+
vision_tower=vision_config,
|
|
143
|
+
language_model=language_model_config
|
|
144
|
+
)
|
|
145
|
+
model = RBLNLlavaForConditionalGeneration.from_pretrained(
|
|
146
|
+
"llava-hf/llava-1.5-7b-hf",
|
|
147
|
+
export=True,
|
|
148
|
+
rbln_config=llava_config
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
auto_model_class = AutoModelForImageTextToText
|
|
154
|
+
_rbln_submodules = [
|
|
155
|
+
{"name": "vision_tower"},
|
|
156
|
+
{"name": "language_model"},
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
def __getattr__(self, __name: str) -> Any:
|
|
160
|
+
def redirect(func):
|
|
161
|
+
return lambda *pargs, **kwargs: func(self, *pargs, **kwargs)
|
|
162
|
+
|
|
163
|
+
val = getattr(LlavaForConditionalGeneration, __name)
|
|
164
|
+
|
|
165
|
+
if isinstance(val, Callable) and "self" in set(inspect.signature(val).parameters):
|
|
166
|
+
return redirect(val)
|
|
167
|
+
return val
|
|
168
|
+
|
|
169
|
+
def can_generate(self):
|
|
170
|
+
return True
|
|
171
|
+
|
|
172
|
+
def __post_init__(self, **kwargs):
|
|
173
|
+
self.vision_tower = LoopVisionTower(self.rbln_submodules[0])
|
|
174
|
+
self.language_model = self.rbln_submodules[1]
|
|
175
|
+
self.multi_modal_projector = LoopProjector(self.model[0])
|
|
176
|
+
self.pad_token_id = self.config.pad_token_id if self.config.pad_token_id is not None else -1
|
|
177
|
+
return super().__post_init__(**kwargs)
|
|
178
|
+
|
|
179
|
+
def get_attn_impl(self) -> str:
|
|
180
|
+
return self.rbln_config.language_model.attn_impl
|
|
181
|
+
|
|
182
|
+
def get_kvcache_num_blocks(self) -> int:
|
|
183
|
+
return self.rbln_config.language_model.kvcache_num_blocks
|
|
184
|
+
|
|
185
|
+
def get_input_embeddings(self):
|
|
186
|
+
return self.language_model.get_input_embeddings()
|
|
187
|
+
|
|
188
|
+
@classmethod
|
|
189
|
+
def wrap_model_if_needed(cls, model: "PreTrainedModel", rbln_config: RBLNModelConfig):
|
|
190
|
+
return model.multi_modal_projector
|
|
191
|
+
|
|
192
|
+
@classmethod
|
|
193
|
+
def _update_rbln_config(
|
|
194
|
+
cls,
|
|
195
|
+
preprocessors: Optional[Union["AutoFeatureExtractor", "AutoProcessor", "AutoTokenizer"]],
|
|
196
|
+
model: Optional["PreTrainedModel"] = None,
|
|
197
|
+
model_config: Optional["PretrainedConfig"] = None,
|
|
198
|
+
rbln_config: Optional[RBLNModelConfig] = None,
|
|
199
|
+
) -> RBLNModelConfig:
|
|
200
|
+
# support for pixtral that needs padding
|
|
201
|
+
if hasattr(rbln_config.vision_tower, "max_image_size"):
|
|
202
|
+
num_positions = (
|
|
203
|
+
rbln_config.vision_tower.batch_size
|
|
204
|
+
* (rbln_config.vision_tower.max_image_size[0] // model_config.vision_config.patch_size)
|
|
205
|
+
* (rbln_config.vision_tower.max_image_size[1] // model_config.vision_config.patch_size)
|
|
206
|
+
)
|
|
207
|
+
selected_image_feature_dim = num_positions
|
|
208
|
+
|
|
209
|
+
else:
|
|
210
|
+
num_positions = (model_config.vision_config.image_size // model_config.vision_config.patch_size) ** 2 + 1
|
|
211
|
+
if model_config.vision_feature_select_strategy == "default":
|
|
212
|
+
selected_image_feature_dim = num_positions - 1
|
|
213
|
+
else:
|
|
214
|
+
selected_image_feature_dim = num_positions
|
|
215
|
+
|
|
216
|
+
input_info = [
|
|
217
|
+
(
|
|
218
|
+
"image_features",
|
|
219
|
+
[rbln_config.batch_size, selected_image_feature_dim, model_config.vision_config.hidden_size],
|
|
220
|
+
"float32",
|
|
221
|
+
)
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
rbln_compile_config = RBLNCompileConfig(input_info=input_info)
|
|
225
|
+
rbln_config.set_compile_cfgs([rbln_compile_config])
|
|
226
|
+
return rbln_config
|
|
227
|
+
|
|
228
|
+
def prepare_inputs_for_generation(
|
|
229
|
+
self,
|
|
230
|
+
input_ids,
|
|
231
|
+
inputs_embeds=None,
|
|
232
|
+
pixel_values=None,
|
|
233
|
+
attention_mask=None,
|
|
234
|
+
cache_position=None,
|
|
235
|
+
image_sizes=None,
|
|
236
|
+
generate_idx=None,
|
|
237
|
+
**kwargs,
|
|
238
|
+
):
|
|
239
|
+
is_prefill_phase = generate_idx is None
|
|
240
|
+
model_inputs = {}
|
|
241
|
+
|
|
242
|
+
if is_prefill_phase:
|
|
243
|
+
generate_idx = attention_mask.sum(dim=-1, keepdim=True).int()
|
|
244
|
+
cache_position = None
|
|
245
|
+
pixel_values = pixel_values
|
|
246
|
+
model_inputs.update({"image_sizes": image_sizes})
|
|
247
|
+
else:
|
|
248
|
+
if inputs_embeds is not None:
|
|
249
|
+
raise NotImplementedError("Specifying inputs_embeds in decoder phase is not supported.")
|
|
250
|
+
|
|
251
|
+
pixel_values = None
|
|
252
|
+
input_ids = input_ids[:, -1:]
|
|
253
|
+
cache_position = generate_idx
|
|
254
|
+
generate_idx = generate_idx + 1
|
|
255
|
+
model_inputs.update({"input_ids": input_ids})
|
|
256
|
+
|
|
257
|
+
if inputs_embeds is not None:
|
|
258
|
+
if self.rbln_config.use_inputs_embeds:
|
|
259
|
+
model_inputs.update({"inputs_embeds": inputs_embeds})
|
|
260
|
+
else:
|
|
261
|
+
raise ValueError(
|
|
262
|
+
"The specifying inputs_embeds is only supported when using a compiled RBLN model with 'rbln_use_inputs_embeds' set to True."
|
|
263
|
+
)
|
|
264
|
+
else:
|
|
265
|
+
model_inputs.update({"input_ids": input_ids})
|
|
266
|
+
|
|
267
|
+
model_inputs.update(
|
|
268
|
+
{
|
|
269
|
+
"attention_mask": attention_mask,
|
|
270
|
+
"pixel_values": pixel_values,
|
|
271
|
+
"cache_position": cache_position,
|
|
272
|
+
"generate_idx": generate_idx,
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
return model_inputs
|
|
276
|
+
|
|
277
|
+
def _update_model_kwargs_for_generation(self, outputs, model_kwargs, is_encoder_decoder, **kwargs):
|
|
278
|
+
model_kwargs["generate_idx"] = outputs.generate_idx
|
|
279
|
+
return model_kwargs
|
|
280
|
+
|
|
281
|
+
def get_image_features(
|
|
282
|
+
self,
|
|
283
|
+
pixel_values: torch.FloatTensor,
|
|
284
|
+
vision_feature_layer: Union[int, List[int]],
|
|
285
|
+
vision_feature_select_strategy: str,
|
|
286
|
+
**kwargs,
|
|
287
|
+
):
|
|
288
|
+
if vision_feature_select_strategy not in ["default", "full"]:
|
|
289
|
+
raise ValueError(f"Unexpected select feature strategy: {self.config.vision_feature_select_strategy}")
|
|
290
|
+
|
|
291
|
+
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
|
292
|
+
image_outputs = self.vision_tower(pixel_values, output_hidden_states=True, **kwargs)
|
|
293
|
+
|
|
294
|
+
if isinstance(vision_feature_layer, int):
|
|
295
|
+
selected_image_feature = image_outputs.hidden_states[vision_feature_layer]
|
|
296
|
+
if vision_feature_select_strategy == "default":
|
|
297
|
+
selected_image_feature = selected_image_feature[:, 1:]
|
|
298
|
+
else:
|
|
299
|
+
hs_pool = [image_outputs.hidden_states[layer_idx] for layer_idx in vision_feature_layer]
|
|
300
|
+
if vision_feature_select_strategy == "default":
|
|
301
|
+
hs_pool = [hs[:, 1:] for hs in hs_pool]
|
|
302
|
+
selected_image_feature = torch.cat(hs_pool, dim=-1)
|
|
303
|
+
|
|
304
|
+
if hasattr(self.rbln_config.vision_tower, "max_image_size"):
|
|
305
|
+
num_real_patches = selected_image_feature.shape[1]
|
|
306
|
+
max_patches = (
|
|
307
|
+
(self.rbln_config.vision_tower.max_image_size[0] // self.config.vision_config.patch_size)
|
|
308
|
+
* (self.rbln_config.vision_tower.max_image_size[1] // self.config.vision_config.patch_size)
|
|
309
|
+
* pixel_values.shape[0]
|
|
310
|
+
)
|
|
311
|
+
num_padding_patches = max_patches - num_real_patches
|
|
312
|
+
|
|
313
|
+
padding_tensor = torch.zeros(
|
|
314
|
+
(selected_image_feature.shape[0], num_padding_patches, selected_image_feature.shape[2]),
|
|
315
|
+
dtype=selected_image_feature.dtype,
|
|
316
|
+
)
|
|
317
|
+
padded_feature = torch.cat([selected_image_feature, padding_tensor], dim=1)
|
|
318
|
+
padded_projected_feature = self.multi_modal_projector(padded_feature)
|
|
319
|
+
image_features = padded_projected_feature[:, :num_real_patches, :]
|
|
320
|
+
else:
|
|
321
|
+
image_features = self.multi_modal_projector(selected_image_feature)
|
|
322
|
+
|
|
323
|
+
return image_features
|
|
324
|
+
|
|
325
|
+
def _preprocess_prefill(
|
|
326
|
+
self,
|
|
327
|
+
input_ids: Optional[torch.LongTensor] = None,
|
|
328
|
+
pixel_values: Optional[torch.FloatTensor] = None,
|
|
329
|
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
|
330
|
+
vision_feature_layer: Optional[Union[int, List[int]]] = None,
|
|
331
|
+
vision_feature_select_strategy: Optional[str] = None,
|
|
332
|
+
return_dict: Optional[bool] = None,
|
|
333
|
+
image_sizes: Optional[torch.Tensor] = None,
|
|
334
|
+
**lm_kwargs,
|
|
335
|
+
):
|
|
336
|
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
|
337
|
+
vision_feature_layer = (
|
|
338
|
+
vision_feature_layer if vision_feature_layer is not None else self.config.vision_feature_layer
|
|
339
|
+
)
|
|
340
|
+
vision_feature_select_strategy = (
|
|
341
|
+
vision_feature_select_strategy
|
|
342
|
+
if vision_feature_select_strategy is not None
|
|
343
|
+
else self.config.vision_feature_select_strategy
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
|
347
|
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
|
348
|
+
|
|
349
|
+
if pixel_values is not None and inputs_embeds is not None:
|
|
350
|
+
raise ValueError(
|
|
351
|
+
"You cannot specify both pixel_values and inputs_embeds at the same time, and must specify either one"
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
if inputs_embeds is None:
|
|
355
|
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
|
356
|
+
|
|
357
|
+
if pixel_values is not None:
|
|
358
|
+
image_features = self.get_image_features(
|
|
359
|
+
pixel_values=pixel_values,
|
|
360
|
+
vision_feature_layer=vision_feature_layer,
|
|
361
|
+
vision_feature_select_strategy=vision_feature_select_strategy,
|
|
362
|
+
image_sizes=image_sizes,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
special_image_mask = (input_ids == self.config.image_token_index).unsqueeze(-1)
|
|
366
|
+
special_image_mask = special_image_mask.expand_as(inputs_embeds)
|
|
367
|
+
inputs_embeds = inputs_embeds.masked_scatter(special_image_mask, image_features)
|
|
368
|
+
|
|
369
|
+
return inputs_embeds
|
|
370
|
+
|
|
371
|
+
def forward(
|
|
372
|
+
self,
|
|
373
|
+
input_ids: Optional[torch.LongTensor] = None,
|
|
374
|
+
pixel_values: Optional[torch.FloatTensor] = None,
|
|
375
|
+
attention_mask: Optional[torch.Tensor] = None,
|
|
376
|
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
|
377
|
+
return_dict: Optional[bool] = None,
|
|
378
|
+
cache_position: Optional[torch.LongTensor] = None,
|
|
379
|
+
image_sizes: Optional[torch.Tensor] = None,
|
|
380
|
+
generate_idx: Optional[torch.Tensor] = None,
|
|
381
|
+
**kwargs,
|
|
382
|
+
) -> Union[Tuple, LlavaCausalLMOutputWithPast]:
|
|
383
|
+
# Prefill
|
|
384
|
+
if cache_position is None:
|
|
385
|
+
inputs_embeds = self._preprocess_prefill(
|
|
386
|
+
input_ids=input_ids, inputs_embeds=inputs_embeds, pixel_values=pixel_values, image_sizes=image_sizes
|
|
387
|
+
)
|
|
388
|
+
logits = []
|
|
389
|
+
inputs = inputs_embeds if inputs_embeds is not None else input_ids
|
|
390
|
+
batch_size = inputs.shape[0]
|
|
391
|
+
|
|
392
|
+
for b_idx in range(batch_size):
|
|
393
|
+
cache_position = torch.arange(0, generate_idx[b_idx].item(), dtype=torch.int32).unsqueeze(0)
|
|
394
|
+
output = self.language_model.prefill_decoder(
|
|
395
|
+
input_ids=inputs[b_idx : b_idx + 1] if inputs_embeds is None else None,
|
|
396
|
+
inputs_embeds=inputs[b_idx : b_idx + 1] if inputs_embeds is not None else None,
|
|
397
|
+
attention_mask=attention_mask[b_idx] if attention_mask is not None else None,
|
|
398
|
+
cache_position=cache_position,
|
|
399
|
+
batch_idx=b_idx,
|
|
400
|
+
)
|
|
401
|
+
logits.append(output.logits)
|
|
402
|
+
|
|
403
|
+
logits = torch.cat(logits, dim=0)
|
|
404
|
+
|
|
405
|
+
# Decoder
|
|
406
|
+
else:
|
|
407
|
+
logits = self.language_model.decoder(
|
|
408
|
+
input_ids=input_ids,
|
|
409
|
+
inputs_embeds=inputs_embeds,
|
|
410
|
+
cache_position=cache_position,
|
|
411
|
+
).logits
|
|
412
|
+
|
|
413
|
+
if not return_dict:
|
|
414
|
+
return logits, generate_idx
|
|
415
|
+
else:
|
|
416
|
+
return RBLNDecoderOnlyForCausalLMOutput(
|
|
417
|
+
logits=logits,
|
|
418
|
+
generate_idx=generate_idx,
|
|
419
|
+
)
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from typing import Any,
|
|
15
|
+
from typing import Any, Optional
|
|
16
16
|
|
|
17
17
|
from ....configuration_utils import RBLNModelConfig
|
|
18
|
+
from ....utils.logging import get_logger
|
|
19
|
+
from ...models.clip import RBLNCLIPVisionModelConfig
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
logger = get_logger(__name__)
|
|
18
23
|
|
|
19
24
|
|
|
20
25
|
class RBLNLlavaNextForConditionalGenerationConfig(RBLNModelConfig):
|
|
@@ -33,7 +38,7 @@ class RBLNLlavaNextForConditionalGenerationConfig(RBLNModelConfig):
|
|
|
33
38
|
batch_size: Optional[int] = None,
|
|
34
39
|
vision_tower: Optional[RBLNModelConfig] = None,
|
|
35
40
|
language_model: Optional[RBLNModelConfig] = None,
|
|
36
|
-
**kwargs:
|
|
41
|
+
**kwargs: Any,
|
|
37
42
|
):
|
|
38
43
|
"""
|
|
39
44
|
Args:
|
|
@@ -50,5 +55,17 @@ class RBLNLlavaNextForConditionalGenerationConfig(RBLNModelConfig):
|
|
|
50
55
|
if not isinstance(self.batch_size, int) or self.batch_size < 0:
|
|
51
56
|
raise ValueError(f"batch_size must be a positive integer, got {self.batch_size}")
|
|
52
57
|
|
|
53
|
-
self.vision_tower =
|
|
58
|
+
self.vision_tower = self.init_submodule_config(
|
|
59
|
+
RBLNCLIPVisionModelConfig,
|
|
60
|
+
vision_tower,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
if self.vision_tower.output_hidden_states is False:
|
|
64
|
+
raise ValueError(
|
|
65
|
+
f"LlavaNext requires output_hidden_states to be True, but found output_hidden_states={self.vision_tower.output_hidden_states}. "
|
|
66
|
+
f"Please compile again with the correct argument."
|
|
67
|
+
)
|
|
68
|
+
else:
|
|
69
|
+
self.vision_tower.output_hidden_states = True
|
|
70
|
+
|
|
54
71
|
self.language_model = language_model
|
|
@@ -18,29 +18,19 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Tuple, Union
|
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
import torch
|
|
21
|
-
from transformers import
|
|
22
|
-
AutoModelForVision2Seq,
|
|
23
|
-
LlavaNextForConditionalGeneration,
|
|
24
|
-
PretrainedConfig,
|
|
25
|
-
PreTrainedModel,
|
|
26
|
-
)
|
|
21
|
+
from transformers import AutoModelForVision2Seq, LlavaNextForConditionalGeneration, PretrainedConfig, PreTrainedModel
|
|
27
22
|
from transformers.modeling_outputs import BaseModelOutputWithPooling
|
|
28
23
|
|
|
29
24
|
from ....configuration_utils import RBLNCompileConfig, RBLNModelConfig
|
|
30
25
|
from ....modeling import RBLNModel
|
|
31
26
|
from ....utils.logging import get_logger
|
|
32
|
-
from ..decoderonly.modeling_decoderonly import
|
|
27
|
+
from ..decoderonly.modeling_decoderonly import RBLNDecoderOnlyForCausalLMOutput
|
|
33
28
|
|
|
34
29
|
|
|
35
30
|
logger = get_logger(__name__)
|
|
36
31
|
|
|
37
32
|
if TYPE_CHECKING:
|
|
38
|
-
from transformers import
|
|
39
|
-
AutoFeatureExtractor,
|
|
40
|
-
AutoProcessor,
|
|
41
|
-
AutoTokenizer,
|
|
42
|
-
PretrainedConfig,
|
|
43
|
-
)
|
|
33
|
+
from transformers import AutoFeatureExtractor, AutoProcessor, AutoTokenizer, PretrainedConfig
|
|
44
34
|
|
|
45
35
|
|
|
46
36
|
class LoopVisionTower:
|
|
@@ -258,7 +248,7 @@ class RBLNLlavaNextForConditionalGeneration(RBLNModel):
|
|
|
258
248
|
|
|
259
249
|
def _update_model_kwargs_for_generation(
|
|
260
250
|
self,
|
|
261
|
-
outputs:
|
|
251
|
+
outputs: RBLNDecoderOnlyForCausalLMOutput,
|
|
262
252
|
model_kwargs: Dict[str, Any],
|
|
263
253
|
**kwargs,
|
|
264
254
|
) -> Dict[str, Any]:
|
|
@@ -359,7 +349,7 @@ class RBLNLlavaNextForConditionalGeneration(RBLNModel):
|
|
|
359
349
|
generate_idx: Optional[torch.Tensor] = None,
|
|
360
350
|
batch_idx: Optional[int] = None,
|
|
361
351
|
**kwargs,
|
|
362
|
-
) -> Union[Tuple,
|
|
352
|
+
) -> Union[Tuple, RBLNDecoderOnlyForCausalLMOutput]:
|
|
363
353
|
vision_feature_layer = (
|
|
364
354
|
vision_feature_layer if vision_feature_layer is not None else self.config.vision_feature_layer
|
|
365
355
|
)
|
|
@@ -418,7 +408,7 @@ class RBLNLlavaNextForConditionalGeneration(RBLNModel):
|
|
|
418
408
|
cache_position=cache_position,
|
|
419
409
|
)
|
|
420
410
|
logits = output.logits
|
|
421
|
-
return
|
|
411
|
+
return RBLNDecoderOnlyForCausalLMOutput(logits=logits, generate_idx=generate_idx)
|
|
422
412
|
|
|
423
413
|
# Almost copied from : https://github.com/huggingface/transformers/blob/6b550462139655d488d4c663086a63e98713c6b9/src/transformers/models/llava_next/modeling_llava_next.py
|
|
424
414
|
def pack_image_features(self, image_features, image_sizes, vision_feature_select_strategy, image_newline=None):
|
|
@@ -20,7 +20,6 @@ import torch.nn as nn
|
|
|
20
20
|
|
|
21
21
|
from ..decoderonly.decoderonly_architecture import (
|
|
22
22
|
DecoderOnlyAttention,
|
|
23
|
-
DecoderOnlyForCausalLM,
|
|
24
23
|
DecoderOnlyLayer,
|
|
25
24
|
DecoderOnlyModel,
|
|
26
25
|
DecoderOnlyWrapper,
|
|
@@ -55,27 +54,20 @@ class MidmLMHeadModelWrapper(DecoderOnlyWrapper):
|
|
|
55
54
|
self.config.partial_rotary_factor = self.config.rotary_percentage
|
|
56
55
|
return super().get_rotary_emb(max_seq_len=max_seq_len)
|
|
57
56
|
|
|
58
|
-
def
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
causal_lm.transformer,
|
|
73
|
-
new_layers,
|
|
74
|
-
max_seq_len=max_seq_len,
|
|
75
|
-
sliding_window_layers=self.sliding_window_layers,
|
|
76
|
-
)
|
|
77
|
-
new_causal_lm = DecoderOnlyForCausalLM(causal_lm, new_model)
|
|
78
|
-
return new_causal_lm
|
|
57
|
+
def get_rbln_attn_class(self):
|
|
58
|
+
return MidmAttention
|
|
59
|
+
|
|
60
|
+
def get_rbln_layer_class(self):
|
|
61
|
+
return MidmLayer
|
|
62
|
+
|
|
63
|
+
def get_rbln_model_class(self):
|
|
64
|
+
return MidmModel
|
|
65
|
+
|
|
66
|
+
def get_model_layer(self, causal_lm: "MidmLMHeadModel"):
|
|
67
|
+
return causal_lm.transformer
|
|
68
|
+
|
|
69
|
+
def get_decoder_layers(self, causal_lm: "MidmLMHeadModel"):
|
|
70
|
+
return causal_lm.transformer.h
|
|
79
71
|
|
|
80
72
|
|
|
81
73
|
class MidmModel(DecoderOnlyModel):
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from .configuration_mistral import RBLNMistralForCausalLMConfig
|
|
16
|
-
from .modeling_mistral import RBLNMistralForCausalLM
|
|
15
|
+
from .configuration_mistral import RBLNMistralForCausalLMConfig, RBLNMistralModelConfig
|
|
16
|
+
from .modeling_mistral import RBLNMistralForCausalLM, RBLNMistralModel
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from ..decoderonly.configuration_decoderonly import RBLNDecoderOnlyModelForCausalLMConfig
|
|
15
|
+
from ..decoderonly.configuration_decoderonly import RBLNDecoderOnlyModelConfig, RBLNDecoderOnlyModelForCausalLMConfig
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class RBLNMistralForCausalLMConfig(RBLNDecoderOnlyModelForCausalLMConfig):
|
|
@@ -40,3 +40,11 @@ class RBLNMistralForCausalLMConfig(RBLNDecoderOnlyModelForCausalLMConfig):
|
|
|
40
40
|
)
|
|
41
41
|
```
|
|
42
42
|
"""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class RBLNMistralModelConfig(RBLNDecoderOnlyModelConfig):
|
|
46
|
+
"""
|
|
47
|
+
Configuration class for RBLN Mistral models.
|
|
48
|
+
|
|
49
|
+
This class is an alias of RBLNDecoderOnlyModelConfig.
|
|
50
|
+
"""
|
|
@@ -15,8 +15,12 @@
|
|
|
15
15
|
from transformers import PretrainedConfig
|
|
16
16
|
|
|
17
17
|
from ....utils import logging
|
|
18
|
-
from ...models.decoderonly import
|
|
19
|
-
|
|
18
|
+
from ...models.decoderonly import (
|
|
19
|
+
RBLNDecoderOnlyModel,
|
|
20
|
+
RBLNDecoderOnlyModelForCausalLM,
|
|
21
|
+
RBLNDecoderOnlyModelForCausalLMConfig,
|
|
22
|
+
)
|
|
23
|
+
from .mistral_architecture import MistralWrapper
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
logger = logging.get_logger(__name__)
|
|
@@ -79,7 +83,26 @@ class RBLNMistralForCausalLM(RBLNDecoderOnlyModelForCausalLM):
|
|
|
79
83
|
```
|
|
80
84
|
"""
|
|
81
85
|
|
|
82
|
-
_decoder_wrapper_cls =
|
|
86
|
+
_decoder_wrapper_cls = MistralWrapper
|
|
87
|
+
|
|
88
|
+
@classmethod
|
|
89
|
+
def _update_sliding_window_config(
|
|
90
|
+
cls, model_config: PretrainedConfig, rbln_config: RBLNDecoderOnlyModelForCausalLMConfig
|
|
91
|
+
):
|
|
92
|
+
rbln_config.cache_impl = "sliding_window"
|
|
93
|
+
rbln_config.sliding_window = model_config.sliding_window
|
|
94
|
+
rbln_config.sliding_window_layers = list(range(model_config.num_hidden_layers))
|
|
95
|
+
|
|
96
|
+
return rbln_config
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class RBLNMistralModel(RBLNDecoderOnlyModel):
|
|
100
|
+
"""
|
|
101
|
+
The Mistral Model transformer without a language modeling head.
|
|
102
|
+
This model inherits from [`RBLNDecoderOnlyModel`]. Check the superclass documentation for the generic methods the library implements for all its models.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
_decoder_wrapper_cls = MistralWrapper
|
|
83
106
|
|
|
84
107
|
@classmethod
|
|
85
108
|
def _update_sliding_window_config(
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from .configuration_opt import RBLNOPTForCausalLMConfig
|
|
16
|
-
from .modeling_opt import RBLNOPTForCausalLM
|
|
15
|
+
from .configuration_opt import RBLNOPTForCausalLMConfig, RBLNOPTModelConfig
|
|
16
|
+
from .modeling_opt import RBLNOPTForCausalLM, RBLNOPTModel
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from ..decoderonly.configuration_decoderonly import RBLNDecoderOnlyModelForCausalLMConfig
|
|
15
|
+
from ..decoderonly.configuration_decoderonly import RBLNDecoderOnlyModelConfig, RBLNDecoderOnlyModelForCausalLMConfig
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class RBLNOPTForCausalLMConfig(RBLNDecoderOnlyModelForCausalLMConfig):
|
|
@@ -20,3 +20,10 @@ class RBLNOPTForCausalLMConfig(RBLNDecoderOnlyModelForCausalLMConfig):
|
|
|
20
20
|
Configuration class for OPT causal language model.
|
|
21
21
|
Inherits from RBLNDecoderOnlyModelForCausalLMConfig with no additional parameters.
|
|
22
22
|
"""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RBLNOPTModelConfig(RBLNDecoderOnlyModelConfig):
|
|
26
|
+
"""
|
|
27
|
+
Configuration class for OPT model.
|
|
28
|
+
Inherits from RBLNDecoderOnlyModelConfig with no additional parameters.
|
|
29
|
+
"""
|