optimum-rbln 0.1.4__py3-none-any.whl → 0.1.8__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 +21 -0
- optimum/rbln/__version__.py +1 -1
- optimum/rbln/diffusers/__init__.py +0 -1
- optimum/rbln/diffusers/models/autoencoder_kl.py +16 -98
- optimum/rbln/diffusers/models/controlnet.py +3 -0
- optimum/rbln/diffusers/models/unet_2d_condition.py +3 -3
- optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +22 -146
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py +109 -53
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +114 -53
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +130 -71
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py +131 -72
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +3 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +8 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +8 -0
- optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +9 -0
- optimum/rbln/modeling_alias.py +14 -0
- optimum/rbln/modeling_base.py +282 -100
- optimum/rbln/modeling_seq2seq.py +58 -132
- optimum/rbln/transformers/__init__.py +8 -0
- optimum/rbln/transformers/cache_utils.py +111 -0
- optimum/rbln/transformers/generation/utils.py +0 -2
- optimum/rbln/transformers/models/__init__.py +3 -0
- optimum/rbln/transformers/models/bart/bart_architecture.py +0 -5
- optimum/rbln/transformers/models/clip/modeling_clip.py +0 -1
- optimum/rbln/transformers/models/decoderonly/__init__.py +36 -0
- optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py +515 -0
- optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py +349 -0
- optimum/rbln/transformers/models/dpt/__init__.py +24 -0
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +89 -0
- optimum/rbln/transformers/models/gemma/__init__.py +24 -0
- optimum/rbln/transformers/models/gemma/gemma_architecture.py +116 -0
- optimum/rbln/transformers/models/gemma/modeling_gemma.py +61 -0
- optimum/rbln/transformers/models/gpt2/gpt2_architecture.py +200 -174
- optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +57 -293
- optimum/rbln/transformers/models/llama/llama_architecture.py +3 -613
- optimum/rbln/transformers/models/llama/modeling_llama.py +9 -469
- optimum/rbln/transformers/models/midm/hf_hub_cached/midm_bitext_tokenization.py +2 -1
- optimum/rbln/transformers/models/midm/hf_hub_cached/modeling_midm.py +0 -4
- optimum/rbln/transformers/models/midm/midm_architecture.py +160 -357
- optimum/rbln/transformers/models/midm/modeling_midm.py +40 -308
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +53 -123
- optimum/rbln/transformers/models/whisper/whisper_architecture.py +0 -6
- optimum/rbln/transformers/models/xlm_roberta/__init__.py +24 -0
- optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py +125 -0
- optimum/rbln/utils/__init__.py +1 -1
- optimum/rbln/utils/import_utils.py +46 -0
- {optimum_rbln-0.1.4.dist-info → optimum_rbln-0.1.8.dist-info}/METADATA +18 -53
- optimum_rbln-0.1.8.dist-info/RECORD +73 -0
- {optimum_rbln-0.1.4.dist-info → optimum_rbln-0.1.8.dist-info}/WHEEL +1 -1
- optimum/rbln/transformers/models/llama/llama_architecture_cb.py +0 -759
- optimum_rbln-0.1.4.dist-info/RECORD +0 -63
- {optimum_rbln-0.1.4.dist-info → optimum_rbln-0.1.8.dist-info}/licenses/LICENSE +0 -0
@@ -57,7 +57,6 @@ class _WhisperAttention(WhisperAttention):
|
|
57
57
|
cache_position: Optional[torch.Tensor] = None,
|
58
58
|
**kwargs,
|
59
59
|
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
60
|
-
|
61
60
|
bsz, tgt_len, _ = hidden_states.size()
|
62
61
|
is_cross_attention = key_value_states is not None
|
63
62
|
|
@@ -123,7 +122,6 @@ class _WhisperSdpaAttention(WhisperSdpaAttention):
|
|
123
122
|
cache_position: Optional[torch.Tensor] = None,
|
124
123
|
**kwargs,
|
125
124
|
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
126
|
-
|
127
125
|
bsz, tgt_len, _ = hidden_states.size()
|
128
126
|
|
129
127
|
is_cross_attention = key_value_states is not None
|
@@ -189,7 +187,6 @@ class _WhisperDecoderLayer(WhisperDecoderLayer):
|
|
189
187
|
cache_position: Optional[torch.Tensor] = None,
|
190
188
|
attn_impl: str = "eager",
|
191
189
|
) -> torch.Tensor:
|
192
|
-
|
193
190
|
# Self Attention Block
|
194
191
|
residual = hidden_states
|
195
192
|
hidden_states = self.self_attn_layer_norm(hidden_states)
|
@@ -248,7 +245,6 @@ class _WhisperDecoder(WhisperDecoder):
|
|
248
245
|
attn_impl: str = "eager",
|
249
246
|
**kwargs,
|
250
247
|
):
|
251
|
-
|
252
248
|
input_shape = input_ids.size()
|
253
249
|
input_ids = input_ids.view(-1, input_shape[-1])
|
254
250
|
|
@@ -312,7 +308,6 @@ class _WhisperDecoderWrapper(torch.nn.Module):
|
|
312
308
|
self_kv_cache: torch.Tensor,
|
313
309
|
cross_kv_cache: torch.Tensor,
|
314
310
|
) -> Union[Tuple[torch.FloatTensor], Seq2SeqLMOutput]:
|
315
|
-
|
316
311
|
# prepare past_key_values
|
317
312
|
kv_cache = ()
|
318
313
|
for i in range(0, self.num_layers * 2, 2):
|
@@ -367,7 +362,6 @@ class _WhisperEncoderWrapper(torch.nn.Module):
|
|
367
362
|
self,
|
368
363
|
input_features: Optional[torch.LongTensor] = None,
|
369
364
|
) -> Union[Tuple[torch.FloatTensor], BaseModelOutput]:
|
370
|
-
|
371
365
|
encoder_outputs = self.encoder(input_features=input_features)
|
372
366
|
last_hidden_states = encoder_outputs[0]
|
373
367
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright 2024 Rebellions Inc.
|
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
|
+
# 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
|
+
from .modeling_xlm_roberta import RBLNXLMRobertaModel
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# Copyright 2024 Rebellions Inc.
|
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
|
+
# 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
|
+
import logging
|
25
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
26
|
+
|
27
|
+
import torch
|
28
|
+
from transformers import AutoModel, PretrainedConfig, PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
|
29
|
+
|
30
|
+
from ....modeling_base import RBLNModel
|
31
|
+
from ....modeling_config import RBLNConfig, RBLNRuntimeConfig
|
32
|
+
|
33
|
+
|
34
|
+
logger = logging.getLogger(__name__)
|
35
|
+
|
36
|
+
if TYPE_CHECKING:
|
37
|
+
from transformers import AutoFeatureExtractor, AutoProcessor, AutoTokenizer
|
38
|
+
|
39
|
+
class RBLNXLMRobertaModel(RBLNModel):
|
40
|
+
auto_model_class = AutoModel # feature extraction
|
41
|
+
original_model_class = XLMRobertaModel
|
42
|
+
original_config_class = XLMRobertaConfig
|
43
|
+
|
44
|
+
@classmethod
|
45
|
+
def get_pytorch_model(
|
46
|
+
cls,
|
47
|
+
model_id: str,
|
48
|
+
use_auth_token: Optional[Union[bool, str]] = None,
|
49
|
+
revision: Optional[str] = None,
|
50
|
+
force_download: bool = False,
|
51
|
+
cache_dir: Optional[str] = None,
|
52
|
+
subfolder: str = "",
|
53
|
+
local_files_only: bool = False,
|
54
|
+
trust_remote_code: bool = False,
|
55
|
+
rbln_config_kwargs: Optional[Dict[str, Any]] = None,
|
56
|
+
rbln_constructor_kwargs: Optional[Dict[str, Any]] = None,
|
57
|
+
**kwargs,
|
58
|
+
) -> "PreTrainedModel":
|
59
|
+
model: "PreTrainedModel" = super().get_pytorch_model(
|
60
|
+
model_id=model_id,
|
61
|
+
use_auth_token=use_auth_token,
|
62
|
+
revision=revision,
|
63
|
+
force_download=force_download,
|
64
|
+
cache_dir=cache_dir,
|
65
|
+
subfolder=subfolder,
|
66
|
+
local_files_only=local_files_only,
|
67
|
+
trust_remote_code=trust_remote_code,
|
68
|
+
rbln_config_kwargs=rbln_config_kwargs,
|
69
|
+
rbln_constructor_kwargs=rbln_constructor_kwargs,
|
70
|
+
library_name="transformers",
|
71
|
+
)
|
72
|
+
|
73
|
+
return model
|
74
|
+
|
75
|
+
@classmethod
|
76
|
+
def _get_rbln_config(
|
77
|
+
cls,
|
78
|
+
preprocessors: Optional[Union["AutoFeatureExtractor", "AutoProcessor", "AutoTokenizer"]],
|
79
|
+
model_config: Optional["PretrainedConfig"] = None,
|
80
|
+
rbln_max_seq_len: Optional[int] = None,
|
81
|
+
rbln_model_input_names: Optional[List[str]] = None,
|
82
|
+
rbln_batch_size: Optional[int] = None,
|
83
|
+
) -> RBLNConfig:
|
84
|
+
|
85
|
+
max_position_embeddings = getattr(model_config, "n_positions", None) or getattr(
|
86
|
+
model_config, "max_position_embeddings", None
|
87
|
+
)
|
88
|
+
|
89
|
+
if rbln_max_seq_len is None:
|
90
|
+
rbln_max_seq_len = max_position_embeddings
|
91
|
+
if rbln_max_seq_len is None:
|
92
|
+
for tokenizer in preprocessors:
|
93
|
+
if hasattr(tokenizer, "model_max_length"):
|
94
|
+
rbln_max_seq_len = tokenizer.model_max_length
|
95
|
+
break
|
96
|
+
if rbln_max_seq_len is None:
|
97
|
+
raise ValueError("`rbln_max_seq_len` should be specified!")
|
98
|
+
|
99
|
+
if max_position_embeddings is not None and rbln_max_seq_len > max_position_embeddings:
|
100
|
+
raise ValueError("`rbln_enc_max_seq_len` should be less or equal than max_position_embeddings!")
|
101
|
+
|
102
|
+
if rbln_model_input_names is None:
|
103
|
+
# These are BERT's inputs
|
104
|
+
rbln_model_input_names = ["input_ids", "attention_mask", "token_type_ids"]
|
105
|
+
|
106
|
+
if rbln_batch_size is None:
|
107
|
+
rbln_batch_size = 1
|
108
|
+
|
109
|
+
input_info = [
|
110
|
+
(model_input_name, [rbln_batch_size, rbln_max_seq_len], "int64")
|
111
|
+
for model_input_name in rbln_model_input_names
|
112
|
+
]
|
113
|
+
|
114
|
+
rbln_runtime_config = RBLNRuntimeConfig(input_info=input_info)
|
115
|
+
rbln_runtime_config.batch_size = rbln_batch_size
|
116
|
+
|
117
|
+
meta = {"rbln_max_seq_len": rbln_max_seq_len}
|
118
|
+
|
119
|
+
return RBLNConfig.from_rbln_runtime_configs([rbln_runtime_config], _rbln_meta=meta)
|
120
|
+
|
121
|
+
def forward(self, input_ids: "torch.Tensor", attention_mask: "torch.Tensor", token_type_ids: "torch.Tensor" = None, **kwargs):
|
122
|
+
if token_type_ids is None:
|
123
|
+
token_type_ids = torch.zeros_like(input=input_ids, dtype=torch.int64)
|
124
|
+
output = super().forward(input_ids, attention_mask, token_type_ids)
|
125
|
+
return output
|
optimum/rbln/utils/__init__.py
CHANGED
@@ -21,8 +21,54 @@
|
|
21
21
|
# copied, modified, or distributed without prior written permission
|
22
22
|
# from Rebellions Inc.
|
23
23
|
|
24
|
+
import importlib.metadata
|
24
25
|
import importlib.util
|
26
|
+
import warnings
|
27
|
+
from dataclasses import dataclass
|
28
|
+
|
29
|
+
from packaging.version import Version
|
30
|
+
|
31
|
+
|
32
|
+
@dataclass
|
33
|
+
class VersionCompat:
|
34
|
+
package_name: str
|
35
|
+
min_version: str
|
36
|
+
max_version: str
|
37
|
+
|
38
|
+
|
39
|
+
RBLN_VERSION_COMPATS = {
|
40
|
+
"0.1.5": [
|
41
|
+
VersionCompat(
|
42
|
+
package_name="rebel-compiler",
|
43
|
+
min_version="0.5.7",
|
44
|
+
max_version="0.5.8",
|
45
|
+
),
|
46
|
+
],
|
47
|
+
"0.0.0": [],
|
48
|
+
}
|
25
49
|
|
26
50
|
|
27
51
|
def is_rbln_available() -> bool:
|
28
52
|
return importlib.util.find_spec("rebel-compiler") is not None
|
53
|
+
|
54
|
+
|
55
|
+
def check_version_compats() -> None:
|
56
|
+
warnings.filterwarnings(action="always", category=ImportWarning)
|
57
|
+
|
58
|
+
my_version = importlib.metadata.version("optimum-rbln")
|
59
|
+
target_version = list(filter(lambda v: Version(my_version) > Version(v), RBLN_VERSION_COMPATS.keys()))[0]
|
60
|
+
for compat in RBLN_VERSION_COMPATS[target_version]:
|
61
|
+
try:
|
62
|
+
dep_version = importlib.metadata.version(compat.package_name)
|
63
|
+
except importlib.metadata.PackageNotFoundError:
|
64
|
+
warnings.warn(f"optimum-rbln requires {compat.package_name} to be installed.", ImportWarning)
|
65
|
+
continue
|
66
|
+
|
67
|
+
if not Version(compat.min_version) <= Version(dep_version) < Version(compat.max_version):
|
68
|
+
warnings.warn(
|
69
|
+
f"optimum-rbln v{my_version} is compatible to {compat.package_name} v{compat.min_version} to v{compat.max_version}. (you are currently using v{dep_version})\n"
|
70
|
+
"Please refer to our SDK release notes at https://docs.rbln.ai/about_atom/release_note.html",
|
71
|
+
ImportWarning,
|
72
|
+
)
|
73
|
+
|
74
|
+
warnings.resetwarnings()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: optimum-rbln
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.8
|
4
4
|
Summary: Optimum RBLN is the interface between the Hugging Face Transformers and Diffusers libraries and RBLN accelerators.
|
5
5
|
It provides a set of tools enabling easy model loading and inference on single and multiple rbln device settings for different downstream tasks.
|
6
6
|
Keywords: transformers,diffusers,inference,rbln,atom,rebel
|
@@ -20,13 +20,13 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
20
|
Project-URL: Homepage, https://rebellions.ai
|
21
21
|
Project-URL: Documentation, https://docs.rbln.ai
|
22
22
|
Requires-Python: <3.11,>=3.8
|
23
|
-
Requires-Dist: torch
|
24
|
-
Requires-Dist: optimum
|
23
|
+
Requires-Dist: torch<=2.2.1
|
24
|
+
Requires-Dist: optimum<=1.20.0
|
25
25
|
Requires-Dist: accelerate>=0.28.0
|
26
|
-
Requires-Dist: transformers
|
27
|
-
Requires-Dist: diffusers
|
26
|
+
Requires-Dist: transformers<=4.40.2
|
27
|
+
Requires-Dist: diffusers<=0.29.2
|
28
28
|
Requires-Dist: einops>=0.8.0
|
29
|
-
Requires-Dist:
|
29
|
+
Requires-Dist: packaging>=24.1
|
30
30
|
Requires-Dist: pytest>=8.1.1; extra == "tests"
|
31
31
|
Requires-Dist: psutil>=5.9.8; extra == "tests"
|
32
32
|
Requires-Dist: parameterized>=0.9.0; extra == "tests"
|
@@ -34,13 +34,10 @@ Requires-Dist: GitPython>=3.1.42; extra == "tests"
|
|
34
34
|
Requires-Dist: sentencepiece>=0.2.0; extra == "tests"
|
35
35
|
Requires-Dist: datasets>=2.18.0; extra == "tests"
|
36
36
|
Requires-Dist: sacremoses>=0.1.1; extra == "tests"
|
37
|
-
Requires-Dist: diffusers>=0.27.1; extra == "tests"
|
38
37
|
Requires-Dist: safetensors>=0.4.2; extra == "tests"
|
39
|
-
Requires-Dist: black>=24.3.0; extra == "quality"
|
40
38
|
Requires-Dist: ruff>=0.3.3; extra == "quality"
|
41
39
|
Requires-Dist: isort>=5.13.2; extra == "quality"
|
42
40
|
Requires-Dist: hf-doc-builder>=0.5.0; extra == "quality"
|
43
|
-
Provides-Extra: diffusers
|
44
41
|
Provides-Extra: tests
|
45
42
|
Provides-Extra: quality
|
46
43
|
Description-Content-Type: text/markdown
|
@@ -65,26 +62,28 @@ limitations under the License.
|
|
65
62
|
|
66
63
|
🤗 Optimum RBLN is the interface between the 🤗 Transformers library and RBLN Accelerators including [ATOM](https://atom_link) and [REBEL](https://rebel_link).
|
67
64
|
It provides a set of tools enabling easy model loading and inference on single- and multi-Accelerator settings for different downstream tasks.
|
68
|
-
The list of officially validated models and tasks is available [here](
|
65
|
+
The list of officially validated models and tasks is available [here](https://docs.rbln.ai/software/optimum/optimum_rbln.html). Users can try other models and tasks with only few changes.
|
69
66
|
|
70
67
|
## Install from PyPI
|
71
68
|
|
72
69
|
To install the latest release of this package:
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
- Export environment variables to access to RBLN private PyPI.
|
72
|
+
```bash
|
73
|
+
export REBEL_PYPI_USERNAME=<username>
|
74
|
+
export REBEL_PYPI_PASSWORD=<password>
|
75
|
+
```
|
76
|
+
|
77
|
+
- Install optimum-rbln package:
|
78
|
+
```bash
|
79
|
+
pip install --index-url https://pypi.rebellions.in/simple optimum-rbln
|
80
|
+
```
|
77
81
|
|
78
82
|
## Install from source
|
79
83
|
|
80
84
|
### Prerequisites
|
81
85
|
|
82
86
|
- Install [PDM](https://pdm-project.org/latest/) (refer [this link](https://pdm-project.org/latest/#installation) for detailed commands)
|
83
|
-
- Export environment variables to access to RBLN private PyPI.
|
84
|
-
```bash
|
85
|
-
export REBEL_PYPI_USERNAME=<username>
|
86
|
-
export REBEL_PYPI_PASSWORD=<password>
|
87
|
-
```
|
88
87
|
|
89
88
|
The below command installs optimum-rbln along with its dependencies.
|
90
89
|
|
@@ -106,40 +105,6 @@ pdm install -G:all
|
|
106
105
|
|
107
106
|
🤗 Optimum RBLN was designed with one goal in mind: **to make inference straightforward for any 🤗 Transformers user while leveraging the complete power of RBLN Accelerators**.
|
108
107
|
|
109
|
-
#### Transformers Interface
|
110
|
-
|
111
|
-
<!--
|
112
|
-
There are two main classes one needs to know:
|
113
|
-
- TrainiumArgumentParser: inherits the original [HfArgumentParser](https://huggingface.co/docs/transformers/main/en/internal/trainer_utils#transformers.HfArgumentParser) in Transformers with additional checks on the argument values to make sure that they will work well with AWS Trainium instances.
|
114
|
-
- [NeuronTrainer](https://huggingface.co/docs/optimum/neuron/package_reference/trainer): this version trainer takes care of doing the proper checks and changes to the supported models to make them trainable on AWS Trainium instances.
|
115
|
-
|
116
|
-
The [NeuronTrainer](https://huggingface.co/docs/optimum/neuron/package_reference/trainer) is very similar to the [🤗 Transformers Trainer](https://huggingface.co/docs/transformers/main_classes/trainer), and adapting a script using the Trainer to make it work with Trainium will mostly consist in simply swapping the Trainer class for the NeuronTrainer one.
|
117
|
-
That's how most of the [example scripts](https://github.com/huggingface/optimum-neuron/tree/main/examples) were adapted from their [original counterparts](https://github.com/huggingface/transformers/tree/main/examples/pytorch).
|
118
|
-
|
119
|
-
```diff
|
120
|
-
from transformers import TrainingArguments
|
121
|
-
+from optimum.neuron import NeuronTrainer as Trainer
|
122
|
-
|
123
|
-
training_args = TrainingArguments(
|
124
|
-
# training arguments...
|
125
|
-
)
|
126
|
-
|
127
|
-
# A lot of code here
|
128
|
-
|
129
|
-
# Initialize our Trainer
|
130
|
-
trainer = Trainer(
|
131
|
-
model=model,
|
132
|
-
args=training_args, # Original training arguments.
|
133
|
-
train_dataset=train_dataset if training_args.do_train else None,
|
134
|
-
eval_dataset=eval_dataset if training_args.do_eval else None,
|
135
|
-
compute_metrics=compute_metrics,
|
136
|
-
tokenizer=tokenizer,
|
137
|
-
data_collator=data_collator,
|
138
|
-
)
|
139
|
-
``` -->
|
140
|
-
|
141
108
|
### Documentation
|
142
109
|
|
143
|
-
Check out [the documentation of Optimum RBLN](https://
|
144
|
-
|
145
|
-
If you find any issue while using those, please open an issue or a pull request.
|
110
|
+
Check out [the documentation of Optimum RBLN](https://docs.rbln.ai/software/optimum/optimum_rbln.html) for more advanced usage.
|
@@ -0,0 +1,73 @@
|
|
1
|
+
optimum/rbln/__init__.py,sha256=3_h6eOK1OuG84FWaN2zSR7FtuUv4YHuzK4_2DsA6uwk,4785
|
2
|
+
optimum/rbln/__version__.py,sha256=zemvJ5zjFE6SQT2xmkxc-ZYwNkUTCEX7mz3Epb2qztE,21
|
3
|
+
optimum/rbln/diffusers/__init__.py,sha256=w4W7Wy-Mmh8CQZ5M9JnrrE5bN0UsfNehZI41QadE-hk,2605
|
4
|
+
optimum/rbln/diffusers/models/__init__.py,sha256=aY6Llq_31dZjdB9HPBDvi7sXVtdQT9r11gokXG5ffxA,1139
|
5
|
+
optimum/rbln/diffusers/models/autoencoder_kl.py,sha256=qIhXCfEADNTm2U9I5ZFN1IfA01zwupUY0IBnJwvxLwI,9506
|
6
|
+
optimum/rbln/diffusers/models/controlnet.py,sha256=BQVjszdk6qlW6HnSXKRsWR7v6oFNcgMG-utNnRPpLSg,9303
|
7
|
+
optimum/rbln/diffusers/models/unet_2d_condition.py,sha256=oZQyT0PpPcxwmDgCSh7d2nT3oU60iKx-AdgJilzWAb8,14468
|
8
|
+
optimum/rbln/diffusers/pipelines/__init__.py,sha256=Xr_bQbpbC5HbJB2NuUcVQu2BGebDkc2bhsGJmL6jgps,1449
|
9
|
+
optimum/rbln/diffusers/pipelines/controlnet/__init__.py,sha256=k0govvSBxBUR5qpxUGxRMHuQCMX7hXHVZ4EqVRw1LWk,1377
|
10
|
+
optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py,sha256=FneDaY03zs5aRTeRUTTAbAQsKjGozsea09Km0Z35Ryc,5129
|
11
|
+
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py,sha256=qX0nDFShyZL3RHKgaeeM8XpMLLDsa_PCrhqS2-IfEwM,42605
|
12
|
+
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py,sha256=9-zw07G5dICByN4k9UgZ5NwPiToRcOApj7M93SM75Pk,41199
|
13
|
+
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py,sha256=g8SABYroDmcND-0_3CUH1wkdrZPHWdzoWpWLxBk8p-8,53126
|
14
|
+
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py,sha256=mOlVPumpYbss18jjnZUSwS1EzFjzQDtZf1yOkS4VLng,54485
|
15
|
+
optimum/rbln/diffusers/pipelines/stable_diffusion/__init__.py,sha256=qf_uMWSwD-CyRMRC73y1QsTMyl_qCMreIdg0a8rhJuA,1142
|
16
|
+
optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py,sha256=rVryl7riAgkkNJzbXQHKRDYEyR7ZhsF_aF_MkMnerco,5399
|
17
|
+
optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py,sha256=VfOOybXQnotWIS1ch0a-eMSM-BDrPlZdGwtsYtsH0JQ,5747
|
18
|
+
optimum/rbln/diffusers/pipelines/stable_diffusion_xl/__init__.py,sha256=8MDMHIVsDrM6lZAyvpjFtWOFwiY_IoSxzCQe-gJYTPI,159
|
19
|
+
optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py,sha256=aCJSoXks7IpjX4rcH6q0TjXtIPzNrbvAvz0KbIEmMr8,5684
|
20
|
+
optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py,sha256=Cv9L4El2GOE-3IRQKHNEMuSdWGmtVsRnQJShcv2hOo0,5874
|
21
|
+
optimum/rbln/modeling.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
+
optimum/rbln/modeling_alias.py,sha256=O7vXVl7Qo1tl_UIMMf4z-62pAyKuEZp2x932MTfKoKM,1888
|
23
|
+
optimum/rbln/modeling_base.py,sha256=U0YbUG8lcKuZwdvY3BLYouvl-etwmXw2BT1Z3etFeeA,34582
|
24
|
+
optimum/rbln/modeling_config.py,sha256=R0GBd-upavJrpR-2SvfgCCxP7f5Zr0NxIqdKmwBfVCk,6439
|
25
|
+
optimum/rbln/modeling_seq2seq.py,sha256=XXYu_hpxOgQmMgayUy9URQwgMl9Ci2AfWyVHm7tMP5o,16783
|
26
|
+
optimum/rbln/transformers/__init__.py,sha256=OJX33eQx_iOE864MIRpoYCkstc57UtnNiIaoIATp2Zo,2202
|
27
|
+
optimum/rbln/transformers/cache_utils.py,sha256=VfArIkAJn3zPXdu-6RXiCWlU-uVwxvhgoMiGxrPtk40,3835
|
28
|
+
optimum/rbln/transformers/generation/__init__.py,sha256=6MmqS9D21ir4dcH6_fq8kRsX1VK3QspSn6Qw83F4ORE,1081
|
29
|
+
optimum/rbln/transformers/generation/streamers.py,sha256=X-dEmL1L_0Oy0QSFj2RNdamb_xbDWLXd-Ms8ckx6OZ4,5778
|
30
|
+
optimum/rbln/transformers/generation/utils.py,sha256=XqPbYQCe6cEuWssG9iHpbbL-wgSQTcyKHabGwKj7lnE,19462
|
31
|
+
optimum/rbln/transformers/models/__init__.py,sha256=pBJm_uxcyORi9A9UBdHAu3VdFy59PkuYuVek-31RiLs,1404
|
32
|
+
optimum/rbln/transformers/models/bart/__init__.py,sha256=SGUcpQ_5iLsVxySxtbwhRpmGt7BgVUTxHAjxAjQStdU,1063
|
33
|
+
optimum/rbln/transformers/models/bart/bart_architecture.py,sha256=T9GjcsL8fAJcvAs_ifnZuDP2F77hhbjBcsc7u53k6OE,14951
|
34
|
+
optimum/rbln/transformers/models/clip/__init__.py,sha256=tbco8qW9QhBe3dtWoKgslLZMsXu9dg_KfJ4IgjvK248,1071
|
35
|
+
optimum/rbln/transformers/models/clip/modeling_clip.py,sha256=WEXc9LWbClEzxeIw-LliI1A5OpiL7nnDm0G2IzYdqp4,3990
|
36
|
+
optimum/rbln/transformers/models/decoderonly/__init__.py,sha256=AG3ib8iZAEDAvVTNhieCyojWZtA67voPB0dI8lbCXTQ,1371
|
37
|
+
optimum/rbln/transformers/models/decoderonly/decoderonly_architecture.py,sha256=OLN0vvkIlEsP5xQ25x-kk-uw_V201TxWxVMUrGNkW-g,19045
|
38
|
+
optimum/rbln/transformers/models/decoderonly/modeling_decoderonly.py,sha256=7YfpYWHH3SNCmNYySj7Q-3WSi64pEqMaH1BmDdSYzi8,14191
|
39
|
+
optimum/rbln/transformers/models/dpt/__init__.py,sha256=R8OHDxOAYPjkk5t8osaPqRh85Pf1Cg1BtzqesqFRcTI,1045
|
40
|
+
optimum/rbln/transformers/models/dpt/modeling_dpt.py,sha256=uN_5DhjGbFmTbpm1JUBgPsDhMP_vIyc0QM2UK5DoRqc,3537
|
41
|
+
optimum/rbln/transformers/models/gemma/__init__.py,sha256=L1Qfr6dufWtoUZND_ofwxXPSxivEvPR8exy16a_nM2o,1042
|
42
|
+
optimum/rbln/transformers/models/gemma/gemma_architecture.py,sha256=nSLyuw9xMs2f17fVMNQiiuwRp813HP9q2uIyFhnDZ3o,4291
|
43
|
+
optimum/rbln/transformers/models/gemma/modeling_gemma.py,sha256=d47ahENZOJ2pNxyZr1ywvnUQhdBjMk5o72rjcqqLz0M,2465
|
44
|
+
optimum/rbln/transformers/models/gpt2/__init__.py,sha256=jsOKYXUclG9G6cwUTUX4eeKqjCPfQUwev7TTFIMXS4Y,1040
|
45
|
+
optimum/rbln/transformers/models/gpt2/gpt2_architecture.py,sha256=SIzwfQFRNvNOHjZmKcUZiURbnmXNXFh95twYELVmHcg,10278
|
46
|
+
optimum/rbln/transformers/models/gpt2/modeling_gpt2.py,sha256=TWfis7dqzPbm23cHfzLl43TwLzyS5nZMcgxSqxBnD1w,5513
|
47
|
+
optimum/rbln/transformers/models/llama/__init__.py,sha256=5mX-MuKzVBj6WQeVxyPhtvFTv0jeZXAFfg4RZ2nVUh0,1042
|
48
|
+
optimum/rbln/transformers/models/llama/llama_architecture.py,sha256=j4mifSOaIk7wwV9fL9wQSt5kR3rpnvjtxd3VzhMNdgY,1123
|
49
|
+
optimum/rbln/transformers/models/llama/modeling_llama.py,sha256=RXv7yyf3dC1h02seAxpRlzrvofgdy9OWE4P8SRwUlk0,2465
|
50
|
+
optimum/rbln/transformers/models/midm/__init__.py,sha256=_6kYchy47frGMZ8uoUspZ9IwrmCBQJ-8kVfXM7xOMew,1249
|
51
|
+
optimum/rbln/transformers/models/midm/hf_hub_cached/configuration_midm.py,sha256=P5JqTTcx56HOccxKbR14ZjA67BI0RNnJycG738JMaJ4,833
|
52
|
+
optimum/rbln/transformers/models/midm/hf_hub_cached/midm_bitext_tokenization.py,sha256=5lhMXfqnIak1PJ9YL-vUxIdY_3DUr3IBXzTqf3ofpmI,12835
|
53
|
+
optimum/rbln/transformers/models/midm/hf_hub_cached/modeling_midm.py,sha256=54__wd9EXwGxmaHDksTTcUD2aWl6WoszYsR8dlL1wfE,61031
|
54
|
+
optimum/rbln/transformers/models/midm/hf_hub_cached/rotary_position_embedding.py,sha256=5ywaUVKTvqO8GRsHOSXOOGlbiEn-DbGkpJs59_dFb18,4059
|
55
|
+
optimum/rbln/transformers/models/midm/midm_architecture.py,sha256=IFnu54MVPFEk5pvaeJ8RZGlCR7X-9MMeTKThXOP6_M0,11367
|
56
|
+
optimum/rbln/transformers/models/midm/modeling_midm.py,sha256=y16ALbYdvlpAhXxrXvVmDYk6uc27u79J8SognYVC-VE,5504
|
57
|
+
optimum/rbln/transformers/models/t5/__init__.py,sha256=dK6F1jbBf001h79WZiVdiNZoXm5kOe2fskzhREhu0EE,1057
|
58
|
+
optimum/rbln/transformers/models/t5/t5_architecture.py,sha256=2nFovfOdiJdY9jdAR9BngwPO3d2Oofn9jqVWgZ-YYZ0,18091
|
59
|
+
optimum/rbln/transformers/models/wav2vec2/__init__.py,sha256=mz4cXqG9b0tDpTAw3qYn3FaJuolX601VmKBE3gohLSw,1043
|
60
|
+
optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py,sha256=kooQ1CC6p2mHvRHkFE48d69yNTnkG_V6g9Beu6Sy3XU,4063
|
61
|
+
optimum/rbln/transformers/models/whisper/__init__.py,sha256=PZ8qeAAFMas2MizwVYFxlpFWd5k1Pe1x-0IJfYAMhT8,1059
|
62
|
+
optimum/rbln/transformers/models/whisper/modeling_whisper.py,sha256=L49ThCv5sqidNevBGsCpGrOSH4H6wzXOCmON1PCmY9M,11996
|
63
|
+
optimum/rbln/transformers/models/whisper/whisper_architecture.py,sha256=QtHP5bXUa9HXa95rEdaqsmbH3eG2QJgUBTV1OG7LF-I,15879
|
64
|
+
optimum/rbln/transformers/models/xlm_roberta/__init__.py,sha256=NTj4hCpd8L2_i5DZuV5wp-h8OlTLYVUqTrJxzY_Dg9g,1047
|
65
|
+
optimum/rbln/transformers/models/xlm_roberta/modeling_xlm_roberta.py,sha256=krLNMjsmK2I_Ai2JUJzLqE1HIrTDNhpTY2EDQFQV6Kg,4971
|
66
|
+
optimum/rbln/utils/__init__.py,sha256=F6hJP00eV1_hT_IVwqqYwLWcLQAvZbmmrNMJTia3mjI,1106
|
67
|
+
optimum/rbln/utils/import_utils.py,sha256=i2GmQJC9kl4BvXncVUrqx8VCqfv1omaHiWyCliBxChg,2632
|
68
|
+
optimum/rbln/utils/runtime_utils.py,sha256=EzEabg2E18nq2WZRDZWsZ_hgrdgQ7u_NElTMAYpSDvM,2545
|
69
|
+
optimum/rbln/utils/save_utils.py,sha256=eFIPtmiblCJ3MvtxEPxmAR3iuLEUrzpyzwtVotDauhw,3283
|
70
|
+
optimum_rbln-0.1.8.dist-info/METADATA,sha256=UJKCmPXw-b8Jm1ie2bAWVowLdYQWUuYD-Tz3-WGwksk,4311
|
71
|
+
optimum_rbln-0.1.8.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
|
72
|
+
optimum_rbln-0.1.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
73
|
+
optimum_rbln-0.1.8.dist-info/RECORD,,
|