optimum-rbln 0.9.2a4__py3-none-any.whl → 0.9.2a5__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/__version__.py +2 -2
- optimum/rbln/modeling.py +71 -1
- optimum/rbln/transformers/modeling_generic.py +23 -1
- optimum/rbln/transformers/models/blip_2/modeling_blip_2.py +65 -1
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +19 -4
- optimum/rbln/transformers/models/gemma3/modeling_gemma3.py +2 -1
- optimum/rbln/transformers/models/idefics3/modeling_idefics3.py +2 -4
- optimum/rbln/transformers/models/llava/modeling_llava.py +2 -1
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +2 -1
- optimum/rbln/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py +0 -9
- optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +3 -1
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +2 -1
- {optimum_rbln-0.9.2a4.dist-info → optimum_rbln-0.9.2a5.dist-info}/METADATA +5 -5
- {optimum_rbln-0.9.2a4.dist-info → optimum_rbln-0.9.2a5.dist-info}/RECORD +16 -16
- {optimum_rbln-0.9.2a4.dist-info → optimum_rbln-0.9.2a5.dist-info}/WHEEL +0 -0
- {optimum_rbln-0.9.2a4.dist-info → optimum_rbln-0.9.2a5.dist-info}/licenses/LICENSE +0 -0
optimum/rbln/__version__.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.9.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 9, 2, '
|
|
31
|
+
__version__ = version = '0.9.2a5'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 9, 2, 'a5')
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
optimum/rbln/modeling.py
CHANGED
|
@@ -34,6 +34,49 @@ if TYPE_CHECKING:
|
|
|
34
34
|
logger = get_logger(__name__)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
def _get_dtype(
|
|
38
|
+
cls,
|
|
39
|
+
dtype: Optional[Union[str, torch.dtype, dict]],
|
|
40
|
+
config: PretrainedConfig,
|
|
41
|
+
) -> tuple[PretrainedConfig, Optional[torch.dtype], Optional[torch.dtype]]:
|
|
42
|
+
dtype_orig = None
|
|
43
|
+
|
|
44
|
+
if dtype is not None:
|
|
45
|
+
if isinstance(dtype, str):
|
|
46
|
+
if dtype == "auto":
|
|
47
|
+
if hasattr(config, "dtype") and config.dtype is not None:
|
|
48
|
+
dtype = config.dtype
|
|
49
|
+
else:
|
|
50
|
+
dtype = torch.get_default_dtype()
|
|
51
|
+
elif hasattr(torch, dtype):
|
|
52
|
+
dtype = getattr(torch, dtype)
|
|
53
|
+
config.dtype = dtype
|
|
54
|
+
elif isinstance(dtype, torch.dtype):
|
|
55
|
+
config.dtype = dtype
|
|
56
|
+
elif isinstance(dtype, dict):
|
|
57
|
+
for key, curr_dtype in dtype.items():
|
|
58
|
+
if hasattr(config, key):
|
|
59
|
+
value = getattr(config, key)
|
|
60
|
+
curr_dtype = curr_dtype if not isinstance(curr_dtype, str) else getattr(torch, curr_dtype)
|
|
61
|
+
value.dtype = curr_dtype
|
|
62
|
+
# main torch dtype for modules that aren't part of any sub-config
|
|
63
|
+
dtype = dtype.get("")
|
|
64
|
+
dtype = dtype if not isinstance(dtype, str) else getattr(torch, dtype)
|
|
65
|
+
config.dtype = dtype
|
|
66
|
+
if dtype is None:
|
|
67
|
+
dtype = torch.float32
|
|
68
|
+
else:
|
|
69
|
+
raise ValueError(f"Invalid dtype: {dtype}")
|
|
70
|
+
|
|
71
|
+
dtype_orig = cls._set_default_dtype(dtype)
|
|
72
|
+
else:
|
|
73
|
+
# Use default dtype
|
|
74
|
+
default_dtype = torch.get_default_dtype()
|
|
75
|
+
config.dtype = default_dtype
|
|
76
|
+
|
|
77
|
+
return config, dtype, dtype_orig
|
|
78
|
+
|
|
79
|
+
|
|
37
80
|
class RBLNModel(RBLNBaseModel):
|
|
38
81
|
@classmethod
|
|
39
82
|
def update_kwargs(cls, kwargs):
|
|
@@ -206,10 +249,37 @@ class RBLNModel(RBLNBaseModel):
|
|
|
206
249
|
trust_remote_code: bool = False,
|
|
207
250
|
# Some rbln-config should be applied before loading torch module (i.e. quantized llm)
|
|
208
251
|
rbln_config: Optional[RBLNModelConfig] = None,
|
|
252
|
+
dtype: Optional[Union[str, torch.dtype, dict]] = None,
|
|
209
253
|
**kwargs,
|
|
210
254
|
) -> "PreTrainedModel":
|
|
211
255
|
kwargs = cls.update_kwargs(kwargs)
|
|
212
|
-
|
|
256
|
+
|
|
257
|
+
hf_class = cls.get_hf_class()
|
|
258
|
+
|
|
259
|
+
if dtype is not None:
|
|
260
|
+
config = hf_class.config_class.from_pretrained(
|
|
261
|
+
model_id,
|
|
262
|
+
subfolder=subfolder,
|
|
263
|
+
revision=revision,
|
|
264
|
+
cache_dir=cache_dir,
|
|
265
|
+
use_auth_token=use_auth_token,
|
|
266
|
+
local_files_only=local_files_only,
|
|
267
|
+
force_download=force_download,
|
|
268
|
+
trust_remote_code=trust_remote_code,
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
config, processed_dtype, dtype_orig = _get_dtype(
|
|
272
|
+
cls=hf_class,
|
|
273
|
+
dtype=dtype,
|
|
274
|
+
config=config,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
kwargs["torch_dtype"] = processed_dtype
|
|
278
|
+
|
|
279
|
+
if dtype_orig is not None:
|
|
280
|
+
hf_class._set_default_dtype(dtype_orig)
|
|
281
|
+
|
|
282
|
+
return hf_class.from_pretrained(
|
|
213
283
|
model_id,
|
|
214
284
|
subfolder=subfolder,
|
|
215
285
|
revision=revision,
|
|
@@ -23,6 +23,7 @@ different model architectures.
|
|
|
23
23
|
import inspect
|
|
24
24
|
from typing import TYPE_CHECKING, Optional, Union
|
|
25
25
|
|
|
26
|
+
from torch import nn
|
|
26
27
|
from transformers import (
|
|
27
28
|
AutoModel,
|
|
28
29
|
AutoModelForAudioClassification,
|
|
@@ -57,6 +58,28 @@ class RBLNTransformerEncoder(RBLNModel):
|
|
|
57
58
|
rbln_model_input_names = ["input_ids", "attention_mask", "token_type_ids"]
|
|
58
59
|
rbln_dtype = "int64"
|
|
59
60
|
|
|
61
|
+
@classmethod
|
|
62
|
+
def wrap_model_if_needed(cls, model: "PreTrainedModel", rbln_config: RBLNTransformerEncoderConfig) -> nn.Module:
|
|
63
|
+
class TransformerEncoderWrapper(nn.Module):
|
|
64
|
+
# Parameters to disable for RBLN compilation
|
|
65
|
+
DISABLED_PARAMS = {"return_dict", "use_cache"}
|
|
66
|
+
|
|
67
|
+
def __init__(self, model: "PreTrainedModel", rbln_config: RBLNTransformerEncoderConfig):
|
|
68
|
+
super().__init__()
|
|
69
|
+
self.model = model
|
|
70
|
+
self.rbln_config = rbln_config
|
|
71
|
+
self._forward_signature = inspect.signature(model.forward)
|
|
72
|
+
|
|
73
|
+
def forward(self, *args, **kwargs):
|
|
74
|
+
# Disable parameters that are not compatible with RBLN compilation
|
|
75
|
+
for param_name in self.DISABLED_PARAMS:
|
|
76
|
+
if param_name in self._forward_signature.parameters:
|
|
77
|
+
kwargs[param_name] = False
|
|
78
|
+
|
|
79
|
+
return self.model(*args, **kwargs)
|
|
80
|
+
|
|
81
|
+
return TransformerEncoderWrapper(model, rbln_config).eval()
|
|
82
|
+
|
|
60
83
|
@classmethod
|
|
61
84
|
def _update_rbln_config(
|
|
62
85
|
cls,
|
|
@@ -208,7 +231,6 @@ class RBLNModelForQuestionAnswering(RBLNTransformerEncoder):
|
|
|
208
231
|
|
|
209
232
|
def _prepare_output(self, output, return_dict):
|
|
210
233
|
# Prepare QuestionAnswering specific output format.
|
|
211
|
-
|
|
212
234
|
start_logits, end_logits = output
|
|
213
235
|
|
|
214
236
|
if not return_dict:
|
|
@@ -31,6 +31,7 @@ from transformers.utils import logging
|
|
|
31
31
|
from ....configuration_utils import RBLNCompileConfig, RBLNModelConfig
|
|
32
32
|
from ....modeling import RBLNModel
|
|
33
33
|
from ...utils.rbln_runtime_wrapper import LoopProcessor
|
|
34
|
+
from ..decoderonly.generation_decoderonly import RBLNDecoderOnlyGenerationMixin
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
logger = logging.get_logger(__name__)
|
|
@@ -265,7 +266,7 @@ class RBLNBlip2QFormerModel(RBLNModel):
|
|
|
265
266
|
)
|
|
266
267
|
|
|
267
268
|
|
|
268
|
-
class RBLNBlip2ForConditionalGeneration(RBLNModel):
|
|
269
|
+
class RBLNBlip2ForConditionalGeneration(RBLNModel, RBLNDecoderOnlyGenerationMixin):
|
|
269
270
|
"""
|
|
270
271
|
RBLNBlip2ForConditionalGeneration is a multi-modal model that integrates vision and language processing capabilities,
|
|
271
272
|
optimized for RBLN NPUs. It is designed for conditional generation tasks that involve both image and text inputs.
|
|
@@ -433,3 +434,66 @@ class RBLNBlip2ForConditionalGeneration(RBLNModel):
|
|
|
433
434
|
)
|
|
434
435
|
|
|
435
436
|
return inputs_embeds
|
|
437
|
+
|
|
438
|
+
@torch.no_grad()
|
|
439
|
+
def generate(
|
|
440
|
+
self,
|
|
441
|
+
pixel_values: torch.FloatTensor,
|
|
442
|
+
input_ids: Optional[torch.LongTensor] = None,
|
|
443
|
+
attention_mask: Optional[torch.LongTensor] = None,
|
|
444
|
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
|
445
|
+
interpolate_pos_encoding: bool = False,
|
|
446
|
+
**generate_kwargs,
|
|
447
|
+
) -> torch.LongTensor:
|
|
448
|
+
batch_size = pixel_values.shape[0]
|
|
449
|
+
image_embeds = self.vision_model(
|
|
450
|
+
pixel_values,
|
|
451
|
+
return_dict=True,
|
|
452
|
+
interpolate_pos_encoding=interpolate_pos_encoding,
|
|
453
|
+
).last_hidden_state
|
|
454
|
+
image_attention_mask = torch.ones(image_embeds.size()[:-1], dtype=torch.long, device=image_embeds.device)
|
|
455
|
+
|
|
456
|
+
query_tokens = self.query_tokens.expand(image_embeds.shape[0], -1, -1)
|
|
457
|
+
query_outputs = self.qformer(
|
|
458
|
+
query_embeds=query_tokens,
|
|
459
|
+
encoder_hidden_states=image_embeds,
|
|
460
|
+
encoder_attention_mask=image_attention_mask,
|
|
461
|
+
return_dict=True,
|
|
462
|
+
)
|
|
463
|
+
query_output = query_outputs.last_hidden_state
|
|
464
|
+
|
|
465
|
+
if query_output.dtype != image_embeds.dtype:
|
|
466
|
+
query_output = query_output.to(image_embeds.dtype)
|
|
467
|
+
|
|
468
|
+
language_model_inputs = self.language_projection(query_output)
|
|
469
|
+
|
|
470
|
+
if inputs_embeds is None:
|
|
471
|
+
if input_ids is None:
|
|
472
|
+
image_tokens = [self.config.image_token_index] * self.config.num_query_tokens
|
|
473
|
+
start_tokens = image_tokens + [self.config.text_config.bos_token_id]
|
|
474
|
+
input_ids = torch.tensor([start_tokens], dtype=torch.long, device=image_embeds.device)
|
|
475
|
+
input_ids = input_ids.repeat(batch_size, 1)
|
|
476
|
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
|
477
|
+
|
|
478
|
+
if attention_mask is None:
|
|
479
|
+
attention_mask = torch.ones_like(input_ids)
|
|
480
|
+
|
|
481
|
+
if input_ids is None:
|
|
482
|
+
special_image_mask = inputs_embeds == self.get_input_embeddings()(
|
|
483
|
+
torch.tensor(self.config.image_token_id, dtype=torch.long, device=inputs_embeds.device)
|
|
484
|
+
)
|
|
485
|
+
special_image_mask = special_image_mask.all(-1)
|
|
486
|
+
else:
|
|
487
|
+
special_image_mask = input_ids == self.config.image_token_id
|
|
488
|
+
|
|
489
|
+
special_image_mask = special_image_mask.unsqueeze(-1).expand_as(inputs_embeds).to(inputs_embeds.device)
|
|
490
|
+
language_model_inputs = language_model_inputs.to(inputs_embeds.device, inputs_embeds.dtype)
|
|
491
|
+
inputs_embeds = inputs_embeds.masked_scatter(special_image_mask, language_model_inputs)
|
|
492
|
+
|
|
493
|
+
inputs = {"inputs_embeds": inputs_embeds, "attention_mask": attention_mask}
|
|
494
|
+
if not self.language_model.config.is_encoder_decoder:
|
|
495
|
+
inputs["input_ids"] = input_ids
|
|
496
|
+
|
|
497
|
+
outputs = self.language_model.generate(**inputs, **generate_kwargs)
|
|
498
|
+
|
|
499
|
+
return outputs
|
|
@@ -19,7 +19,7 @@ from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, Union
|
|
|
19
19
|
import rebel
|
|
20
20
|
import torch
|
|
21
21
|
from rebel.compile_context import CompileContext
|
|
22
|
-
from transformers import AutoModel, AutoModelForCausalLM, PretrainedConfig, PreTrainedModel
|
|
22
|
+
from transformers import AutoConfig, AutoModel, AutoModelForCausalLM, PretrainedConfig, PreTrainedModel
|
|
23
23
|
from transformers.modeling_outputs import BaseModelOutputWithPast
|
|
24
24
|
from transformers.modeling_utils import no_init_weights
|
|
25
25
|
|
|
@@ -317,12 +317,27 @@ class RBLNDecoderOnlyModel(RBLNModel, RBLNDecoderOnlyFlashAttentionMixin):
|
|
|
317
317
|
|
|
318
318
|
@classmethod
|
|
319
319
|
def get_pytorch_model(
|
|
320
|
-
cls,
|
|
320
|
+
cls,
|
|
321
|
+
model_id: str,
|
|
322
|
+
*args,
|
|
323
|
+
rbln_config: Optional[RBLNDecoderOnlyModelConfig] = None,
|
|
324
|
+
num_hidden_layers: Optional[int] = None,
|
|
325
|
+
**kwargs,
|
|
321
326
|
) -> PreTrainedModel:
|
|
322
327
|
if rbln_config and rbln_config.quantization:
|
|
323
|
-
model = cls.get_quantized_model(*args, rbln_config=rbln_config, **kwargs)
|
|
328
|
+
model = cls.get_quantized_model(model_id, *args, rbln_config=rbln_config, **kwargs)
|
|
324
329
|
else:
|
|
325
|
-
|
|
330
|
+
if num_hidden_layers is not None:
|
|
331
|
+
trust_remote_code = kwargs.get("trust_remote_code", None)
|
|
332
|
+
config, kwargs = AutoConfig.from_pretrained(
|
|
333
|
+
model_id, return_unused_kwargs=True, num_hidden_layers=num_hidden_layers, **kwargs
|
|
334
|
+
)
|
|
335
|
+
if hasattr(config, "layer_types"):
|
|
336
|
+
config.layer_types = config.layer_types[:num_hidden_layers]
|
|
337
|
+
kwargs["config"] = config
|
|
338
|
+
kwargs["trust_remote_code"] = trust_remote_code
|
|
339
|
+
|
|
340
|
+
model = super().get_pytorch_model(model_id, *args, **kwargs)
|
|
326
341
|
|
|
327
342
|
return model
|
|
328
343
|
|
|
@@ -28,6 +28,7 @@ from ....modeling import RBLNModel
|
|
|
28
28
|
from ...modeling_outputs import RBLNDecoderOnlyOutput
|
|
29
29
|
from ...utils.rbln_runtime_wrapper import LoopProcessor
|
|
30
30
|
from ..decoderonly.decoderonly_runtime_utils import RBLNPageTableManager
|
|
31
|
+
from ..decoderonly.generation_decoderonly import RBLNDecoderOnlyGenerationMixin
|
|
31
32
|
from ..decoderonly.modeling_decoderonly import (
|
|
32
33
|
RBLNDecoderOnlyModelForCausalLM,
|
|
33
34
|
)
|
|
@@ -77,7 +78,7 @@ class LoopProjector(LoopProcessor):
|
|
|
77
78
|
return output[0]
|
|
78
79
|
|
|
79
80
|
|
|
80
|
-
class RBLNGemma3ForConditionalGeneration(RBLNModel):
|
|
81
|
+
class RBLNGemma3ForConditionalGeneration(RBLNModel, RBLNDecoderOnlyGenerationMixin):
|
|
81
82
|
auto_model_class = AutoModelForImageTextToText
|
|
82
83
|
_rbln_submodules = [
|
|
83
84
|
{"name": "vision_tower"},
|
|
@@ -35,6 +35,7 @@ from ....configuration_utils import RBLNCompileConfig, RBLNModelConfig
|
|
|
35
35
|
from ....modeling import RBLNModel
|
|
36
36
|
from ....utils.runtime_utils import RBLNPytorchRuntime
|
|
37
37
|
from ...modeling_outputs import RBLNDecoderOnlyOutput
|
|
38
|
+
from ..decoderonly.generation_decoderonly import RBLNDecoderOnlyGenerationMixin
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
if TYPE_CHECKING:
|
|
@@ -120,9 +121,6 @@ class RBLNIdefics3VisionTransformer(RBLNModel):
|
|
|
120
121
|
encoder_outputs = self.encoder(
|
|
121
122
|
inputs_embeds=hidden_states,
|
|
122
123
|
attention_mask=patch_attention_mask,
|
|
123
|
-
output_attentions=None,
|
|
124
|
-
output_hidden_states=None,
|
|
125
|
-
return_dict=False,
|
|
126
124
|
)
|
|
127
125
|
last_hidden_state = encoder_outputs[0]
|
|
128
126
|
last_hidden_state = self.post_layernorm(last_hidden_state)
|
|
@@ -185,7 +183,7 @@ class RBLNIdefics3VisionTransformer(RBLNModel):
|
|
|
185
183
|
return BaseModelOutput(last_hidden_state=last_hidden_state)
|
|
186
184
|
|
|
187
185
|
|
|
188
|
-
class RBLNIdefics3ForConditionalGeneration(RBLNModel):
|
|
186
|
+
class RBLNIdefics3ForConditionalGeneration(RBLNModel, RBLNDecoderOnlyGenerationMixin):
|
|
189
187
|
"""
|
|
190
188
|
RBLNIdefics3ForConditionalGeneration is a multi-modal model that integrates vision and language processing capabilities,
|
|
191
189
|
optimized for RBLN NPUs. It is designed for conditional generation tasks that involve both image and text inputs.
|
|
@@ -27,6 +27,7 @@ from ....modeling import RBLNModel
|
|
|
27
27
|
from ....utils.logging import get_logger
|
|
28
28
|
from ...modeling_outputs import RBLNDecoderOnlyOutput
|
|
29
29
|
from ...utils.rbln_runtime_wrapper import LoopProcessor
|
|
30
|
+
from ..decoderonly.generation_decoderonly import RBLNDecoderOnlyGenerationMixin
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
logger = get_logger(__name__)
|
|
@@ -103,7 +104,7 @@ class LoopProjector(LoopProcessor):
|
|
|
103
104
|
return output[0]
|
|
104
105
|
|
|
105
106
|
|
|
106
|
-
class RBLNLlavaForConditionalGeneration(RBLNModel):
|
|
107
|
+
class RBLNLlavaForConditionalGeneration(RBLNModel, RBLNDecoderOnlyGenerationMixin):
|
|
107
108
|
"""
|
|
108
109
|
RBLNLlavaForConditionalGeneration is a multi-modal model that combines vision and language processing capabilities,
|
|
109
110
|
optimized for RBLN NPUs. It is designed for conditional generation tasks that involve both image and text inputs.
|
|
@@ -32,6 +32,7 @@ from ....configuration_utils import RBLNCompileConfig, RBLNModelConfig
|
|
|
32
32
|
from ....modeling import RBLNModel
|
|
33
33
|
from ....utils.logging import get_logger
|
|
34
34
|
from ...utils.rbln_runtime_wrapper import LoopProcessor
|
|
35
|
+
from ..decoderonly.generation_decoderonly import RBLNDecoderOnlyGenerationMixin
|
|
35
36
|
from ..decoderonly.modeling_decoderonly import RBLNDecoderOnlyOutput
|
|
36
37
|
|
|
37
38
|
|
|
@@ -87,7 +88,7 @@ class LoopProjector(LoopProcessor):
|
|
|
87
88
|
return output[0]
|
|
88
89
|
|
|
89
90
|
|
|
90
|
-
class RBLNLlavaNextForConditionalGeneration(RBLNModel):
|
|
91
|
+
class RBLNLlavaNextForConditionalGeneration(RBLNModel, RBLNDecoderOnlyGenerationMixin):
|
|
91
92
|
"""
|
|
92
93
|
RBLNLlavaNextForConditionalGeneration is a multi-modal model that combines vision and language processing capabilities,
|
|
93
94
|
optimized for RBLN NPUs. It is designed for conditional generation tasks that involve both image and text inputs.
|
|
@@ -400,15 +400,6 @@ class RBLNQwen2_5_VLForConditionalGeneration(RBLNDecoderOnlyModelForCausalLM):
|
|
|
400
400
|
del model.lm_head
|
|
401
401
|
return model
|
|
402
402
|
|
|
403
|
-
@classmethod
|
|
404
|
-
def update_kwargs(cls, kwargs):
|
|
405
|
-
kwargs.update(
|
|
406
|
-
{
|
|
407
|
-
"_attn_implementation": "eager",
|
|
408
|
-
}
|
|
409
|
-
)
|
|
410
|
-
return super().update_kwargs(kwargs)
|
|
411
|
-
|
|
412
403
|
@classmethod
|
|
413
404
|
def get_input_info(
|
|
414
405
|
cls,
|
|
@@ -20,6 +20,7 @@ import rebel
|
|
|
20
20
|
import torch
|
|
21
21
|
from rebel.compile_context import CompileContext
|
|
22
22
|
from transformers import AutoModelForSeq2SeqLM, PretrainedConfig, PreTrainedModel
|
|
23
|
+
from transformers.generation.utils import GenerationMixin
|
|
23
24
|
from transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput
|
|
24
25
|
|
|
25
26
|
from ....configuration_utils import RBLNCompileConfig
|
|
@@ -101,7 +102,7 @@ class RBLNRuntimeDecoder(RBLNPytorchRuntime):
|
|
|
101
102
|
return Seq2SeqLMOutput(logits=lm_logits)
|
|
102
103
|
|
|
103
104
|
|
|
104
|
-
class RBLNModelForSeq2SeqLM(RBLNModel, ABC):
|
|
105
|
+
class RBLNModelForSeq2SeqLM(RBLNModel, GenerationMixin, ABC):
|
|
105
106
|
"""
|
|
106
107
|
This is a generic model class that will be instantiated as one of the model classes of the library (with a sequence-to-sequence language modeling head) when created with the from_pretrained() class method.
|
|
107
108
|
This model inherits from [`RBLNModel`]. Check the superclass documentation for the generic methods the library implements for all its models.
|
|
@@ -117,6 +118,7 @@ class RBLNModelForSeq2SeqLM(RBLNModel, ABC):
|
|
|
117
118
|
main_input_name = "input_ids"
|
|
118
119
|
auto_model_class = AutoModelForSeq2SeqLM
|
|
119
120
|
support_causal_attn = None
|
|
121
|
+
_is_stateful = False
|
|
120
122
|
|
|
121
123
|
def __post_init__(self, **kwargs):
|
|
122
124
|
batch_size = self.rbln_config.batch_size
|
|
@@ -150,7 +150,8 @@ class RBLNWhisperForConditionalGeneration(RBLNModel, RBLNWhisperGenerationMixin)
|
|
|
150
150
|
"""
|
|
151
151
|
|
|
152
152
|
auto_model_class = AutoModelForSpeechSeq2Seq
|
|
153
|
-
main_input_name = "
|
|
153
|
+
main_input_name = "input_features"
|
|
154
|
+
_is_stateful = False
|
|
154
155
|
|
|
155
156
|
def __post_init__(self, **kwargs):
|
|
156
157
|
super().__post_init__(**kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: optimum-rbln
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.2a5
|
|
4
4
|
Summary: Optimum RBLN is the interface between the HuggingFace Transformers and Diffusers libraries and RBLN accelerators. It provides a set of tools enabling easy model loading and inference on single and multiple rbln device settings for different downstream tasks.
|
|
5
5
|
Project-URL: Homepage, https://rebellions.ai
|
|
6
6
|
Project-URL: Documentation, https://docs.rbln.ai
|
|
@@ -26,10 +26,10 @@ Requires-Python: <3.14,>=3.9
|
|
|
26
26
|
Requires-Dist: accelerate>=1.0.1
|
|
27
27
|
Requires-Dist: diffusers==0.35.1
|
|
28
28
|
Requires-Dist: packaging>=24.1
|
|
29
|
-
Requires-Dist: torch==2.
|
|
30
|
-
Requires-Dist: torchaudio<=2.
|
|
31
|
-
Requires-Dist: torchvision<=0.
|
|
32
|
-
Requires-Dist: transformers==4.
|
|
29
|
+
Requires-Dist: torch==2.8.0
|
|
30
|
+
Requires-Dist: torchaudio<=2.8.0
|
|
31
|
+
Requires-Dist: torchvision<=0.23.0
|
|
32
|
+
Requires-Dist: transformers==4.57.1
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
34
34
|
|
|
35
35
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
optimum/rbln/__init__.py,sha256=AZ-7X3ZCjMNcz4mkC_98y-HWRw38ijh8gETJet9tiyM,18828
|
|
2
|
-
optimum/rbln/__version__.py,sha256=
|
|
2
|
+
optimum/rbln/__version__.py,sha256=SknjPrWnnK8RN1n8X1WB74WmhEFBtAnbp5Zb4GrhDlA,712
|
|
3
3
|
optimum/rbln/configuration_utils.py,sha256=KFibQ8IYcapw3M1GpgNLgQ1ZolRIip0_bOlwfU0OYac,38193
|
|
4
|
-
optimum/rbln/modeling.py,sha256=
|
|
4
|
+
optimum/rbln/modeling.py,sha256=jfYPOl0FmYq6B3et3rmoCbiWV4939LlVgs-PrZ7IWIk,16928
|
|
5
5
|
optimum/rbln/modeling_base.py,sha256=poXfHZCAlFd28MY9dvMi7tC2RytLx77Lee2XGS_KeZg,27684
|
|
6
6
|
optimum/rbln/diffusers/__init__.py,sha256=1tgU_xWA42BmInqu9bBz_5R_E9TGhhK3mI06YlaiTLg,7232
|
|
7
7
|
optimum/rbln/diffusers/modeling_diffusers.py,sha256=egx137ECmNA0bK2JPRUOpxCl1Wb3qOpE-xSaPaJOs-g,20549
|
|
@@ -75,7 +75,7 @@ optimum/rbln/ops/sliding_window_attn.py,sha256=EQrV_yRGc5z6kvwEsAcLP028bJWkQg2UP
|
|
|
75
75
|
optimum/rbln/transformers/__init__.py,sha256=hyv53b_d_IJ9KYsDogTmKHDNuXIGNCFkrJI21RHE5ak,12573
|
|
76
76
|
optimum/rbln/transformers/configuration_generic.py,sha256=rM4XY1a_UlRf3ZCZkCav59JKRuvqiEEUUgnqNlgdcv8,5207
|
|
77
77
|
optimum/rbln/transformers/modeling_attention_utils.py,sha256=aLyOaq4me1m-JMmnKbuyNQageDxNU2jjEhGE_ew2P5o,11465
|
|
78
|
-
optimum/rbln/transformers/modeling_generic.py,sha256=
|
|
78
|
+
optimum/rbln/transformers/modeling_generic.py,sha256=csViS2KrCr4qaID2jZ1vdHn_W-3wdPFEAtsheEB_LFc,13619
|
|
79
79
|
optimum/rbln/transformers/modeling_outputs.py,sha256=cd8ZlhHAGq7S6i5-QK6TJCxgORvoPMnZpqPBlUc_pMY,1177
|
|
80
80
|
optimum/rbln/transformers/modeling_rope_utils.py,sha256=6Zg3r-TeUk4WQAlr95pqfhuoAD_RQ4njT1rbO9uPL0Q,14379
|
|
81
81
|
optimum/rbln/transformers/models/__init__.py,sha256=yzcjyHCHH4-Mi26N34HzNs7Tl5HjjT1rrwQ8f_W2_nc,13532
|
|
@@ -95,7 +95,7 @@ optimum/rbln/transformers/models/bert/configuration_bert.py,sha256=nEZnX6LXpLKWa
|
|
|
95
95
|
optimum/rbln/transformers/models/bert/modeling_bert.py,sha256=7MQZS11k4__oyeni5ek2SzRf-gtD3_hMKl_oOzN7_XQ,2263
|
|
96
96
|
optimum/rbln/transformers/models/blip_2/__init__.py,sha256=L01gPXcUCa8Vg-bcng20vZvBIN_jlqCzwUSFuq0QOag,855
|
|
97
97
|
optimum/rbln/transformers/models/blip_2/configuration_blip_2.py,sha256=8eSilBwcPWQhBg-oilCmDPo-DN6V5lpLMlTB7WPknII,4630
|
|
98
|
-
optimum/rbln/transformers/models/blip_2/modeling_blip_2.py,sha256=
|
|
98
|
+
optimum/rbln/transformers/models/blip_2/modeling_blip_2.py,sha256=MUDwSboH8gdIaJxbPUJsBPuhQf8ViNbVAViU2DASm1g,19308
|
|
99
99
|
optimum/rbln/transformers/models/clip/__init__.py,sha256=TLeXDqcFK6M6v9x7Xr64kBbqGu3hFHM7p754dQ8UVQc,938
|
|
100
100
|
optimum/rbln/transformers/models/clip/configuration_clip.py,sha256=Ea8TCVmMayydfw9p4kTP3UdtvoaPWf4Z4claB61JuE4,4175
|
|
101
101
|
optimum/rbln/transformers/models/clip/modeling_clip.py,sha256=BLAYJAtv_2ZnKOlZ8iDBr2Su3bKM_eMWeUSK9MOaj7I,13198
|
|
@@ -110,7 +110,7 @@ optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py,sha256=
|
|
|
110
110
|
optimum/rbln/transformers/models/decoderonly/decoderonly_runtime_utils.py,sha256=2yGU1JfxCepG37DbyY8oWq3gMIKhMnPyBkLH8VniKfA,21530
|
|
111
111
|
optimum/rbln/transformers/models/decoderonly/generation_decoderonly.py,sha256=zabSgQd2VzHhkpbhUFW5Z-CjYB1JvSJOb5yXKjXCQV0,4326
|
|
112
112
|
optimum/rbln/transformers/models/decoderonly/lora_architecture.py,sha256=jo-jYy95JhdvOsX1UTCXeYTNer37wBbtY578C0QQpZo,8306
|
|
113
|
-
optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py,sha256=
|
|
113
|
+
optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py,sha256=myXdyYLivoPVJVGa2vmeaGLFxmjw-vUyYYsNTAX41yk,35907
|
|
114
114
|
optimum/rbln/transformers/models/depth_anything/__init__.py,sha256=xvPSIriMJWyNeVYoVB1Z7YqB4kkHOIkaHq7loNps-dk,756
|
|
115
115
|
optimum/rbln/transformers/models/depth_anything/configuration_depth_anything.py,sha256=JujBVEUa_zZDXNPr1y-B_PhK5SgFFcY8Ib4EoGjjtmE,989
|
|
116
116
|
optimum/rbln/transformers/models/depth_anything/modeling_depth_anything.py,sha256=tTmsVaW9Wb2WD3nKRLwp7swn3hbMvgwUEJwwVIfNYEc,1008
|
|
@@ -132,7 +132,7 @@ optimum/rbln/transformers/models/gemma3/__init__.py,sha256=6rugk3615SEt4lh7gduo_
|
|
|
132
132
|
optimum/rbln/transformers/models/gemma3/configuration_gemma3.py,sha256=NJJfarzbWJc3pm0XvICN7D0FFF9nqidagIEoOvYLixQ,4696
|
|
133
133
|
optimum/rbln/transformers/models/gemma3/gemma3_architecture.py,sha256=TkGt2g313hXbB8vPFz8-oDBEsuR3HJI6LjSFgqec_Sc,6533
|
|
134
134
|
optimum/rbln/transformers/models/gemma3/gemma3_runtime_utils.py,sha256=ZhWgecT4v4Ewd1hmrlJH47QUZuQweVB1qAaK-Qw24-Q,11127
|
|
135
|
-
optimum/rbln/transformers/models/gemma3/modeling_gemma3.py,sha256=
|
|
135
|
+
optimum/rbln/transformers/models/gemma3/modeling_gemma3.py,sha256=Yx1rUxTgGvaCsNldggL3rFc2zxsndDKkQovjCmmNf28,25868
|
|
136
136
|
optimum/rbln/transformers/models/gpt2/__init__.py,sha256=SsawHMStE3wYRtqkH5EvdTFkCdX0LLmp-QSKFhEBrHo,740
|
|
137
137
|
optimum/rbln/transformers/models/gpt2/configuration_gpt2.py,sha256=iGdHfzG7plekZcIz-Z5U8lRE4SB8gbJJNcFQJ9l8Myg,1533
|
|
138
138
|
optimum/rbln/transformers/models/gpt2/gpt2_architecture.py,sha256=ul87zvaLkqsuNJirvl6QtGXM147taNEbnb9qPulR1Ps,2933
|
|
@@ -143,17 +143,17 @@ optimum/rbln/transformers/models/grounding_dino/grounding_dino_architecture.py,s
|
|
|
143
143
|
optimum/rbln/transformers/models/grounding_dino/modeling_grounding_dino.py,sha256=bXAOs2QH4sy2UFoFLUSM6u1_VHouUT5COERLQX20F6Y,46897
|
|
144
144
|
optimum/rbln/transformers/models/idefics3/__init__.py,sha256=ulxE7HEfXsNJhd25J9Fvi6vggo9aZH9sLKJjWB6LlzQ,814
|
|
145
145
|
optimum/rbln/transformers/models/idefics3/configuration_idefics3.py,sha256=7IENNxflZL8ZH3YRqtCXfYdKs-RdUeGiPzq-C03te_s,3679
|
|
146
|
-
optimum/rbln/transformers/models/idefics3/modeling_idefics3.py,sha256=
|
|
146
|
+
optimum/rbln/transformers/models/idefics3/modeling_idefics3.py,sha256=LEFJu9JsoiS3ZJoG2J3QkwDAyTa75xJQmMtvpomYwsw,19918
|
|
147
147
|
optimum/rbln/transformers/models/llama/__init__.py,sha256=6tgx9-qlM5r9ouoeZEouVRNLs3r6Sku-cuXNkyfeFHc,746
|
|
148
148
|
optimum/rbln/transformers/models/llama/configuration_llama.py,sha256=_uxfH5kaGbeJTMJfESYn0Vg3OEkINS2ShGtVQTeOcs4,1578
|
|
149
149
|
optimum/rbln/transformers/models/llama/llama_architecture.py,sha256=S7MCPfyjG5eUqgaS-QNBB0ApUD6wnb5fR0RHq7k7-pA,728
|
|
150
150
|
optimum/rbln/transformers/models/llama/modeling_llama.py,sha256=uRxEXYhHOuEwPjBo_Ps3eFU1uwScasla6P8HwsQgAu0,4214
|
|
151
151
|
optimum/rbln/transformers/models/llava/__init__.py,sha256=FaVLgBIqKGjT_nvwYO9k9BVqrzH_Ym3DfjGRCSUhG2s,734
|
|
152
152
|
optimum/rbln/transformers/models/llava/configuration_llava.py,sha256=c1rie8LCypxlsT7SNjZJE07_xCLAasV4EBs97o1757Q,2998
|
|
153
|
-
optimum/rbln/transformers/models/llava/modeling_llava.py,sha256=
|
|
153
|
+
optimum/rbln/transformers/models/llava/modeling_llava.py,sha256=MaszTboXRr-PTWZKxhbw5w5rBZ95ES2_fHEW280T2LU,20351
|
|
154
154
|
optimum/rbln/transformers/models/llava_next/__init__.py,sha256=kDXKr7wMkp1XqE__DER2B8kQF_NYMxhzsQS5ytGg56I,752
|
|
155
155
|
optimum/rbln/transformers/models/llava_next/configuration_llava_next.py,sha256=Sz8L8p_23T7xw7pkUmW5pyK_wZclph1p_kQYbslc8m8,2708
|
|
156
|
-
optimum/rbln/transformers/models/llava_next/modeling_llava_next.py,sha256=
|
|
156
|
+
optimum/rbln/transformers/models/llava_next/modeling_llava_next.py,sha256=0aooyMG7ElVIa52MB0ysVKqB4Pdxyl4tbeD1QdehiZk,21342
|
|
157
157
|
optimum/rbln/transformers/models/midm/__init__.py,sha256=IC3FETwgYinbp3wDj7tp4zIHJhbqM-c6GfTRdYcMNj8,913
|
|
158
158
|
optimum/rbln/transformers/models/midm/configuration_midm.py,sha256=DxhcSJlApxfi00XxYmSkKZ6bY9vfLXT0zh-oMKkZot0,1365
|
|
159
159
|
optimum/rbln/transformers/models/midm/midm_architecture.py,sha256=f9IwLLyYErliWJhkRj880QByMEYs_XVwm2Yh6r-Y_ik,5186
|
|
@@ -184,7 +184,7 @@ optimum/rbln/transformers/models/qwen2/modeling_qwen2.py,sha256=VOboPJF1rvvSVWkH
|
|
|
184
184
|
optimum/rbln/transformers/models/qwen2/qwen2_architecture.py,sha256=XlNAMYAcDLohnSAhIFGKOPuCB5XLgzYs5ABWdeQSaZs,720
|
|
185
185
|
optimum/rbln/transformers/models/qwen2_5_vl/__init__.py,sha256=rAW3DKQUzGL6EMwa5r1iLu94yhpiZpk6zfoD7TtYXrc,865
|
|
186
186
|
optimum/rbln/transformers/models/qwen2_5_vl/configuration_qwen2_5_vl.py,sha256=WHLH72i7Pe16Ee1waMixMsR3eD6TsMGN08QD82qdVvw,6162
|
|
187
|
-
optimum/rbln/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py,sha256=
|
|
187
|
+
optimum/rbln/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py,sha256=ey6uZqf9ULr5LOugf-KrHGKMkdPyZ5XOPt8I-tBBXOc,26730
|
|
188
188
|
optimum/rbln/transformers/models/qwen2_5_vl/qwen2_5_vl_architecture.py,sha256=hlx9Tt9n9m-fL4m21QFKgsN719CDhwhgfOMjnhde4RE,8392
|
|
189
189
|
optimum/rbln/transformers/models/qwen2_vl/__init__.py,sha256=O3t6zKda92CnZDzEnz_dcisMOQ71-OOJxElXzKCH5e0,849
|
|
190
190
|
optimum/rbln/transformers/models/qwen2_vl/configuration_qwen2_vl.py,sha256=mi5CqSKZ77G5Fib3g8a86_4CEB6lb-qJOhDnSqslvNk,4714
|
|
@@ -202,7 +202,7 @@ optimum/rbln/transformers/models/roberta/configuration_roberta.py,sha256=6KhO-xB
|
|
|
202
202
|
optimum/rbln/transformers/models/roberta/modeling_roberta.py,sha256=74Pswb5JJNtctvrQHlo2zYocKZN0npWhjAaKMUDVBUU,1535
|
|
203
203
|
optimum/rbln/transformers/models/seq2seq/__init__.py,sha256=HiSyWFcKeZ8okfo-s-_Mf_upyvAoZwraUIJyGNLNurY,714
|
|
204
204
|
optimum/rbln/transformers/models/seq2seq/configuration_seq2seq.py,sha256=pFnt382URDduIpeNb7z_xmONCSOt_2mKssro5xe8y3E,3121
|
|
205
|
-
optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py,sha256=
|
|
205
|
+
optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py,sha256=nb511JHbi1wLCr5dOTClItuScx1fb-PCaNxKXjFTVQs,18395
|
|
206
206
|
optimum/rbln/transformers/models/seq2seq/seq2seq_architecture.py,sha256=jmBgj7BkUS_S-T-9DI53rE3KXUHSCoIofr7k5JDVPrU,20024
|
|
207
207
|
optimum/rbln/transformers/models/siglip/__init__.py,sha256=X1Fc1GUnJ2EIxFx45nbeoW-T2t0OyP3W73C0HD8Vowo,712
|
|
208
208
|
optimum/rbln/transformers/models/siglip/configuration_siglip.py,sha256=Fy-ANF91bQno_QVd4ZpyRs-uNgC_XRyBRScBg2uKM6w,3029
|
|
@@ -227,7 +227,7 @@ optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py,sha256=bMKHdUDHgz
|
|
|
227
227
|
optimum/rbln/transformers/models/whisper/__init__.py,sha256=ErquiUlYycSYPsDcq9IwwmbZXoYLn1MVZ8VikWY5gQo,792
|
|
228
228
|
optimum/rbln/transformers/models/whisper/configuration_whisper.py,sha256=bSwDN7VLuk1aVXvfrQIgb9SLdFBDhO5q8ZFaPQPJal0,3077
|
|
229
229
|
optimum/rbln/transformers/models/whisper/generation_whisper.py,sha256=0MYzMTZwTHFcJV_ZEtCm2AZbKN9RHgAr9jefuOAouVI,5017
|
|
230
|
-
optimum/rbln/transformers/models/whisper/modeling_whisper.py,sha256=
|
|
230
|
+
optimum/rbln/transformers/models/whisper/modeling_whisper.py,sha256=MFKYAqO1ep3teYumMY5E_jjyCU4552GKZacSNFyjVQM,19323
|
|
231
231
|
optimum/rbln/transformers/models/whisper/whisper_architecture.py,sha256=fKUbAMIl20o6EBMVcLg9TDSsJ1FDp8NKcl4jT9RWCEM,13981
|
|
232
232
|
optimum/rbln/transformers/models/xlm_roberta/__init__.py,sha256=O3o2KzJ8Li3QhB7GHdRQASc93SYO2jz00Rx4pxYRuDg,982
|
|
233
233
|
optimum/rbln/transformers/models/xlm_roberta/configuration_xlm_roberta.py,sha256=wHRpGTXL9khYqSkKL1IgA7__6_lt9QpOz9tHumjK7fo,1260
|
|
@@ -245,7 +245,7 @@ optimum/rbln/utils/model_utils.py,sha256=4k5879Kh75m3x_vS4-qOGfqsOiAvc2kdNFFfvsF
|
|
|
245
245
|
optimum/rbln/utils/runtime_utils.py,sha256=R6uXDbeJP03-FWdd4vthNe2D4aCra5n12E3WB1ifiGM,7933
|
|
246
246
|
optimum/rbln/utils/save_utils.py,sha256=hG5uOtYmecSXZuGTvCXsTM-SiyZpr5q3InUGCCq_jzQ,3619
|
|
247
247
|
optimum/rbln/utils/submodule.py,sha256=SKLnM3KsX8_rv3HauO4oB2-JSjzuadQjRwo_BhMUzLI,6362
|
|
248
|
-
optimum_rbln-0.9.
|
|
249
|
-
optimum_rbln-0.9.
|
|
250
|
-
optimum_rbln-0.9.
|
|
251
|
-
optimum_rbln-0.9.
|
|
248
|
+
optimum_rbln-0.9.2a5.dist-info/METADATA,sha256=8gm204ZrCL7yjPNG5vEGsSE5RhIDtPk2H-eWGFxX8yw,5350
|
|
249
|
+
optimum_rbln-0.9.2a5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
250
|
+
optimum_rbln-0.9.2a5.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
251
|
+
optimum_rbln-0.9.2a5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|