optimum-rbln 0.2.1a0__py3-none-any.whl → 0.2.1a1__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 +1 -10
- optimum/rbln/__version__.py +1 -1
- optimum/rbln/diffusers/__init__.py +1 -10
- optimum/rbln/diffusers/modeling_diffusers.py +1 -10
- optimum/rbln/diffusers/models/__init__.py +1 -10
- optimum/rbln/diffusers/models/autoencoders/__init__.py +1 -10
- optimum/rbln/diffusers/models/autoencoders/autoencoder_kl.py +1 -10
- optimum/rbln/diffusers/models/autoencoders/vae.py +1 -10
- optimum/rbln/diffusers/models/controlnet.py +1 -10
- optimum/rbln/diffusers/models/transformers/__init__.py +1 -10
- optimum/rbln/diffusers/models/transformers/transformer_sd3.py +1 -10
- optimum/rbln/diffusers/models/unets/__init__.py +1 -10
- optimum/rbln/diffusers/models/unets/unet_2d_condition.py +1 -10
- optimum/rbln/diffusers/pipelines/__init__.py +1 -10
- optimum/rbln/diffusers/pipelines/controlnet/__init__.py +1 -10
- optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +1 -10
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py +1 -10
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +1 -10
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +1 -10
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion/__init__.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/__init__.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/__init__.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +1 -10
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +1 -10
- optimum/rbln/modeling.py +1 -10
- optimum/rbln/modeling_base.py +1 -10
- optimum/rbln/modeling_config.py +1 -10
- optimum/rbln/ops/__init__.py +1 -10
- optimum/rbln/ops/attn.py +5 -14
- optimum/rbln/ops/flash_attn.py +5 -14
- optimum/rbln/ops/kv_cache_update.py +1 -10
- optimum/rbln/transformers/__init__.py +3 -12
- optimum/rbln/transformers/modeling_alias.py +1 -14
- optimum/rbln/transformers/modeling_generic.py +40 -21
- optimum/rbln/transformers/modeling_rope_utils.py +28 -0
- optimum/rbln/transformers/models/__init__.py +3 -12
- optimum/rbln/transformers/models/auto/__init__.py +1 -10
- optimum/rbln/transformers/models/auto/auto_factory.py +1 -10
- optimum/rbln/transformers/models/auto/modeling_auto.py +1 -10
- optimum/rbln/transformers/models/bart/__init__.py +1 -10
- optimum/rbln/transformers/models/bart/bart_architecture.py +1 -10
- optimum/rbln/transformers/models/bart/modeling_bart.py +14 -13
- optimum/rbln/transformers/models/bert/__init__.py +2 -11
- optimum/rbln/transformers/models/bert/modeling_bert.py +19 -13
- optimum/rbln/transformers/models/clip/__init__.py +1 -10
- optimum/rbln/transformers/models/clip/modeling_clip.py +1 -10
- optimum/rbln/transformers/models/decoderonly/__init__.py +1 -10
- optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +48 -67
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +14 -14
- optimum/rbln/transformers/models/dpt/__init__.py +1 -10
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +1 -10
- optimum/rbln/transformers/models/exaone/__init__.py +1 -10
- optimum/rbln/transformers/models/exaone/exaone_architecture.py +1 -10
- optimum/rbln/transformers/models/exaone/modeling_exaone.py +1 -10
- optimum/rbln/transformers/models/gemma/__init__.py +1 -10
- optimum/rbln/transformers/models/gemma/gemma_architecture.py +1 -10
- optimum/rbln/transformers/models/gemma/modeling_gemma.py +1 -10
- optimum/rbln/transformers/models/gpt2/__init__.py +1 -10
- optimum/rbln/transformers/models/gpt2/gpt2_architecture.py +1 -10
- optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +1 -10
- optimum/rbln/transformers/models/llama/__init__.py +1 -10
- optimum/rbln/transformers/models/llama/llama_architecture.py +1 -10
- optimum/rbln/transformers/models/llama/modeling_llama.py +1 -10
- optimum/rbln/transformers/models/llava_next/__init__.py +1 -10
- optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +95 -89
- optimum/rbln/transformers/models/midm/__init__.py +1 -10
- optimum/rbln/transformers/models/midm/midm_architecture.py +1 -10
- optimum/rbln/transformers/models/midm/modeling_midm.py +1 -10
- optimum/rbln/transformers/models/mistral/__init__.py +1 -10
- optimum/rbln/transformers/models/mistral/mistral_architecture.py +1 -10
- optimum/rbln/transformers/models/mistral/modeling_mistral.py +1 -10
- optimum/rbln/transformers/models/phi/__init__.py +1 -10
- optimum/rbln/transformers/models/phi/modeling_phi.py +1 -10
- optimum/rbln/transformers/models/phi/phi_architecture.py +1 -10
- optimum/rbln/transformers/models/qwen2/__init__.py +1 -10
- optimum/rbln/transformers/models/qwen2/modeling_qwen2.py +1 -10
- optimum/rbln/transformers/models/qwen2/qwen2_architecture.py +1 -10
- optimum/rbln/transformers/models/seq2seq/__init__.py +1 -10
- optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +1 -10
- optimum/rbln/transformers/models/seq2seq/seq2seq_architecture.py +1 -10
- optimum/rbln/transformers/models/t5/__init__.py +1 -10
- optimum/rbln/transformers/models/t5/modeling_t5.py +14 -15
- optimum/rbln/transformers/models/t5/t5_architecture.py +1 -10
- optimum/rbln/transformers/models/wav2vec2/__init__.py +1 -10
- optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py +1 -10
- optimum/rbln/transformers/models/whisper/__init__.py +1 -10
- optimum/rbln/transformers/models/whisper/generation_whisper.py +2 -11
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +1 -10
- optimum/rbln/transformers/models/whisper/whisper_architecture.py +1 -10
- optimum/rbln/transformers/models/xlm_roberta/__init__.py +1 -10
- optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +24 -12
- optimum/rbln/transformers/utils/rbln_quantization.py +6 -10
- optimum/rbln/utils/__init__.py +1 -10
- optimum/rbln/utils/decorator_utils.py +1 -10
- optimum/rbln/utils/hub.py +1 -10
- optimum/rbln/utils/import_utils.py +1 -10
- optimum/rbln/utils/logging.py +1 -10
- optimum/rbln/utils/model_utils.py +1 -10
- optimum/rbln/utils/runtime_utils.py +1 -10
- optimum/rbln/utils/save_utils.py +2 -10
- optimum/rbln/utils/submodule.py +1 -10
- {optimum_rbln-0.2.1a0.dist-info → optimum_rbln-0.2.1a1.dist-info}/METADATA +6 -4
- optimum_rbln-0.2.1a1.dist-info/RECORD +114 -0
- optimum_rbln-0.2.1a1.dist-info/licenses/LICENSE +201 -0
- optimum_rbln-0.2.1a0.dist-info/RECORD +0 -114
- optimum_rbln-0.2.1a0.dist-info/licenses/LICENSE +0 -288
- {optimum_rbln-0.2.1a0.dist-info → optimum_rbln-0.2.1a1.dist-info}/WHEEL +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,13 +12,4 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from .modeling_qwen2 import RBLNQwen2ForCausalLM
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from ....utils import logging
|
25
16
|
from ...models.decoderonly import RBLNDecoderOnlyModelForCausalLM
|
26
17
|
from .qwen2_architecture import QWEN2Wrapper
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from ..decoderonly.decoderonly_architecture import DecoderOnlyWrapper
|
25
16
|
|
26
17
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,13 +12,4 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from .modeling_seq2seq import RBLNModelForSeq2SeqLM
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import inspect
|
25
16
|
import logging
|
26
17
|
from abc import ABC
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from typing import Tuple
|
25
16
|
|
26
17
|
import torch
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,13 +12,4 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from .modeling_t5 import RBLNT5EncoderModel, RBLNT5ForConditionalGeneration
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,20 +12,10 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import inspect
|
25
16
|
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Tuple, Union
|
26
17
|
|
27
18
|
import torch
|
28
|
-
import transformers
|
29
19
|
from transformers import (
|
30
20
|
AutoModelForTextEncoding,
|
31
21
|
PretrainedConfig,
|
@@ -130,20 +120,29 @@ class RBLNT5EncoderModel(RBLNModel):
|
|
130
120
|
if max_position_embeddings is not None and rbln_max_seq_len > max_position_embeddings:
|
131
121
|
raise ValueError("`rbln_max_seq_len` should be less or equal than max_position_embeddings!")
|
132
122
|
|
123
|
+
signature_params = inspect.signature(cls.hf_class.forward).parameters.keys()
|
124
|
+
|
133
125
|
if rbln_model_input_names is None:
|
134
126
|
for tokenizer in preprocessors:
|
135
127
|
if hasattr(tokenizer, "model_input_names"):
|
136
|
-
rbln_model_input_names = tokenizer.model_input_names
|
128
|
+
rbln_model_input_names = [name for name in signature_params if name in tokenizer.model_input_names]
|
129
|
+
|
130
|
+
invalid_params = set(rbln_model_input_names) - set(signature_params)
|
131
|
+
if invalid_params:
|
132
|
+
raise ValueError(f"Invalid model input names: {invalid_params}")
|
137
133
|
break
|
138
134
|
if rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names"):
|
139
135
|
rbln_model_input_names = cls.rbln_model_input_names
|
140
136
|
elif rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names") is False:
|
141
|
-
original_model_class = getattr(transformers, model_config.architectures[0])
|
142
|
-
input_names_order = inspect.signature(original_model_class.forward).parameters.keys()
|
143
137
|
raise ValueError(
|
144
138
|
"Specify the model input names obtained by the tokenizer via `rbln_model_input_names`, "
|
145
|
-
f"and be sure to make the order of the inputs same as T5EncoderModel forward() arguments like ({list(
|
139
|
+
f"and be sure to make the order of the inputs same as T5EncoderModel forward() arguments like ({list(signature_params)})"
|
146
140
|
)
|
141
|
+
else:
|
142
|
+
invalid_params = set(rbln_model_input_names) - set(signature_params)
|
143
|
+
if invalid_params:
|
144
|
+
raise ValueError(f"Invalid model input names: {invalid_params}")
|
145
|
+
rbln_model_input_names = [name for name in signature_params if name in rbln_model_input_names]
|
147
146
|
|
148
147
|
if rbln_batch_size is None:
|
149
148
|
rbln_batch_size = 1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from typing import Tuple
|
25
16
|
|
26
17
|
import torch
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,13 +12,4 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from .modeling_wav2vec2 import RBLNWav2Vec2ForCTC
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import logging
|
25
16
|
from typing import TYPE_CHECKING, Any, Dict, Union
|
26
17
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,13 +12,4 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from .modeling_whisper import RBLNWhisperForConditionalGeneration
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2022 The HuggingFace Inc. team. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Copyright
|
15
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
16
16
|
|
17
17
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
18
18
|
# you may not use this file except in compliance with the License.
|
@@ -26,15 +26,6 @@
|
|
26
26
|
# See the License for the specific language governing permissions and
|
27
27
|
# limitations under the License.
|
28
28
|
|
29
|
-
# Portions of this software are licensed under the Apache License,
|
30
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
31
|
-
# additional information regarding copyright ownership.
|
32
|
-
|
33
|
-
# All other portions of this software, including proprietary code,
|
34
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
35
|
-
# copied, modified, or distributed without prior written permission
|
36
|
-
# from Rebellions Inc.
|
37
|
-
|
38
29
|
"""
|
39
30
|
Generation utilities for Whisper.
|
40
31
|
Modified from `transformers.models.whisper.generation_whisper.py`
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import inspect
|
25
16
|
import logging
|
26
17
|
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from typing import Optional, Tuple, Union
|
25
16
|
|
26
17
|
import torch
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,13 +12,4 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from .modeling_xlm_roberta import RBLNXLMRobertaModel
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
15
|
+
import inspect
|
24
16
|
import logging
|
25
17
|
from typing import TYPE_CHECKING, Optional, Union
|
26
18
|
|
@@ -66,9 +58,29 @@ class RBLNXLMRobertaModel(RBLNModel):
|
|
66
58
|
if max_position_embeddings is not None and rbln_max_seq_len > max_position_embeddings:
|
67
59
|
raise ValueError("`rbln_enc_max_seq_len` should be less or equal than max_position_embeddings!")
|
68
60
|
|
61
|
+
signature_params = inspect.signature(cls.hf_class.forward).parameters.keys()
|
62
|
+
|
69
63
|
if rbln_model_input_names is None:
|
70
|
-
|
71
|
-
|
64
|
+
for tokenizer in preprocessors:
|
65
|
+
if hasattr(tokenizer, "model_input_names"):
|
66
|
+
rbln_model_input_names = [name for name in signature_params if name in tokenizer.model_input_names]
|
67
|
+
|
68
|
+
invalid_params = set(rbln_model_input_names) - set(signature_params)
|
69
|
+
if invalid_params:
|
70
|
+
raise ValueError(f"Invalid model input names: {invalid_params}")
|
71
|
+
break
|
72
|
+
if rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names"):
|
73
|
+
rbln_model_input_names = cls.rbln_model_input_names
|
74
|
+
elif rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names") is False:
|
75
|
+
raise ValueError(
|
76
|
+
"Specify the model input names obtained by the tokenizer via `rbln_model_input_names`, "
|
77
|
+
f"and be sure to make the order of the inputs same as XLMRobertaModel forward() arguments like ({list(signature_params)})"
|
78
|
+
)
|
79
|
+
else:
|
80
|
+
invalid_params = set(rbln_model_input_names) - set(signature_params)
|
81
|
+
if invalid_params:
|
82
|
+
raise ValueError(f"Invalid model input names: {invalid_params}")
|
83
|
+
rbln_model_input_names = [name for name in signature_params if name in rbln_model_input_names]
|
72
84
|
|
73
85
|
if rbln_batch_size is None:
|
74
86
|
rbln_batch_size = 1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import functools
|
25
16
|
import glob
|
26
17
|
import os
|
@@ -135,6 +126,8 @@ def update_layers_to_quantize(module: torch.nn.Module) -> None:
|
|
135
126
|
"""
|
136
127
|
Updates specified linear layers to quantized (qlinear) layers in the given module.
|
137
128
|
"""
|
129
|
+
|
130
|
+
logger.debug("Updating layers to be quantized") # TODO(jongho): remove.
|
138
131
|
processed_layers = []
|
139
132
|
|
140
133
|
for name, layer in module.named_modules():
|
@@ -151,6 +144,7 @@ def load_weights(model, model_id, n_layer=None):
|
|
151
144
|
"""
|
152
145
|
Load safetensor file data directly into the model, filtering by layer if n_layer is provided.
|
153
146
|
"""
|
147
|
+
logger.debug("Loading the quantized weights into the CPU.") # TODO(jongho): remove.
|
154
148
|
|
155
149
|
model_params = dict(model.named_parameters(recurse=True))
|
156
150
|
model_buffers = dict(model.named_buffers(recurse=True))
|
@@ -172,6 +166,8 @@ def load_weights(model, model_id, n_layer=None):
|
|
172
166
|
elif key in model_buffers:
|
173
167
|
model_buffers[key].data.copy_(value)
|
174
168
|
|
169
|
+
logger.debug("Loaded the quantized weights into the CPU.")
|
170
|
+
|
175
171
|
|
176
172
|
def is_target_for_qlinear_replacement(layer_name: str, layer: torch.nn.Module) -> bool:
|
177
173
|
"""
|
optimum/rbln/utils/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,14 +12,5 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
from .import_utils import check_version_compats, is_rbln_available
|
25
16
|
from .runtime_utils import RBLNPytorchRuntime
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import inspect
|
25
16
|
from functools import wraps
|
26
17
|
|
optimum/rbln/utils/hub.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import os
|
25
16
|
from pathlib import Path
|
26
17
|
from typing import List, Optional, Union
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import importlib.metadata
|
25
16
|
import importlib.util
|
26
17
|
import warnings
|
optimum/rbln/utils/logging.py
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Copyright
|
15
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
16
16
|
|
17
17
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
18
18
|
# you may not use this file except in compliance with the License.
|
@@ -26,15 +26,6 @@
|
|
26
26
|
# See the License for the specific language governing permissions and
|
27
27
|
# limitations under the License.
|
28
28
|
|
29
|
-
# Portions of this software are licensed under the Apache License,
|
30
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
31
|
-
# additional information regarding copyright ownership.
|
32
|
-
|
33
|
-
# All other portions of this software, including proprietary code,
|
34
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
35
|
-
# copied, modified, or distributed without prior written permission
|
36
|
-
# from Rebellions Inc.
|
37
|
-
|
38
29
|
"""
|
39
30
|
Logging utilities.
|
40
31
|
Modified from `transformers.utils.logging.py`
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
# Prefix used for RBLN model class names
|
25
16
|
RBLN_PREFIX = "RBLN"
|
26
17
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Rebellions Inc. All rights reserved.
|
2
2
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Portions of this software are licensed under the Apache License,
|
16
|
-
# Version 2.0. See the NOTICE file distributed with this work for
|
17
|
-
# additional information regarding copyright ownership.
|
18
|
-
|
19
|
-
# All other portions of this software, including proprietary code,
|
20
|
-
# are the intellectual property of Rebellions Inc. and may not be
|
21
|
-
# copied, modified, or distributed without prior written permission
|
22
|
-
# from Rebellions Inc.
|
23
|
-
|
24
15
|
import threading
|
25
16
|
from typing import Any, Dict, List
|
26
17
|
|