optimum-rbln 0.9.3__py3-none-any.whl → 0.9.3rc0__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 +0 -12
- optimum/rbln/__version__.py +2 -2
- optimum/rbln/configuration_utils.py +2 -4
- optimum/rbln/diffusers/__init__.py +0 -12
- optimum/rbln/diffusers/configurations/__init__.py +0 -3
- optimum/rbln/diffusers/configurations/models/__init__.py +0 -2
- optimum/rbln/diffusers/configurations/pipelines/__init__.py +0 -3
- optimum/rbln/diffusers/models/__init__.py +3 -17
- optimum/rbln/diffusers/models/autoencoders/__init__.py +0 -1
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl_cosmos.py +3 -3
- optimum/rbln/diffusers/models/autoencoders/vae.py +8 -27
- optimum/rbln/diffusers/models/controlnet.py +1 -16
- optimum/rbln/diffusers/models/transformers/prior_transformer.py +2 -16
- optimum/rbln/diffusers/models/transformers/transformer_cosmos.py +1 -16
- optimum/rbln/diffusers/models/transformers/transformer_sd3.py +1 -14
- optimum/rbln/diffusers/models/unets/__init__.py +0 -1
- optimum/rbln/diffusers/models/unets/unet_2d_condition.py +1 -17
- optimum/rbln/diffusers/pipelines/__init__.py +0 -4
- optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +0 -20
- optimum/rbln/modeling.py +45 -20
- optimum/rbln/modeling_base.py +1 -0
- optimum/rbln/transformers/configuration_generic.py +27 -0
- optimum/rbln/transformers/modeling_attention_utils.py +109 -242
- optimum/rbln/transformers/modeling_generic.py +61 -2
- optimum/rbln/transformers/models/audio_spectrogram_transformer/configuration_audio_spectrogram_transformer.py +2 -28
- optimum/rbln/transformers/models/audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.py +5 -68
- optimum/rbln/transformers/models/bart/modeling_bart.py +2 -23
- optimum/rbln/transformers/models/bert/modeling_bert.py +1 -86
- optimum/rbln/transformers/models/blip_2/modeling_blip_2.py +15 -42
- optimum/rbln/transformers/models/clip/modeling_clip.py +2 -40
- optimum/rbln/transformers/models/colpali/modeling_colpali.py +44 -5
- optimum/rbln/transformers/models/decoderonly/configuration_decoderonly.py +1 -6
- optimum/rbln/transformers/models/decoderonly/decoderonly_runtime_utils.py +2 -6
- optimum/rbln/transformers/models/decoderonly/generation_decoderonly.py +9 -17
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +12 -36
- optimum/rbln/transformers/models/depth_anything/modeling_depth_anything.py +0 -17
- optimum/rbln/transformers/models/distilbert/modeling_distilbert.py +0 -24
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +0 -17
- optimum/rbln/transformers/models/gemma3/modeling_gemma3.py +5 -3
- optimum/rbln/transformers/models/grounding_dino/modeling_grounding_dino.py +8 -24
- optimum/rbln/transformers/models/idefics3/modeling_idefics3.py +5 -3
- optimum/rbln/transformers/models/llava/modeling_llava.py +24 -36
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +4 -2
- optimum/rbln/transformers/models/opt/modeling_opt.py +2 -2
- optimum/rbln/transformers/models/pegasus/modeling_pegasus.py +1 -1
- optimum/rbln/transformers/models/pixtral/modeling_pixtral.py +1 -13
- optimum/rbln/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py +3 -2
- optimum/rbln/transformers/models/qwen2_vl/modeling_qwen2_vl.py +3 -2
- optimum/rbln/transformers/models/resnet/configuration_resnet.py +0 -17
- optimum/rbln/transformers/models/resnet/modeling_resnet.py +0 -73
- optimum/rbln/transformers/models/roberta/modeling_roberta.py +0 -33
- optimum/rbln/transformers/models/seq2seq/configuration_seq2seq.py +4 -2
- optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +10 -34
- optimum/rbln/transformers/models/siglip/modeling_siglip.py +1 -17
- optimum/rbln/transformers/models/swin/modeling_swin.py +1 -14
- optimum/rbln/transformers/models/t5/modeling_t5.py +2 -2
- optimum/rbln/transformers/models/time_series_transformer/modeling_time_series_transformer.py +2 -16
- optimum/rbln/transformers/models/vit/modeling_vit.py +0 -19
- optimum/rbln/transformers/models/wav2vec2/configuration_wav2vec2.py +3 -15
- optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py +8 -60
- optimum/rbln/transformers/models/whisper/generation_whisper.py +14 -48
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +2 -2
- optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +0 -43
- optimum/rbln/transformers/utils/rbln_quantization.py +0 -9
- optimum/rbln/utils/depreacate_utils.py +16 -0
- optimum/rbln/utils/hub.py +3 -14
- optimum/rbln/utils/runtime_utils.py +0 -32
- {optimum_rbln-0.9.3.dist-info → optimum_rbln-0.9.3rc0.dist-info}/METADATA +2 -2
- {optimum_rbln-0.9.3.dist-info → optimum_rbln-0.9.3rc0.dist-info}/RECORD +72 -79
- {optimum_rbln-0.9.3.dist-info → optimum_rbln-0.9.3rc0.dist-info}/WHEEL +1 -1
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl_temporal_decoder.py +0 -67
- optimum/rbln/diffusers/configurations/models/configuration_unet_spatio_temporal_condition.py +0 -59
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_video_diffusion.py +0 -114
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +0 -275
- optimum/rbln/diffusers/models/unets/unet_spatio_temporal_condition.py +0 -201
- optimum/rbln/diffusers/pipelines/stable_video_diffusion/__init__.py +0 -15
- optimum/rbln/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +0 -46
- optimum/rbln/utils/deprecation.py +0 -213
- {optimum_rbln-0.9.3.dist-info → optimum_rbln-0.9.3rc0.dist-info}/entry_points.txt +0 -0
- {optimum_rbln-0.9.3.dist-info → optimum_rbln-0.9.3rc0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
|
2
|
-
# Copyright 2025 Rebellions Inc. All rights reserved.
|
|
3
|
-
|
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
# you may not use this file except in compliance with the License.
|
|
6
|
-
# You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
# See the License for the specific language governing permissions and
|
|
14
|
-
# limitations under the License.
|
|
15
|
-
|
|
16
|
-
# **********************************************************************************
|
|
17
|
-
# * NOTE: This file has been modified from its original version in *
|
|
18
|
-
# * the Hugging Face transformers library. *
|
|
19
|
-
# * Original source: *
|
|
20
|
-
# * https://github.com/huggingface/transformers/blob/v4.57.1/src/transformers/utils/deprecation.py
|
|
21
|
-
# **********************************************************************************
|
|
22
|
-
|
|
23
|
-
import inspect
|
|
24
|
-
from enum import Enum
|
|
25
|
-
from functools import wraps
|
|
26
|
-
from typing import Callable, Optional
|
|
27
|
-
|
|
28
|
-
import packaging.version
|
|
29
|
-
|
|
30
|
-
from ..__version__ import __version__
|
|
31
|
-
from .logging import get_logger
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
logger = get_logger(__name__)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def warn_deprecated_npu(npu: Optional[str] = None):
|
|
38
|
-
import rebel
|
|
39
|
-
|
|
40
|
-
npu = npu or rebel.get_npu_name()
|
|
41
|
-
if npu == "RBLN-CA02":
|
|
42
|
-
logger.warning_once(
|
|
43
|
-
"Support for the RBLN-CA02 device is provided only up to optimum-rbln v0.8.0 and has reached end of life.",
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class Action(Enum):
|
|
48
|
-
NONE = "none"
|
|
49
|
-
NOTIFY = "notify"
|
|
50
|
-
RAISE = "raise"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# Scenario Table for Deprecation Strategy Example
|
|
54
|
-
# Assume that current version is v0.9.6 and the deprecated version is v0.10.0
|
|
55
|
-
# |--------------------|----------------|----------------|---------------------------------------------|--------------------------------------------------------------------------------------|----------------------------------------------------------------------|
|
|
56
|
-
# | Type | v0.9.6 (as_is) | v0.9.6 (to_be) | v0.9.6 Patch | v0.9.7 Action | v0.10.0+ Action |
|
|
57
|
-
# |--------------------|----------------|----------------|---------------------------------------------|--------------------------------------------------------------------------------------|----------------------------------------------------------------------|
|
|
58
|
-
# | Modify (Key Name) | a: bool | a': bool | Add a', Keep a | 1. Only 'a' provided: replace a -> a' & future warning | In v0.10.0, raise error once, then remove decorator. |
|
|
59
|
-
# | | | | | 2. Both 'a' & 'a'' provided: ignore 'a' value & future warning | |
|
|
60
|
-
# |--------------------|----------------|----------------|---------------------------------------------|--------------------------------------------------------------------------------------|----------------------------------------------------------------------|
|
|
61
|
-
# | Modify (Value Type)| b: bool | b: str | b: Union[str, bool] | 'bool' value provided for 'b': replace with corresponding 'str' & future warning | In v0.10.0, raise error once, then remove decorator. |
|
|
62
|
-
# | | | | | | |
|
|
63
|
-
# |--------------------|----------------|----------------|---------------------------------------------|--------------------------------------------------------------------------------------|----------------------------------------------------------------------|
|
|
64
|
-
# | Deletion | c | - | Delete c or Keep c (flexible) | ignore c & future warning | In v0.10.0, raise error once, then remove decorator. |
|
|
65
|
-
# | | | | | | |
|
|
66
|
-
# |--------------------|----------------|----------------|---------------------------------------------|--------------------------------------------------------------------------------------|----------------------------------------------------------------------|
|
|
67
|
-
# | Addition | - | d | Add d, set default_value for d | No action needed as default value is set | Keep default value |
|
|
68
|
-
# |--------------------|----------------|----------------|---------------------------------------------|--------------------------------------------------------------------------------------|----------------------------------------------------------------------|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def deprecate_kwarg(
|
|
72
|
-
old_name: str,
|
|
73
|
-
version: str,
|
|
74
|
-
new_name: Optional[str] = None,
|
|
75
|
-
deprecated_type: Optional[type] = None,
|
|
76
|
-
value_replacer: Optional[Callable] = None,
|
|
77
|
-
raise_if_greater_or_equal_version: bool = True,
|
|
78
|
-
raise_if_both_names: bool = False,
|
|
79
|
-
additional_message: Optional[str] = None,
|
|
80
|
-
):
|
|
81
|
-
"""
|
|
82
|
-
Function or method decorator to notify users about deprecated keyword arguments, replacing them with a new name if specified,
|
|
83
|
-
or handling deprecated value types.
|
|
84
|
-
|
|
85
|
-
This decorator allows you to:
|
|
86
|
-
- Notify users when a keyword argument name is deprecated (Scenario 'a', 'c').
|
|
87
|
-
- Notify users when a specific value type for an argument is deprecated (Scenario 'b').
|
|
88
|
-
- Automatically replace deprecated keyword arguments with new ones.
|
|
89
|
-
- Automatically replace deprecated values with new ones using a replacer function.
|
|
90
|
-
- Raise an error if deprecated arguments are used, depending on the specified conditions.
|
|
91
|
-
|
|
92
|
-
By default, the decorator notifies the user about the deprecated argument while the `optimum.rbln.__version__` < specified `version`
|
|
93
|
-
in the decorator. To keep notifications with any version `warn_if_greater_or_equal_version=True` can be set.
|
|
94
|
-
|
|
95
|
-
Parameters:
|
|
96
|
-
old_name (`str`):
|
|
97
|
-
Name of the deprecated keyword argument, or the argument with a deprecated value type.
|
|
98
|
-
version (`str`):
|
|
99
|
-
The version in which the keyword argument or value type was (or will be) deprecated.
|
|
100
|
-
new_name (`Optional[str]`, *optional*):
|
|
101
|
-
The new name for the deprecated keyword argument. If specified, the deprecated keyword argument will be replaced with this new name (Scenario 'a').
|
|
102
|
-
deprecated_type (`type`, *optional*):
|
|
103
|
-
The deprecated type for the keyword argument specified by `old_name` (Scenario 'b').
|
|
104
|
-
If this is set, `new_name` should typically be `None`.
|
|
105
|
-
value_replacer (`Callable`, *optional*):
|
|
106
|
-
A function that takes the old (deprecated type) value and returns a new value (Scenario 'b').
|
|
107
|
-
Used in conjunction with `deprecated_type`. If provided, the value will be automatically converted.
|
|
108
|
-
raise_if_greater_or_equal_version (`bool`, *optional*, defaults to `False`):
|
|
109
|
-
Whether to raise `ValueError` if current `optimum.rbln.` version is greater or equal to the deprecated version.
|
|
110
|
-
raise_if_both_names (`bool`, *optional*, defaults to `False`):
|
|
111
|
-
Whether to raise `ValueError` if both deprecated and new keyword arguments are set (only for Scenario 'a').
|
|
112
|
-
additional_message (`Optional[str]`, *optional*):
|
|
113
|
-
An additional message to append to the default deprecation message.
|
|
114
|
-
|
|
115
|
-
Raises:
|
|
116
|
-
ValueError:
|
|
117
|
-
If raise_if_greater_or_equal_version is True and the current version is greater than or equal to the deprecated version, or if raise_if_both_names is True and both old and new keyword arguments are provided.
|
|
118
|
-
|
|
119
|
-
Returns:
|
|
120
|
-
Callable:
|
|
121
|
-
A wrapped function that handles the deprecated keyword arguments according to the specified parameters.
|
|
122
|
-
"""
|
|
123
|
-
|
|
124
|
-
deprecated_version = packaging.version.parse(version)
|
|
125
|
-
current_version = packaging.version.parse(__version__)
|
|
126
|
-
is_greater_or_equal_version = current_version >= deprecated_version
|
|
127
|
-
|
|
128
|
-
if is_greater_or_equal_version:
|
|
129
|
-
version_message = f"and removed starting from version {version}"
|
|
130
|
-
else:
|
|
131
|
-
version_message = f"and will be removed in version {version}"
|
|
132
|
-
|
|
133
|
-
def wrapper(func):
|
|
134
|
-
# Required for better warning message
|
|
135
|
-
sig = inspect.signature(func)
|
|
136
|
-
function_named_args = set(sig.parameters.keys())
|
|
137
|
-
is_instance_method = "self" in function_named_args
|
|
138
|
-
is_class_method = "cls" in function_named_args
|
|
139
|
-
|
|
140
|
-
@wraps(func)
|
|
141
|
-
def wrapped_func(*args, **kwargs):
|
|
142
|
-
# Get class + function name (just for better warning message)
|
|
143
|
-
func_name = func.__name__
|
|
144
|
-
if is_instance_method:
|
|
145
|
-
func_name = f"{args[0].__class__.__name__}.{func_name}"
|
|
146
|
-
elif is_class_method:
|
|
147
|
-
func_name = f"{args[0].__name__}.{func_name}"
|
|
148
|
-
|
|
149
|
-
minimum_action = Action.NONE
|
|
150
|
-
message = None
|
|
151
|
-
|
|
152
|
-
# Scenario A: Rename (e.g., a -> a')
|
|
153
|
-
if new_name is not None:
|
|
154
|
-
if old_name in kwargs and new_name in kwargs:
|
|
155
|
-
minimum_action = Action.RAISE if raise_if_both_names else Action.NOTIFY
|
|
156
|
-
message = f"Both `{old_name}` and `{new_name}` are set for `{func_name}`. Using `{new_name}={kwargs[new_name]}` and ignoring deprecated `{old_name}={kwargs[old_name]}`."
|
|
157
|
-
kwargs.pop(old_name)
|
|
158
|
-
|
|
159
|
-
elif old_name in kwargs and new_name not in kwargs:
|
|
160
|
-
minimum_action = Action.NOTIFY
|
|
161
|
-
message = (
|
|
162
|
-
f"`{old_name}` is deprecated {version_message} for `{func_name}`. Use `{new_name}` instead."
|
|
163
|
-
)
|
|
164
|
-
kwargs[new_name] = kwargs.pop(old_name)
|
|
165
|
-
|
|
166
|
-
# Scenario B: Value Type Change (e.g., b: bool -> str)
|
|
167
|
-
if deprecated_type is not None:
|
|
168
|
-
key_to_check = old_name if new_name is None else new_name # For Senario A + B Mixed
|
|
169
|
-
if key_to_check in kwargs and isinstance(kwargs[key_to_check], deprecated_type):
|
|
170
|
-
minimum_action = Action.NOTIFY
|
|
171
|
-
old_value = kwargs[key_to_check]
|
|
172
|
-
message = f"Using type `{deprecated_type.__name__}` for argument `{key_to_check}` in `{func_name}` is deprecated {version_message}."
|
|
173
|
-
|
|
174
|
-
if value_replacer:
|
|
175
|
-
try:
|
|
176
|
-
new_value = value_replacer(old_value)
|
|
177
|
-
kwargs[key_to_check] = new_value
|
|
178
|
-
message += f" Value `{old_value}` has been automatically replaced with `{new_value}`."
|
|
179
|
-
except Exception as e:
|
|
180
|
-
logger.error(f"Error during deprecated value replacement for {key_to_check}: {e}")
|
|
181
|
-
message += f" Automatic replacement failed: {e}. Passing original value."
|
|
182
|
-
else:
|
|
183
|
-
raise ValueError(
|
|
184
|
-
f"value_replacer should be provided when deprecated_type is set for {key_to_check} in {func_name}"
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
# Scenario C: Deletion (e.g., c)
|
|
188
|
-
if old_name in kwargs and new_name is None and deprecated_type is None:
|
|
189
|
-
minimum_action = Action.NOTIFY
|
|
190
|
-
message = f"`{old_name}` is deprecated {version_message} for `{func_name}`."
|
|
191
|
-
kwargs.pop(old_name)
|
|
192
|
-
|
|
193
|
-
if message is not None and additional_message is not None:
|
|
194
|
-
message = f"{message} {additional_message}"
|
|
195
|
-
|
|
196
|
-
# update minimum_action if argument is ALREADY deprecated (current version >= deprecated version)
|
|
197
|
-
if is_greater_or_equal_version:
|
|
198
|
-
# change to NOTIFY -> RAISE in case we want to raise error for already deprecated arguments
|
|
199
|
-
if raise_if_greater_or_equal_version:
|
|
200
|
-
minimum_action = Action.RAISE
|
|
201
|
-
|
|
202
|
-
# raise error or notify user
|
|
203
|
-
if minimum_action == Action.RAISE:
|
|
204
|
-
raise ValueError(message)
|
|
205
|
-
elif minimum_action == Action.NOTIFY:
|
|
206
|
-
# DeprecationWarning is ignored by default, so we use FutureWarning instead
|
|
207
|
-
logger.warning(message, stacklevel=2)
|
|
208
|
-
|
|
209
|
-
return func(*args, **kwargs)
|
|
210
|
-
|
|
211
|
-
return wrapped_func
|
|
212
|
-
|
|
213
|
-
return wrapper
|
|
File without changes
|
|
File without changes
|