optimum-rbln 0.8.2a0__py3-none-any.whl → 0.9.3__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 +116 -9
- optimum/rbln/__version__.py +16 -3
- optimum/rbln/cli.py +660 -0
- optimum/rbln/configuration_utils.py +171 -43
- optimum/rbln/diffusers/__init__.py +19 -0
- optimum/rbln/diffusers/configurations/__init__.py +3 -0
- optimum/rbln/diffusers/configurations/models/__init__.py +2 -0
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl.py +3 -3
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl_cosmos.py +1 -1
- optimum/rbln/diffusers/configurations/models/configuration_autoencoder_kl_temporal_decoder.py +67 -0
- optimum/rbln/diffusers/configurations/models/configuration_controlnet.py +3 -3
- optimum/rbln/diffusers/configurations/models/configuration_prior_transformer.py +4 -4
- optimum/rbln/diffusers/configurations/models/configuration_transformer_cosmos.py +12 -4
- optimum/rbln/diffusers/configurations/models/configuration_transformer_sd3.py +9 -4
- optimum/rbln/diffusers/configurations/models/configuration_unet_2d_condition.py +3 -3
- optimum/rbln/diffusers/configurations/models/configuration_unet_spatio_temporal_condition.py +59 -0
- optimum/rbln/diffusers/configurations/models/configuration_vq_model.py +3 -3
- optimum/rbln/diffusers/configurations/pipelines/__init__.py +3 -0
- optimum/rbln/diffusers/configurations/pipelines/configuration_controlnet.py +35 -19
- optimum/rbln/diffusers/configurations/pipelines/configuration_cosmos.py +14 -11
- optimum/rbln/diffusers/configurations/pipelines/configuration_kandinsky2_2.py +30 -20
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion.py +13 -9
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_3.py +17 -13
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_diffusion_xl.py +17 -10
- optimum/rbln/diffusers/configurations/pipelines/configuration_stable_video_diffusion.py +114 -0
- optimum/rbln/diffusers/modeling_diffusers.py +33 -18
- optimum/rbln/diffusers/models/__init__.py +4 -0
- optimum/rbln/diffusers/models/autoencoders/__init__.py +1 -0
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl.py +32 -3
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl_cosmos.py +32 -6
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py +275 -0
- optimum/rbln/diffusers/models/autoencoders/vae.py +27 -8
- optimum/rbln/diffusers/models/autoencoders/vq_model.py +32 -3
- optimum/rbln/diffusers/models/controlnet.py +16 -1
- optimum/rbln/diffusers/models/transformers/prior_transformer.py +17 -3
- optimum/rbln/diffusers/models/transformers/transformer_cosmos.py +26 -3
- optimum/rbln/diffusers/models/transformers/transformer_sd3.py +23 -2
- optimum/rbln/diffusers/models/unets/__init__.py +1 -0
- optimum/rbln/diffusers/models/unets/unet_2d_condition.py +23 -4
- optimum/rbln/diffusers/models/unets/unet_spatio_temporal_condition.py +201 -0
- optimum/rbln/diffusers/pipelines/__init__.py +15 -5
- optimum/rbln/diffusers/pipelines/auto_pipeline.py +307 -0
- optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +20 -0
- optimum/rbln/diffusers/pipelines/cosmos/configuration_cosmos_guardrail.py +23 -12
- optimum/rbln/diffusers/pipelines/cosmos/cosmos_guardrail.py +16 -46
- optimum/rbln/diffusers/pipelines/cosmos/pipeline_cosmos_text2world.py +31 -1
- optimum/rbln/diffusers/pipelines/cosmos/pipeline_cosmos_video2world.py +31 -1
- optimum/rbln/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +1 -6
- optimum/rbln/diffusers/pipelines/stable_video_diffusion/__init__.py +15 -0
- optimum/rbln/diffusers/pipelines/stable_video_diffusion/pipeline_stable_video_diffusion.py +46 -0
- optimum/rbln/modeling.py +50 -24
- optimum/rbln/modeling_base.py +116 -35
- optimum/rbln/ops/attn.py +158 -0
- optimum/rbln/ops/flash_attn.py +166 -0
- optimum/rbln/ops/kv_cache_update.py +5 -0
- optimum/rbln/ops/linear.py +7 -0
- optimum/rbln/transformers/__init__.py +100 -0
- optimum/rbln/transformers/configuration_generic.py +7 -32
- optimum/rbln/transformers/modeling_attention_utils.py +385 -0
- optimum/rbln/transformers/modeling_generic.py +48 -65
- optimum/rbln/transformers/modeling_outputs.py +37 -0
- optimum/rbln/transformers/models/__init__.py +93 -30
- optimum/rbln/transformers/models/audio_spectrogram_transformer/configuration_audio_spectrogram_transformer.py +28 -2
- optimum/rbln/transformers/models/audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.py +68 -5
- optimum/rbln/transformers/models/auto/__init__.py +2 -0
- optimum/rbln/transformers/models/auto/auto_factory.py +92 -17
- optimum/rbln/transformers/models/auto/modeling_auto.py +45 -0
- optimum/rbln/transformers/models/bart/bart_architecture.py +2 -7
- optimum/rbln/transformers/models/bart/configuration_bart.py +2 -0
- optimum/rbln/transformers/models/bart/modeling_bart.py +23 -2
- optimum/rbln/transformers/models/bert/bert_architecture.py +16 -0
- optimum/rbln/transformers/models/bert/modeling_bert.py +93 -4
- optimum/rbln/transformers/models/blip_2/configuration_blip_2.py +42 -11
- optimum/rbln/transformers/models/blip_2/modeling_blip_2.py +135 -44
- optimum/rbln/transformers/models/clip/configuration_clip.py +21 -7
- optimum/rbln/transformers/models/clip/modeling_clip.py +183 -27
- optimum/rbln/transformers/models/colpali/colpali_architecture.py +3 -6
- optimum/rbln/transformers/models/colpali/configuration_colpali.py +37 -21
- optimum/rbln/transformers/models/colpali/modeling_colpali.py +82 -104
- optimum/rbln/transformers/models/colqwen2/__init__.py +2 -0
- optimum/rbln/transformers/models/colqwen2/colqwen2_architecture.py +233 -0
- optimum/rbln/transformers/models/colqwen2/configuration_colqwen2.py +74 -0
- optimum/rbln/transformers/models/colqwen2/modeling_colqwen2.py +446 -0
- optimum/rbln/transformers/models/decoderonly/__init__.py +3 -2
- optimum/rbln/transformers/models/decoderonly/configuration_decoderonly.py +114 -37
- optimum/rbln/transformers/models/decoderonly/configuration_lora.py +411 -0
- optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +323 -316
- optimum/rbln/transformers/models/decoderonly/decoderonly_runtime_utils.py +508 -0
- optimum/rbln/transformers/models/decoderonly/generation_decoderonly.py +119 -0
- optimum/rbln/transformers/models/decoderonly/lora_architecture.py +204 -0
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +486 -892
- optimum/rbln/transformers/models/depth_anything/__init__.py +16 -0
- optimum/rbln/transformers/models/depth_anything/configuration_depth_anything.py +24 -0
- optimum/rbln/transformers/models/depth_anything/modeling_depth_anything.py +42 -0
- optimum/rbln/transformers/models/distilbert/modeling_distilbert.py +24 -0
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +17 -0
- optimum/rbln/transformers/models/exaone/modeling_exaone.py +42 -4
- 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 +1 -4
- optimum/rbln/transformers/models/gemma/modeling_gemma.py +22 -1
- optimum/rbln/transformers/models/gemma3/configuration_gemma3.py +49 -14
- optimum/rbln/transformers/models/gemma3/gemma3_architecture.py +12 -2
- optimum/rbln/transformers/models/gemma3/gemma3_runtime_utils.py +245 -0
- optimum/rbln/transformers/models/gemma3/modeling_gemma3.py +212 -504
- 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 +10 -8
- optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +18 -1
- optimum/rbln/transformers/models/grounding_dino/__init__.py +10 -0
- optimum/rbln/transformers/models/grounding_dino/configuration_grounding_dino.py +92 -0
- optimum/rbln/transformers/models/grounding_dino/grounding_dino_architecture.py +599 -0
- optimum/rbln/transformers/models/grounding_dino/modeling_grounding_dino.py +1048 -0
- optimum/rbln/transformers/models/idefics3/configuration_idefics3.py +35 -7
- optimum/rbln/transformers/models/idefics3/modeling_idefics3.py +29 -32
- 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 +72 -0
- optimum/rbln/transformers/models/llava/modeling_llava.py +490 -0
- optimum/rbln/transformers/models/llava_next/configuration_llava_next.py +21 -6
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +234 -376
- optimum/rbln/transformers/models/midm/midm_architecture.py +4 -1
- optimum/rbln/transformers/models/midm/modeling_midm.py +42 -4
- 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 +29 -17
- optimum/rbln/transformers/models/opt/opt_architecture.py +4 -4
- optimum/rbln/transformers/models/pegasus/__init__.py +17 -0
- optimum/rbln/transformers/models/pegasus/configuration_pegasus.py +38 -0
- optimum/rbln/transformers/models/pegasus/modeling_pegasus.py +71 -0
- optimum/rbln/transformers/models/pegasus/pegasus_architecture.py +161 -0
- optimum/rbln/transformers/models/phi/__init__.py +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 +11 -7
- optimum/rbln/transformers/models/pixtral/__init__.py +16 -0
- optimum/rbln/transformers/models/pixtral/configuration_pixtral.py +43 -0
- optimum/rbln/transformers/models/pixtral/modeling_pixtral.py +322 -0
- optimum/rbln/transformers/models/pixtral/pixtral_architecture.py +73 -0
- optimum/rbln/transformers/models/qwen2/__init__.py +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 +21 -6
- optimum/rbln/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py +15 -22
- optimum/rbln/transformers/models/qwen2_5_vl/qwen2_5_vl_architecture.py +28 -7
- optimum/rbln/transformers/models/qwen2_vl/__init__.py +19 -0
- optimum/rbln/transformers/models/qwen2_vl/configuration_qwen2_vl.py +88 -0
- optimum/rbln/transformers/models/qwen2_vl/modeling_qwen2_vl.py +513 -0
- optimum/rbln/transformers/models/qwen2_vl/qwen2_vl_architecture.py +165 -0
- optimum/rbln/transformers/models/qwen3/__init__.py +16 -0
- optimum/rbln/transformers/models/qwen3/configuration_qwen3.py +71 -0
- optimum/rbln/transformers/models/qwen3/modeling_qwen3.py +133 -0
- optimum/rbln/transformers/models/qwen3/qwen3_architecture.py +31 -0
- optimum/rbln/transformers/models/resnet/configuration_resnet.py +17 -0
- optimum/rbln/transformers/models/resnet/modeling_resnet.py +73 -0
- optimum/rbln/transformers/models/roberta/modeling_roberta.py +33 -0
- optimum/rbln/transformers/models/seq2seq/configuration_seq2seq.py +21 -16
- optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +60 -13
- optimum/rbln/transformers/models/seq2seq/seq2seq_architecture.py +2 -2
- optimum/rbln/transformers/models/siglip/__init__.py +2 -6
- optimum/rbln/transformers/models/siglip/configuration_siglip.py +1 -1
- optimum/rbln/transformers/models/siglip/modeling_siglip.py +21 -16
- optimum/rbln/transformers/models/swin/__init__.py +16 -0
- optimum/rbln/transformers/models/swin/configuration_swin.py +42 -0
- optimum/rbln/transformers/models/swin/modeling_swin.py +354 -0
- optimum/rbln/transformers/models/t5/configuration_t5.py +2 -0
- optimum/rbln/transformers/models/t5/modeling_t5.py +2 -2
- optimum/rbln/transformers/models/t5/t5_architecture.py +8 -1
- optimum/rbln/transformers/models/time_series_transformer/configuration_time_series_transformer.py +3 -3
- optimum/rbln/transformers/models/time_series_transformer/modeling_time_series_transformer.py +22 -16
- optimum/rbln/transformers/models/time_series_transformer/time_series_transformers_architecture.py +7 -1
- optimum/rbln/transformers/models/vit/modeling_vit.py +19 -0
- optimum/rbln/transformers/models/wav2vec2/configuration_wav2vec2.py +15 -3
- optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py +61 -8
- optimum/rbln/transformers/models/whisper/configuration_whisper.py +12 -13
- optimum/rbln/transformers/models/whisper/generation_whisper.py +62 -6
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +32 -5
- optimum/rbln/transformers/models/xlm_roberta/__init__.py +2 -8
- optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +43 -0
- optimum/rbln/transformers/utils/rbln_quantization.py +400 -75
- optimum/rbln/transformers/utils/rbln_runtime_wrapper.py +79 -0
- optimum/rbln/utils/deprecation.py +213 -0
- optimum/rbln/utils/hub.py +22 -50
- optimum/rbln/utils/runtime_utils.py +85 -17
- optimum/rbln/utils/submodule.py +31 -9
- {optimum_rbln-0.8.2a0.dist-info → optimum_rbln-0.9.3.dist-info}/METADATA +8 -7
- optimum_rbln-0.9.3.dist-info/RECORD +264 -0
- {optimum_rbln-0.8.2a0.dist-info → optimum_rbln-0.9.3.dist-info}/WHEEL +1 -1
- optimum_rbln-0.9.3.dist-info/entry_points.txt +2 -0
- optimum_rbln-0.8.2a0.dist-info/RECORD +0 -211
- {optimum_rbln-0.8.2a0.dist-info → optimum_rbln-0.9.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
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
|
optimum/rbln/utils/hub.py
CHANGED
|
@@ -12,59 +12,24 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import json
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
from typing import List, Optional, Union
|
|
18
18
|
|
|
19
|
-
from huggingface_hub import HfApi,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class PushToHubMixin:
|
|
23
|
-
def push_to_hub(
|
|
24
|
-
self,
|
|
25
|
-
save_directory: str,
|
|
26
|
-
repository_id: str,
|
|
27
|
-
private: Optional[bool] = None,
|
|
28
|
-
use_auth_token: Union[bool, str] = True,
|
|
29
|
-
) -> str:
|
|
30
|
-
huggingface_token = _get_huggingface_token(use_auth_token)
|
|
31
|
-
api = HfApi()
|
|
32
|
-
|
|
33
|
-
api.create_repo(
|
|
34
|
-
token=huggingface_token,
|
|
35
|
-
repo_id=repository_id,
|
|
36
|
-
exist_ok=True,
|
|
37
|
-
private=private,
|
|
38
|
-
)
|
|
39
|
-
for path, subdirs, files in os.walk(save_directory):
|
|
40
|
-
for name in files:
|
|
41
|
-
local_file_path = os.path.join(path, name)
|
|
42
|
-
_, hub_file_path = os.path.split(local_file_path)
|
|
43
|
-
# FIXME: when huggingface_hub fixes the return of upload_file
|
|
44
|
-
try:
|
|
45
|
-
api.upload_file(
|
|
46
|
-
token=huggingface_token,
|
|
47
|
-
repo_id=f"{repository_id}",
|
|
48
|
-
path_or_fileobj=os.path.join(os.getcwd(), local_file_path),
|
|
49
|
-
path_in_repo=hub_file_path,
|
|
50
|
-
)
|
|
51
|
-
except KeyError:
|
|
52
|
-
pass
|
|
53
|
-
except NameError:
|
|
54
|
-
pass
|
|
19
|
+
from huggingface_hub import HfApi, get_token, hf_hub_download
|
|
55
20
|
|
|
56
21
|
|
|
57
22
|
def pull_compiled_model_from_hub(
|
|
58
23
|
model_id: Union[str, Path],
|
|
59
24
|
subfolder: str,
|
|
60
|
-
|
|
25
|
+
token: Union[bool, str],
|
|
61
26
|
revision: Optional[str],
|
|
62
27
|
cache_dir: Optional[str],
|
|
63
28
|
force_download: bool,
|
|
64
29
|
local_files_only: bool,
|
|
65
30
|
) -> Path:
|
|
66
31
|
"""Pull model files from the HuggingFace Hub."""
|
|
67
|
-
huggingface_token = _get_huggingface_token(
|
|
32
|
+
huggingface_token = _get_huggingface_token(token)
|
|
68
33
|
repo_files = list(
|
|
69
34
|
map(
|
|
70
35
|
Path,
|
|
@@ -87,7 +52,7 @@ def pull_compiled_model_from_hub(
|
|
|
87
52
|
repo_id=model_id,
|
|
88
53
|
filename=filename,
|
|
89
54
|
subfolder=subfolder,
|
|
90
|
-
|
|
55
|
+
token=token,
|
|
91
56
|
revision=revision,
|
|
92
57
|
cache_dir=cache_dir,
|
|
93
58
|
force_download=force_download,
|
|
@@ -103,20 +68,27 @@ def validate_files(
|
|
|
103
68
|
location: str,
|
|
104
69
|
):
|
|
105
70
|
"""Validate the presence and count of required files."""
|
|
106
|
-
if len(files) == 0:
|
|
107
|
-
raise FileNotFoundError(f"Could not find any rbln model file in {location}")
|
|
108
|
-
|
|
109
71
|
if len(config_files) == 0:
|
|
110
72
|
raise FileNotFoundError(f"Could not find `rbln_config.json` file in {location}")
|
|
111
73
|
|
|
112
74
|
if len(config_files) > 1:
|
|
113
75
|
raise FileExistsError(f"Multiple rbln_config.json files found in {location}. This is not expected.")
|
|
114
76
|
|
|
77
|
+
try:
|
|
78
|
+
with open(config_files[0], "r") as f:
|
|
79
|
+
config_data = json.load(f)
|
|
80
|
+
compile_cfgs = config_data.get("_compile_cfgs", [])
|
|
81
|
+
if len(compile_cfgs) == 0:
|
|
82
|
+
# If compile_cfgs is empty, we don't need .rbln files
|
|
83
|
+
return
|
|
84
|
+
except (json.JSONDecodeError, KeyError, OSError):
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
if len(files) == 0:
|
|
88
|
+
raise FileNotFoundError(f"Could not find any rbln model file in {location}")
|
|
89
|
+
|
|
115
90
|
|
|
116
|
-
def _get_huggingface_token(
|
|
117
|
-
if isinstance(
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
return HfFolder.get_token()
|
|
121
|
-
else:
|
|
122
|
-
raise ValueError("`use_auth_token` must be provided to interact with the HuggingFace Hub.")
|
|
91
|
+
def _get_huggingface_token(token: Union[bool, str]) -> str:
|
|
92
|
+
if isinstance(token, str):
|
|
93
|
+
return token
|
|
94
|
+
return get_token()
|
|
@@ -12,13 +12,61 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import re
|
|
15
16
|
import threading
|
|
16
|
-
from typing import Any,
|
|
17
|
+
from typing import Any, List, Optional, Union
|
|
17
18
|
|
|
18
19
|
import rebel
|
|
19
20
|
import torch
|
|
20
21
|
|
|
21
22
|
|
|
23
|
+
def get_available_dram(npu: Optional[str] = None) -> int:
|
|
24
|
+
"""
|
|
25
|
+
Get the available DRAM size of the specified NPU.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
npu : Optional[str], default=None
|
|
29
|
+
The NPU to get the available DRAM size.
|
|
30
|
+
If None, the function will attempt to retrieve through `ensure_valid_npu()`
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
int
|
|
34
|
+
The available DRAM size in bytes.
|
|
35
|
+
"""
|
|
36
|
+
if npu is None:
|
|
37
|
+
if not rebel.npu_is_available(0):
|
|
38
|
+
raise RuntimeError("No NPU is available to get available DRAM size.")
|
|
39
|
+
|
|
40
|
+
npu = rebel.get_npu_name(0)
|
|
41
|
+
|
|
42
|
+
if npu.startswith("RBLN-CR"):
|
|
43
|
+
# TODO(jongho): Assuming 4 chiplets.
|
|
44
|
+
DRAM_NBYTES = 144 * 2**30
|
|
45
|
+
SYS_DRAM_NBYTES = 4 * 2**30
|
|
46
|
+
elif npu.startswith("RBLN-CA"):
|
|
47
|
+
DRAM_NBYTES = 16 * 2**30
|
|
48
|
+
SYS_DRAM_NBYTES = 288 * 2**20
|
|
49
|
+
else:
|
|
50
|
+
raise ValueError(f"Unknown npu name: {npu}")
|
|
51
|
+
|
|
52
|
+
return DRAM_NBYTES - SYS_DRAM_NBYTES
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def normalize_npu(npu: str) -> str:
|
|
56
|
+
"""Normalize the NPU string by removing the form factor."""
|
|
57
|
+
match = re.match(r"(RBLN-CA|RBLN-CR)(\d+)", npu)
|
|
58
|
+
if match:
|
|
59
|
+
prefix, num = match.groups()
|
|
60
|
+
if len(num) == 1:
|
|
61
|
+
# Convert "RBLN-CAx" → "RBLN-CA0"
|
|
62
|
+
# (e.g., "RBLN-CA2" -> "RBLN-CA0")
|
|
63
|
+
npu = f"{prefix}0"
|
|
64
|
+
elif len(num) == 2:
|
|
65
|
+
# Strip form factor (e.g., "RBLN-CA15" → "RBLN-CA1")
|
|
66
|
+
npu = f"{prefix}{num[:-1]}"
|
|
67
|
+
return npu
|
|
68
|
+
|
|
69
|
+
|
|
22
70
|
def tp_and_devices_are_ok(
|
|
23
71
|
tensor_parallel_size: Optional[int] = None,
|
|
24
72
|
device: Optional[Union[int, List[int]]] = None,
|
|
@@ -58,7 +106,7 @@ def tp_and_devices_are_ok(
|
|
|
58
106
|
if npu is not None:
|
|
59
107
|
for device_id in device:
|
|
60
108
|
npu_name = rebel.get_npu_name(device_id)
|
|
61
|
-
if npu_name != npu:
|
|
109
|
+
if normalize_npu(npu_name) != normalize_npu(npu):
|
|
62
110
|
return f"Device {device_id} ({npu_name}) is not on the same NPU as {npu}."
|
|
63
111
|
|
|
64
112
|
return None
|
|
@@ -78,7 +126,7 @@ class RBLNPytorchRuntime:
|
|
|
78
126
|
def __call__(self, *args: Any, **kwds: Any) -> Any:
|
|
79
127
|
return self.forward(*args, **kwds)
|
|
80
128
|
|
|
81
|
-
def forward(self, *args: List["torch.Tensor"], **kwargs:
|
|
129
|
+
def forward(self, *args: List["torch.Tensor"], **kwargs: "torch.Tensor"):
|
|
82
130
|
# filtering useless args or kwarg such as None.
|
|
83
131
|
args = list(filter(lambda arg: isinstance(arg, torch.Tensor), args))
|
|
84
132
|
kwargs = dict(filter(lambda kwarg: isinstance(kwarg[1], torch.Tensor) or kwarg[0] == "out", kwargs.items()))
|
|
@@ -126,7 +174,7 @@ class UnavailableRuntime:
|
|
|
126
174
|
"""Returns an iterator with self as the only item."""
|
|
127
175
|
return iter([self])
|
|
128
176
|
|
|
129
|
-
def forward(self, *args: List["torch.Tensor"], **kwargs:
|
|
177
|
+
def forward(self, *args: List["torch.Tensor"], **kwargs: "torch.Tensor"):
|
|
130
178
|
"""Raises a detailed RuntimeError explaining why inference cannot be performed."""
|
|
131
179
|
raise RuntimeError(
|
|
132
180
|
"Cannot perform inference: RBLN runtime is not available.\n\n"
|
|
@@ -147,28 +195,48 @@ class ContextRblnConfig:
|
|
|
147
195
|
_local = threading.local()
|
|
148
196
|
|
|
149
197
|
def __init__(
|
|
150
|
-
self,
|
|
198
|
+
self,
|
|
199
|
+
device=None,
|
|
200
|
+
device_map=None,
|
|
201
|
+
create_runtimes=None,
|
|
202
|
+
activate_profiler=None,
|
|
203
|
+
timeout=None,
|
|
151
204
|
):
|
|
152
205
|
self.device = device
|
|
153
206
|
self.device_map = device_map
|
|
154
207
|
self.create_runtimes = create_runtimes
|
|
155
|
-
self.optimize_host_mem = optimize_host_mem
|
|
156
208
|
self.activate_profiler = activate_profiler
|
|
209
|
+
self.timeout = timeout
|
|
210
|
+
self._previous_context = None
|
|
157
211
|
|
|
158
212
|
def __enter__(self):
|
|
159
|
-
self.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
213
|
+
self._previous_context = {
|
|
214
|
+
"device": getattr(self._local, "device", None),
|
|
215
|
+
"device_map": getattr(self._local, "device_map", None),
|
|
216
|
+
"create_runtimes": getattr(self._local, "create_runtimes", None),
|
|
217
|
+
"activate_profiler": getattr(self._local, "activate_profiler", None),
|
|
218
|
+
"timeout": getattr(self._local, "timeout", None),
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if self.device is not None:
|
|
222
|
+
self._local.device = self.device
|
|
223
|
+
if self.device_map is not None:
|
|
224
|
+
self._local.device_map = self.device_map
|
|
225
|
+
if self.create_runtimes is not None:
|
|
226
|
+
self._local.create_runtimes = self.create_runtimes
|
|
227
|
+
if self.activate_profiler is not None:
|
|
228
|
+
self._local.activate_profiler = self.activate_profiler
|
|
229
|
+
if self.timeout is not None:
|
|
230
|
+
self._local.timeout = self.timeout
|
|
164
231
|
return self
|
|
165
232
|
|
|
166
233
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
167
|
-
self.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
234
|
+
if self._previous_context is not None:
|
|
235
|
+
self._local.device = self._previous_context["device"]
|
|
236
|
+
self._local.device_map = self._previous_context["device_map"]
|
|
237
|
+
self._local.create_runtimes = self._previous_context["create_runtimes"]
|
|
238
|
+
self._local.activate_profiler = self._previous_context["activate_profiler"]
|
|
239
|
+
self._local.timeout = self._previous_context["timeout"]
|
|
172
240
|
|
|
173
241
|
@classmethod
|
|
174
242
|
def get_current_context(cls):
|
|
@@ -176,6 +244,6 @@ class ContextRblnConfig:
|
|
|
176
244
|
"device": getattr(cls._local, "device", None),
|
|
177
245
|
"device_map": getattr(cls._local, "device_map", None),
|
|
178
246
|
"create_runtimes": getattr(cls._local, "create_runtimes", None),
|
|
179
|
-
"optimize_host_memory": getattr(cls._local, "optimize_host_memory", None),
|
|
180
247
|
"activate_profiler": getattr(cls._local, "activate_profiler", None),
|
|
248
|
+
"timeout": getattr(cls._local, "timeout", None),
|
|
181
249
|
}
|
optimum/rbln/utils/submodule.py
CHANGED
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
from pathlib import Path
|
|
16
|
-
from typing import TYPE_CHECKING, Any, Dict, List, Type
|
|
16
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, Union
|
|
17
17
|
|
|
18
18
|
from transformers import PretrainedConfig
|
|
19
19
|
|
|
20
|
-
from ..configuration_utils import RBLNModelConfig
|
|
20
|
+
from ..configuration_utils import RBLNModelConfig, get_rbln_config_class
|
|
21
21
|
from ..utils.model_utils import get_rbln_model_cls
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
if TYPE_CHECKING:
|
|
25
|
-
from transformers import PreTrainedModel
|
|
25
|
+
from transformers import AutoFeatureExtractor, AutoProcessor, AutoTokenizer, PreTrainedModel
|
|
26
26
|
|
|
27
27
|
from ..modeling import RBLNModel
|
|
28
28
|
|
|
@@ -42,7 +42,21 @@ class SubModulesMixin:
|
|
|
42
42
|
setattr(self, submodule_meta["name"], submodule)
|
|
43
43
|
|
|
44
44
|
@classmethod
|
|
45
|
-
def
|
|
45
|
+
def _get_submodule_config_class(
|
|
46
|
+
cls, cls_name: str, submodule_rbln_config: Dict[str, Any]
|
|
47
|
+
) -> Type[RBLNModelConfig]:
|
|
48
|
+
if isinstance(submodule_rbln_config, dict) and "cls_name" in submodule_rbln_config:
|
|
49
|
+
config_cls_name = submodule_rbln_config["cls_name"]
|
|
50
|
+
return get_rbln_config_class(config_cls_name)
|
|
51
|
+
return get_rbln_config_class(f"RBLN{cls_name}Config")
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def _update_submodule_config(
|
|
55
|
+
cls,
|
|
56
|
+
model: "PreTrainedModel",
|
|
57
|
+
rbln_config: RBLNModelConfig,
|
|
58
|
+
preprocessors: Optional[Union["AutoFeatureExtractor", "AutoProcessor", "AutoTokenizer"]],
|
|
59
|
+
):
|
|
46
60
|
return rbln_config
|
|
47
61
|
|
|
48
62
|
@classmethod
|
|
@@ -51,6 +65,7 @@ class SubModulesMixin:
|
|
|
51
65
|
) -> List["RBLNModel"]:
|
|
52
66
|
rbln_submodules = []
|
|
53
67
|
submodule_prefix = getattr(cls, "_rbln_submodule_prefix", None)
|
|
68
|
+
preprocessors = kwargs.pop("preprocessors", [])
|
|
54
69
|
|
|
55
70
|
for submodule in cls._rbln_submodules:
|
|
56
71
|
submodule_name = submodule["name"]
|
|
@@ -63,13 +78,20 @@ class SubModulesMixin:
|
|
|
63
78
|
cls_name = torch_submodule.__class__.__name__
|
|
64
79
|
submodule_cls: Type["RBLNModel"] = get_rbln_model_cls(f"RBLN{cls_name}")
|
|
65
80
|
submodule_rbln_config = getattr(rbln_config, submodule_name) or {}
|
|
81
|
+
submodule_config_cls = cls._get_submodule_config_class(cls_name, submodule_rbln_config)
|
|
66
82
|
|
|
67
83
|
if isinstance(submodule_rbln_config, dict):
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
filtered_kwargs = rbln_config.filter_parameters(submodule_config_cls, submodule_rbln_config)
|
|
85
|
+
filtered_kwargs["cls_name"] = submodule_config_cls.__name__
|
|
86
|
+
submodule_rbln_config = submodule_config_cls(**filtered_kwargs)
|
|
87
|
+
elif not isinstance(submodule_rbln_config, submodule_config_cls):
|
|
88
|
+
config_dict = {k: v for k, v in submodule_rbln_config.__dict__.items() if not k.startswith("_")}
|
|
89
|
+
filtered_kwargs = rbln_config.filter_parameters(submodule_config_cls, config_dict)
|
|
90
|
+
filtered_kwargs["cls_name"] = submodule_config_cls.__name__
|
|
91
|
+
submodule_rbln_config = submodule_config_cls(**filtered_kwargs)
|
|
92
|
+
|
|
93
|
+
setattr(rbln_config, submodule_name, submodule_rbln_config)
|
|
94
|
+
submodule_rbln_config = submodule_cls._update_submodule_config(model, submodule_rbln_config, preprocessors)
|
|
73
95
|
|
|
74
96
|
rbln_submodule = submodule_cls.from_model(
|
|
75
97
|
model=torch_submodule,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: optimum-rbln
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.3
|
|
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
|
|
@@ -20,15 +20,16 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
24
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
-
Requires-Python: <3.
|
|
25
|
+
Requires-Python: <3.14,>=3.9
|
|
25
26
|
Requires-Dist: accelerate>=1.0.1
|
|
26
|
-
Requires-Dist: diffusers==0.
|
|
27
|
+
Requires-Dist: diffusers==0.35.2
|
|
27
28
|
Requires-Dist: packaging>=24.1
|
|
28
|
-
Requires-Dist: torch==2.
|
|
29
|
-
Requires-Dist: torchaudio<=2.
|
|
30
|
-
Requires-Dist: torchvision<=0.
|
|
31
|
-
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
|
|
32
33
|
Description-Content-Type: text/markdown
|
|
33
34
|
|
|
34
35
|
|