optimum-rbln 0.2.1a0__py3-none-any.whl → 0.2.1a2__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.
Files changed (115) hide show
  1. optimum/rbln/__init__.py +3 -10
  2. optimum/rbln/__version__.py +1 -1
  3. optimum/rbln/diffusers/__init__.py +1 -10
  4. optimum/rbln/diffusers/modeling_diffusers.py +1 -10
  5. optimum/rbln/diffusers/models/__init__.py +1 -10
  6. optimum/rbln/diffusers/models/autoencoders/__init__.py +1 -10
  7. optimum/rbln/diffusers/models/autoencoders/autoencoder_kl.py +1 -10
  8. optimum/rbln/diffusers/models/autoencoders/vae.py +1 -10
  9. optimum/rbln/diffusers/models/controlnet.py +1 -10
  10. optimum/rbln/diffusers/models/transformers/__init__.py +1 -10
  11. optimum/rbln/diffusers/models/transformers/transformer_sd3.py +1 -10
  12. optimum/rbln/diffusers/models/unets/__init__.py +1 -10
  13. optimum/rbln/diffusers/models/unets/unet_2d_condition.py +1 -10
  14. optimum/rbln/diffusers/pipelines/__init__.py +1 -10
  15. optimum/rbln/diffusers/pipelines/controlnet/__init__.py +1 -10
  16. optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +1 -10
  17. optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py +1 -10
  18. optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +1 -10
  19. optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +1 -10
  20. optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +1 -10
  21. optimum/rbln/diffusers/pipelines/stable_diffusion/__init__.py +1 -10
  22. optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +1 -10
  23. optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +1 -10
  24. optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +1 -10
  25. optimum/rbln/diffusers/pipelines/stable_diffusion_3/__init__.py +1 -10
  26. optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +1 -10
  27. optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_img2img.py +1 -10
  28. optimum/rbln/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py +1 -10
  29. optimum/rbln/diffusers/pipelines/stable_diffusion_xl/__init__.py +1 -10
  30. optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +1 -10
  31. optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +1 -10
  32. optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +1 -10
  33. optimum/rbln/modeling.py +1 -10
  34. optimum/rbln/modeling_base.py +1 -10
  35. optimum/rbln/modeling_config.py +1 -10
  36. optimum/rbln/ops/__init__.py +1 -10
  37. optimum/rbln/ops/attn.py +9 -18
  38. optimum/rbln/ops/flash_attn.py +5 -14
  39. optimum/rbln/ops/kv_cache_update.py +1 -10
  40. optimum/rbln/transformers/__init__.py +5 -12
  41. optimum/rbln/transformers/modeling_alias.py +1 -14
  42. optimum/rbln/transformers/modeling_generic.py +40 -21
  43. optimum/rbln/transformers/modeling_rope_utils.py +28 -0
  44. optimum/rbln/transformers/models/__init__.py +3 -12
  45. optimum/rbln/transformers/models/auto/__init__.py +1 -10
  46. optimum/rbln/transformers/models/auto/auto_factory.py +1 -10
  47. optimum/rbln/transformers/models/auto/modeling_auto.py +1 -10
  48. optimum/rbln/transformers/models/bart/__init__.py +1 -10
  49. optimum/rbln/transformers/models/bart/bart_architecture.py +1 -10
  50. optimum/rbln/transformers/models/bart/modeling_bart.py +14 -13
  51. optimum/rbln/transformers/models/bert/__init__.py +2 -11
  52. optimum/rbln/transformers/models/bert/modeling_bert.py +23 -13
  53. optimum/rbln/transformers/models/clip/__init__.py +1 -10
  54. optimum/rbln/transformers/models/clip/modeling_clip.py +1 -10
  55. optimum/rbln/transformers/models/decoderonly/__init__.py +1 -10
  56. optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +54 -69
  57. optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +14 -14
  58. optimum/rbln/transformers/models/dpt/__init__.py +1 -10
  59. optimum/rbln/transformers/models/dpt/modeling_dpt.py +1 -10
  60. optimum/rbln/transformers/models/exaone/__init__.py +1 -10
  61. optimum/rbln/transformers/models/exaone/exaone_architecture.py +1 -10
  62. optimum/rbln/transformers/models/exaone/modeling_exaone.py +1 -10
  63. optimum/rbln/transformers/models/gemma/__init__.py +1 -10
  64. optimum/rbln/transformers/models/gemma/gemma_architecture.py +1 -10
  65. optimum/rbln/transformers/models/gemma/modeling_gemma.py +1 -10
  66. optimum/rbln/transformers/models/gpt2/__init__.py +1 -10
  67. optimum/rbln/transformers/models/gpt2/gpt2_architecture.py +1 -10
  68. optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +1 -10
  69. optimum/rbln/transformers/models/llama/__init__.py +1 -10
  70. optimum/rbln/transformers/models/llama/llama_architecture.py +1 -10
  71. optimum/rbln/transformers/models/llama/modeling_llama.py +1 -10
  72. optimum/rbln/transformers/models/llava_next/__init__.py +1 -10
  73. optimum/rbln/transformers/models/llava_next/modeling_llava_next.py +95 -89
  74. optimum/rbln/transformers/models/midm/__init__.py +1 -10
  75. optimum/rbln/transformers/models/midm/midm_architecture.py +1 -10
  76. optimum/rbln/transformers/models/midm/modeling_midm.py +1 -10
  77. optimum/rbln/transformers/models/mistral/__init__.py +1 -10
  78. optimum/rbln/transformers/models/mistral/mistral_architecture.py +1 -10
  79. optimum/rbln/transformers/models/mistral/modeling_mistral.py +1 -10
  80. optimum/rbln/transformers/models/phi/__init__.py +1 -10
  81. optimum/rbln/transformers/models/phi/modeling_phi.py +1 -10
  82. optimum/rbln/transformers/models/phi/phi_architecture.py +1 -10
  83. optimum/rbln/transformers/models/qwen2/__init__.py +1 -10
  84. optimum/rbln/transformers/models/qwen2/modeling_qwen2.py +1 -10
  85. optimum/rbln/transformers/models/qwen2/qwen2_architecture.py +1 -10
  86. optimum/rbln/transformers/models/seq2seq/__init__.py +1 -10
  87. optimum/rbln/transformers/models/seq2seq/modeling_seq2seq.py +1 -10
  88. optimum/rbln/transformers/models/seq2seq/seq2seq_architecture.py +16 -42
  89. optimum/rbln/transformers/models/t5/__init__.py +1 -10
  90. optimum/rbln/transformers/models/t5/modeling_t5.py +14 -15
  91. optimum/rbln/transformers/models/t5/t5_architecture.py +30 -16
  92. optimum/rbln/transformers/models/wav2vec2/__init__.py +1 -10
  93. optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py +1 -10
  94. optimum/rbln/transformers/models/whisper/__init__.py +1 -10
  95. optimum/rbln/transformers/models/whisper/generation_whisper.py +2 -11
  96. optimum/rbln/transformers/models/whisper/modeling_whisper.py +1 -10
  97. optimum/rbln/transformers/models/whisper/whisper_architecture.py +1 -10
  98. optimum/rbln/transformers/models/xlm_roberta/__init__.py +1 -10
  99. optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +24 -12
  100. optimum/rbln/transformers/utils/rbln_quantization.py +6 -10
  101. optimum/rbln/utils/__init__.py +1 -10
  102. optimum/rbln/utils/decorator_utils.py +1 -10
  103. optimum/rbln/utils/hub.py +1 -10
  104. optimum/rbln/utils/import_utils.py +1 -10
  105. optimum/rbln/utils/logging.py +1 -10
  106. optimum/rbln/utils/model_utils.py +1 -10
  107. optimum/rbln/utils/runtime_utils.py +1 -10
  108. optimum/rbln/utils/save_utils.py +2 -10
  109. optimum/rbln/utils/submodule.py +1 -10
  110. {optimum_rbln-0.2.1a0.dist-info → optimum_rbln-0.2.1a2.dist-info}/METADATA +6 -4
  111. optimum_rbln-0.2.1a2.dist-info/RECORD +114 -0
  112. optimum_rbln-0.2.1a2.dist-info/licenses/LICENSE +201 -0
  113. optimum_rbln-0.2.1a0.dist-info/RECORD +0 -114
  114. optimum_rbln-0.2.1a0.dist-info/licenses/LICENSE +0 -288
  115. {optimum_rbln-0.2.1a0.dist-info → optimum_rbln-0.2.1a2.dist-info}/WHEEL +0 -0
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 diffusers import StableDiffusionXLPipeline
25
16
 
26
17
  from ...modeling_diffusers import RBLNDiffusionMixin
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 diffusers import StableDiffusionXLImg2ImgPipeline
25
16
 
26
17
  from ...modeling_diffusers import RBLNDiffusionMixin
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 diffusers import StableDiffusionXLInpaintPipeline
25
16
 
26
17
  from ...modeling_diffusers import RBLNDiffusionMixin
optimum/rbln/modeling.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 pathlib import Path
26
17
  from tempfile import TemporaryDirectory
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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
25
16
  import logging
26
17
  import os
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 copy
25
16
  import json
26
17
  from dataclasses import asdict, dataclass
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 .attn import register_rbln_custom_attention, register_rbln_custom_attention_add_softmax
25
16
  from .flash_attn import register_rbln_custom_flash_attention
26
17
  from .kv_cache_update import register_rbln_custom_cache_update
optimum/rbln/ops/attn.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 functools import lru_cache
25
16
 
26
17
  import torch
@@ -71,16 +62,16 @@ def register_rbln_custom_attention():
71
62
  """
72
63
  return (
73
64
  q,
74
- torch.empty(1, *kcache.shape[1:], device=kcache.device),
75
- torch.empty(1, *vcache.shape[1:], device=vcache.device),
65
+ torch.empty(*kcache.shape, device=kcache.device),
66
+ torch.empty(*vcache.shape, device=vcache.device),
76
67
  )
77
68
 
78
69
  @register_fake("rbln_custom_ops::attn_decode")
79
70
  def attn_decode_abstract(q, k, v, m, kcache, vcache, seq, partition):
80
71
  return (
81
72
  q,
82
- torch.empty(1, *kcache.shape[1:], device=kcache.device),
83
- torch.empty(1, *vcache.shape[1:], device=vcache.device),
73
+ torch.empty(*kcache.shape, device=kcache.device),
74
+ torch.empty(*vcache.shape, device=vcache.device),
84
75
  )
85
76
 
86
77
  torch.library.define(
@@ -161,16 +152,16 @@ def register_rbln_custom_attention_add_softmax():
161
152
  """
162
153
  return (
163
154
  q,
164
- torch.empty(1, *kcache.shape[1:], device=kcache.device),
165
- torch.empty(1, *vcache.shape[1:], device=vcache.device),
155
+ torch.empty(*kcache.shape, device=kcache.device),
156
+ torch.empty(*vcache.shape, device=vcache.device),
166
157
  )
167
158
 
168
159
  @register_fake("rbln_custom_ops::attn_decode_add_softmax")
169
160
  def attn_decode_add_softmax_abstract(q, k, v, m, kcache, vcache, seq, partition):
170
161
  return (
171
162
  q,
172
- torch.empty(1, *kcache.shape[1:], device=kcache.device),
173
- torch.empty(1, *vcache.shape[1:], device=vcache.device),
163
+ torch.empty(*kcache.shape, device=kcache.device),
164
+ torch.empty(*vcache.shape, device=vcache.device),
174
165
  )
175
166
 
176
167
  torch.library.define(
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 functools import lru_cache
25
16
 
26
17
  import torch
@@ -44,16 +35,16 @@ def register_rbln_custom_flash_attention():
44
35
  def flash_attn_decode_cpu(q, k, v, mask, kcache, vcache, seq, scale, partition):
45
36
  return (
46
37
  q,
47
- torch.empty(1, *kcache.shape[1:], device=kcache.device),
48
- torch.empty(1, *vcache.shape[1:], device=vcache.device),
38
+ torch.empty(*kcache.shape, device=kcache.device),
39
+ torch.empty(*vcache.shape, device=vcache.device),
49
40
  )
50
41
 
51
42
  @register_fake("rbln_custom_ops::flash_attn_decode")
52
43
  def flash_attn_decode_abstract(q, k, v, m, kcache, vcache, seq, scale, partition):
53
44
  return (
54
45
  q,
55
- torch.empty(1, *kcache.shape[1:], device=kcache.device),
56
- torch.empty(1, *vcache.shape[1:], device=vcache.device),
46
+ torch.empty(*kcache.shape, device=kcache.device),
47
+ torch.empty(*vcache.shape, device=vcache.device),
57
48
  )
58
49
 
59
50
  torch.library.define(
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 functools import lru_cache
25
16
 
26
17
  import torch
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 TYPE_CHECKING
25
16
 
26
17
  from transformers.utils import _LazyModule
@@ -44,6 +35,8 @@ _import_structure = {
44
35
  "RBLNBartForConditionalGeneration",
45
36
  "RBLNBartModel",
46
37
  "RBLNBertModel",
38
+ "RBLNBertForMaskedLM",
39
+ "RBLNBertForQuestionAnswering",
47
40
  "RBLNCLIPTextModel",
48
41
  "RBLNCLIPTextModelWithProjection",
49
42
  "RBLNCLIPVisionModel",
@@ -65,7 +58,6 @@ _import_structure = {
65
58
  ],
66
59
  "modeling_alias": [
67
60
  "RBLNASTForAudioClassification",
68
- "RBLNBertForQuestionAnswering",
69
61
  "RBLNDistilBertForQuestionAnswering",
70
62
  "RBLNResNetForImageClassification",
71
63
  "RBLNXLMRobertaForSequenceClassification",
@@ -79,7 +71,6 @@ if TYPE_CHECKING:
79
71
  from .cache_utils import RebelDynamicCache
80
72
  from .modeling_alias import (
81
73
  RBLNASTForAudioClassification,
82
- RBLNBertForQuestionAnswering,
83
74
  RBLNDistilBertForQuestionAnswering,
84
75
  RBLNResNetForImageClassification,
85
76
  RBLNRobertaForMaskedLM,
@@ -102,6 +93,8 @@ if TYPE_CHECKING:
102
93
  RBLNAutoModelForVision2Seq,
103
94
  RBLNBartForConditionalGeneration,
104
95
  RBLNBartModel,
96
+ RBLNBertForMaskedLM,
97
+ RBLNBertForQuestionAnswering,
105
98
  RBLNBertModel,
106
99
  RBLNCLIPTextModel,
107
100
  RBLNCLIPTextModelWithProjection,
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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.logging import get_logger
25
16
  from .modeling_generic import (
26
17
  RBLNModelForAudioClassification,
@@ -38,10 +29,6 @@ class RBLNASTForAudioClassification(RBLNModelForAudioClassification):
38
29
  pass
39
30
 
40
31
 
41
- class RBLNBertForQuestionAnswering(RBLNModelForQuestionAnswering):
42
- rbln_model_input_names = ["input_ids", "attention_mask", "token_type_ids"]
43
-
44
-
45
32
  class RBLNDistilBertForQuestionAnswering(RBLNModelForQuestionAnswering):
46
33
  rbln_model_input_names = ["input_ids", "attention_mask"]
47
34
 
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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
  """
25
16
  This file defines generic base classes for various RBLN models,
26
17
  such as Question Answering, Image Classification, Audio Classification,
@@ -32,7 +23,6 @@ different model architectures.
32
23
  import inspect
33
24
  from typing import TYPE_CHECKING, Any, Dict, Optional, Union
34
25
 
35
- import transformers
36
26
  from transformers import (
37
27
  AutoModelForAudioClassification,
38
28
  AutoModelForImageClassification,
@@ -83,19 +73,29 @@ class RBLNModelForQuestionAnswering(RBLNModel):
83
73
  if rbln_batch_size is None:
84
74
  rbln_batch_size = 1
85
75
 
76
+ signature_params = inspect.signature(cls.hf_class.forward).parameters.keys()
77
+
86
78
  if rbln_model_input_names is None:
87
79
  for tokenizer in preprocessors:
88
80
  if hasattr(tokenizer, "model_input_names"):
89
- rbln_model_input_names = tokenizer.model_input_names
81
+ rbln_model_input_names = [name for name in signature_params if name in tokenizer.model_input_names]
82
+
83
+ invalid_params = set(rbln_model_input_names) - set(signature_params)
84
+ if invalid_params:
85
+ raise ValueError(f"Invalid model input names: {invalid_params}")
90
86
  break
91
87
  if rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names"):
92
88
  rbln_model_input_names = cls.rbln_model_input_names
93
89
  elif rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names") is False:
94
- input_names_order = inspect.signature(cls.hf_class.forward).parameters.keys()
95
90
  raise ValueError(
96
91
  "Specify the model input names obtained by the tokenizer via `rbln_model_input_names`, "
97
- f"and be sure to make the order of the inputs same as QuestionAnswering forward() arguments like ({list(input_names_order)})"
92
+ f"and be sure to make the order of the inputs same as QuestionAnswering forward() arguments like ({list(signature_params)})"
98
93
  )
94
+ else:
95
+ invalid_params = set(rbln_model_input_names) - set(signature_params)
96
+ if invalid_params:
97
+ raise ValueError(f"Invalid model input names: {invalid_params}")
98
+ rbln_model_input_names = [name for name in signature_params if name in rbln_model_input_names]
99
99
 
100
100
  input_info = [
101
101
  (model_input_name, [rbln_batch_size, rbln_max_seq_len], "int64")
@@ -289,20 +289,29 @@ class RBLNModelForSequenceClassification(RBLNModel):
289
289
  if max_position_embeddings is not None and rbln_max_seq_len > max_position_embeddings:
290
290
  raise ValueError("`rbln_enc_max_seq_len` should be less or equal than max_position_embeddings!")
291
291
 
292
+ signature_params = inspect.signature(cls.hf_class.forward).parameters.keys()
293
+
292
294
  if rbln_model_input_names is None:
293
295
  for tokenizer in preprocessors:
294
296
  if hasattr(tokenizer, "model_input_names"):
295
- rbln_model_input_names = tokenizer.model_input_names
297
+ rbln_model_input_names = [name for name in signature_params if name in tokenizer.model_input_names]
298
+
299
+ invalid_params = set(rbln_model_input_names) - set(signature_params)
300
+ if invalid_params:
301
+ raise ValueError(f"Invalid model input names: {invalid_params}")
296
302
  break
297
303
  if rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names"):
298
304
  rbln_model_input_names = cls.rbln_model_input_names
299
305
  elif rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names") is False:
300
- original_model_class = getattr(transformers, model_config.architectures[0])
301
- input_names_order = inspect.signature(original_model_class.forward).parameters.keys()
302
306
  raise ValueError(
303
307
  "Specify the model input names obtained by the tokenizer via `rbln_model_input_names`, "
304
- f"and be sure to make the order of the inputs same as SequenceClassification forward() arguments like ({list(input_names_order)})"
308
+ f"and be sure to make the order of the inputs same as SequenceClassification forward() arguments like ({list(signature_params)})"
305
309
  )
310
+ else:
311
+ invalid_params = set(rbln_model_input_names) - set(signature_params)
312
+ if invalid_params:
313
+ raise ValueError(f"Invalid model input names: {invalid_params}")
314
+ rbln_model_input_names = [name for name in signature_params if name in rbln_model_input_names]
306
315
 
307
316
  if rbln_batch_size is None:
308
317
  rbln_batch_size = 1
@@ -353,19 +362,29 @@ class RBLNModelForMaskedLM(RBLNModel):
353
362
  if max_position_embeddings is not None and rbln_max_seq_len > max_position_embeddings:
354
363
  raise ValueError("`rbln_enc_max_seq_len` should be less or equal than max_position_embeddings!")
355
364
 
365
+ signature_params = inspect.signature(cls.hf_class.forward).parameters.keys()
366
+
356
367
  if rbln_model_input_names is None:
357
368
  for tokenizer in preprocessors:
358
369
  if hasattr(tokenizer, "model_input_names"):
359
- rbln_model_input_names = tokenizer.model_input_names
370
+ rbln_model_input_names = [name for name in signature_params if name in tokenizer.model_input_names]
371
+
372
+ invalid_params = set(rbln_model_input_names) - set(signature_params)
373
+ if invalid_params:
374
+ raise ValueError(f"Invalid model input names: {invalid_params}")
360
375
  break
361
376
  if rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names"):
362
377
  rbln_model_input_names = cls.rbln_model_input_names
363
378
  elif rbln_model_input_names is None and hasattr(cls, "rbln_model_input_names") is False:
364
- input_names_order = inspect.signature(cls.hf_class.forward).parameters.keys()
365
379
  raise ValueError(
366
380
  "Specify the model input names obtained by the tokenizer via `rbln_model_input_names`, "
367
- f"and be sure to make the order of the inputs same as MaskedLM forward() arguments like ({list(input_names_order)})"
381
+ f"and be sure to make the order of the inputs same as MaskedLM forward() arguments like ({list(signature_params)})"
368
382
  )
383
+ else:
384
+ invalid_params = set(rbln_model_input_names) - set(signature_params)
385
+ if invalid_params:
386
+ raise ValueError(f"Invalid model input names: {invalid_params}")
387
+ rbln_model_input_names = [name for name in signature_params if name in rbln_model_input_names]
369
388
 
370
389
  if rbln_batch_size is None:
371
390
  rbln_batch_size = 1
@@ -1,3 +1,31 @@
1
+ # Copyright 2024 The HuggingFace Team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Copyright 2025 Rebellions Inc. All rights reserved.
16
+
17
+ # Licensed under the Apache License, Version 2.0 (the "License");
18
+ # you may not use this file except in compliance with the License.
19
+ # You may obtain a copy of the License at:
20
+
21
+ # http://www.apache.org/licenses/LICENSE-2.0
22
+
23
+ # Unless required by applicable law or agreed to in writing, software
24
+ # distributed under the License is distributed on an "AS IS" BASIS,
25
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ # See the License for the specific language governing permissions and
27
+ # limitations under the License.
28
+
1
29
  import math
2
30
  from typing import Optional, Tuple
3
31
 
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 TYPE_CHECKING
25
16
 
26
17
  from transformers.utils import _LazyModule
@@ -42,7 +33,7 @@ _import_structure = {
42
33
  "RBLNAutoModelForVision2Seq",
43
34
  ],
44
35
  "bart": ["RBLNBartForConditionalGeneration", "RBLNBartModel"],
45
- "bert": ["RBLNBertModel"],
36
+ "bert": ["RBLNBertModel", "RBLNBertForQuestionAnswering", "RBLNBertForMaskedLM"],
46
37
  "clip": ["RBLNCLIPTextModel", "RBLNCLIPTextModelWithProjection", "RBLNCLIPVisionModel"],
47
38
  "dpt": ["RBLNDPTForDepthEstimation"],
48
39
  "exaone": ["RBLNExaoneForCausalLM"],
@@ -76,7 +67,7 @@ if TYPE_CHECKING:
76
67
  RBLNAutoModelForVision2Seq,
77
68
  )
78
69
  from .bart import RBLNBartForConditionalGeneration, RBLNBartModel
79
- from .bert import RBLNBertModel
70
+ from .bert import RBLNBertForMaskedLM, RBLNBertForQuestionAnswering, RBLNBertModel
80
71
  from .clip import RBLNCLIPTextModel, RBLNCLIPTextModelWithProjection, RBLNCLIPVisionModel
81
72
  from .dpt import RBLNDPTForDepthEstimation
82
73
  from .exaone import RBLNExaoneForCausalLM
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 .modeling_auto import (
25
16
  RBLNAutoModel,
26
17
  RBLNAutoModelForAudioClassification,
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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
25
16
  import inspect
26
17
  import warnings
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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 transformers.models.auto.modeling_auto import (
25
16
  MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING,
26
17
  MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES,
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Rebellions Inc.
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_bart import RBLNBartForConditionalGeneration, RBLNBartModel