optimum-rbln 0.1.4__py3-none-any.whl → 0.1.7__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 +7 -0
- optimum/rbln/__version__.py +1 -1
- optimum/rbln/diffusers/models/autoencoder_kl.py +16 -98
- optimum/rbln/diffusers/models/unet_2d_condition.py +1 -1
- optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py +9 -11
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py +8 -0
- optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +9 -0
- 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_base.py +172 -100
- optimum/rbln/modeling_seq2seq.py +58 -132
- optimum/rbln/transformers/__init__.py +2 -0
- optimum/rbln/transformers/models/__init__.py +1 -0
- optimum/rbln/transformers/models/clip/modeling_clip.py +0 -1
- optimum/rbln/transformers/models/dpt/__init__.py +24 -0
- optimum/rbln/transformers/models/dpt/modeling_dpt.py +89 -0
- optimum/rbln/transformers/models/gpt2/gpt2_architecture.py +24 -33
- optimum/rbln/transformers/models/gpt2/modeling_gpt2.py +52 -124
- optimum/rbln/transformers/models/llama/llama_architecture.py +13 -16
- optimum/rbln/transformers/models/llama/llama_architecture_cb.py +41 -36
- optimum/rbln/transformers/models/llama/modeling_llama.py +94 -120
- optimum/rbln/transformers/models/midm/modeling_midm.py +85 -121
- optimum/rbln/transformers/models/whisper/modeling_whisper.py +53 -123
- 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.7.dist-info}/METADATA +17 -51
- {optimum_rbln-0.1.4.dist-info → optimum_rbln-0.1.7.dist-info}/RECORD +31 -29
- {optimum_rbln-0.1.4.dist-info → optimum_rbln-0.1.7.dist-info}/WHEEL +1 -1
- {optimum_rbln-0.1.4.dist-info → optimum_rbln-0.1.7.dist-info}/licenses/LICENSE +0 -0
@@ -23,13 +23,10 @@
|
|
23
23
|
|
24
24
|
import inspect
|
25
25
|
import logging
|
26
|
-
from pathlib import Path
|
27
|
-
from tempfile import TemporaryDirectory
|
28
26
|
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
|
29
27
|
|
30
28
|
import rebel
|
31
29
|
import torch
|
32
|
-
from optimum.exporters import TasksManager
|
33
30
|
from transformers import (
|
34
31
|
AutoModelForSpeechSeq2Seq,
|
35
32
|
AutoProcessor,
|
@@ -40,10 +37,9 @@ from transformers import (
|
|
40
37
|
)
|
41
38
|
from transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput
|
42
39
|
|
43
|
-
from ....modeling_base import
|
40
|
+
from ....modeling_base import RBLNModel
|
44
41
|
from ....modeling_config import DEFAULT_COMPILED_MODEL_NAME, RBLNConfig, RBLNRuntimeConfig
|
45
42
|
from ....utils.runtime_utils import RBLNPytorchRuntime
|
46
|
-
from ....utils.save_utils import maybe_save_preprocessors
|
47
43
|
from .whisper_architecture import (
|
48
44
|
_WhisperDecoderWrapper,
|
49
45
|
_WhisperEncoderWrapper,
|
@@ -76,10 +72,10 @@ class RBLNRuntimeDecoder(RBLNPytorchRuntime):
|
|
76
72
|
return Seq2SeqLMOutput(logits=outputs)
|
77
73
|
|
78
74
|
|
79
|
-
class RBLNWhisperForConditionalGeneration(
|
75
|
+
class RBLNWhisperForConditionalGeneration(RBLNModel, GenerationMixin):
|
80
76
|
"""
|
81
77
|
The Whisper Model with a language modeling head. Can be used for automatic speech recognition.
|
82
|
-
This model inherits from [`
|
78
|
+
This model inherits from [`RBLNMultiModel`]. Check the superclass documentation for the generic methods the library implements for all its models.
|
83
79
|
|
84
80
|
A class to convert and run pre-trained transformers based LlamaForCausalLM model on RBLN devices.
|
85
81
|
It implements the methods to convert a pre-trained transformers LlamaForCausalLM model into a RBLN transformer model by:
|
@@ -96,8 +92,8 @@ class RBLNWhisperForConditionalGeneration(RBLNBaseModel, GenerationMixin):
|
|
96
92
|
self.enc_max_seq_len = self.rbln_config.meta["input_max_length"]
|
97
93
|
self.dec_max_seq_len = self.rbln_config.meta["rbln_dec_max_seq_len"]
|
98
94
|
|
99
|
-
self.encoder = RBLNRuntimeEncoder(runtime=self.
|
100
|
-
self.decoder = RBLNRuntimeDecoder(runtime=self.
|
95
|
+
self.encoder = RBLNRuntimeEncoder(runtime=self.model[0], main_input_name="input_features")
|
96
|
+
self.decoder = RBLNRuntimeDecoder(runtime=self.model[1], main_input_name="input_ids")
|
101
97
|
self.forced_decoder_ids = self.config.forced_decoder_ids
|
102
98
|
|
103
99
|
# used in GenerationMixin.generate()
|
@@ -152,123 +148,57 @@ class RBLNWhisperForConditionalGeneration(RBLNBaseModel, GenerationMixin):
|
|
152
148
|
}
|
153
149
|
|
154
150
|
@classmethod
|
155
|
-
def
|
156
|
-
cls,
|
157
|
-
model_id: str,
|
158
|
-
config: "PretrainedConfig",
|
159
|
-
use_auth_token: Optional[Union[bool, str]] = None,
|
160
|
-
revision: Optional[str] = None,
|
161
|
-
force_download: bool = False,
|
162
|
-
cache_dir: Optional[str] = None,
|
163
|
-
subfolder: str = "",
|
164
|
-
local_files_only: bool = False,
|
165
|
-
trust_remote_code: bool = False,
|
166
|
-
model_save_dir: Optional[Union[str, Path, TemporaryDirectory]] = None,
|
167
|
-
**kwargs,
|
168
|
-
) -> "RBLNWhisperForConditionalGeneration":
|
169
|
-
"""
|
170
|
-
Exports a vanilla Transformers model into a rbln-compiled Module.
|
171
|
-
"""
|
172
|
-
task = kwargs.pop("task", None)
|
173
|
-
if task is None:
|
174
|
-
task = TasksManager.infer_task_from_model(cls.auto_model_class)
|
175
|
-
|
176
|
-
if model_save_dir is None:
|
177
|
-
save_dir = TemporaryDirectory()
|
178
|
-
save_dir_path = Path(save_dir.name)
|
179
|
-
else:
|
180
|
-
save_dir = model_save_dir
|
181
|
-
if isinstance(save_dir, TemporaryDirectory):
|
182
|
-
save_dir_path = Path(model_save_dir.name)
|
183
|
-
else:
|
184
|
-
save_dir_path = Path(model_save_dir)
|
185
|
-
save_dir_path.mkdir(exist_ok=True)
|
186
|
-
|
151
|
+
def update_kwargs(cls, kwargs):
|
187
152
|
kwargs.update(
|
188
153
|
{
|
189
154
|
"torchscript": True,
|
190
155
|
"return_dict": False,
|
191
|
-
"use_cache":
|
156
|
+
"use_cache": True,
|
192
157
|
}
|
193
158
|
)
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
159
|
+
return kwargs
|
160
|
+
|
161
|
+
@classmethod
|
162
|
+
@torch.inference_mode()
|
163
|
+
def get_compiled_model(cls, model, rbln_config: RBLNConfig):
|
164
|
+
wrapped_encoder = _WhisperEncoderWrapper(model).eval()
|
165
|
+
wrapped_decoder = _WhisperDecoderWrapper(model).eval()
|
166
|
+
|
167
|
+
enc_rbln_runtime_config = rbln_config[DEFAULT_COMPILED_MODEL_NAME][0]
|
168
|
+
dec_rbln_runtime_config = rbln_config[DEFAULT_COMPILED_MODEL_NAME][1]
|
169
|
+
|
170
|
+
enc_example_inputs = enc_rbln_runtime_config.get_dummy_inputs(fill=1)
|
171
|
+
dec_example_inputs = dec_rbln_runtime_config.get_dummy_inputs(fill=1)
|
172
|
+
|
173
|
+
enc_scripted_model = torch.jit.trace(wrapped_encoder, enc_example_inputs[0], check_trace=False)
|
174
|
+
dec_scripted_model = torch.jit.trace(wrapped_decoder, dec_example_inputs, check_trace=False)
|
175
|
+
|
176
|
+
enc_ir = rebel.torchscript_to_ir(
|
177
|
+
enc_scripted_model,
|
178
|
+
input_names=[v[0] for v in enc_rbln_runtime_config.input_info],
|
179
|
+
name=enc_rbln_runtime_config.rbln_mod_name,
|
180
|
+
)
|
181
|
+
dec_ir = rebel.torchscript_to_ir(
|
182
|
+
dec_scripted_model,
|
183
|
+
input_names=[v[0] for v in dec_rbln_runtime_config.input_info],
|
184
|
+
name=dec_rbln_runtime_config.rbln_mod_name,
|
208
185
|
)
|
186
|
+
dec_ir.batch_size = dec_rbln_runtime_config.batch_size
|
209
187
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
def compile_whisper():
|
223
|
-
wrapped_encoder = _WhisperEncoderWrapper(model).eval()
|
224
|
-
wrapped_decoder = _WhisperDecoderWrapper(model).eval()
|
225
|
-
|
226
|
-
enc_rbln_runtime_config = rbln_config[DEFAULT_COMPILED_MODEL_NAME][0]
|
227
|
-
dec_rbln_runtime_config = rbln_config[DEFAULT_COMPILED_MODEL_NAME][1]
|
228
|
-
|
229
|
-
enc_example_inputs = enc_rbln_runtime_config.get_dummy_inputs(fill=1)
|
230
|
-
dec_example_inputs = dec_rbln_runtime_config.get_dummy_inputs(fill=1)
|
231
|
-
|
232
|
-
enc_scripted_model = torch.jit.trace(wrapped_encoder, enc_example_inputs[0]).eval()
|
233
|
-
dec_scripted_model = torch.jit.trace(wrapped_decoder, dec_example_inputs).eval()
|
234
|
-
|
235
|
-
enc_ir = rebel.torchscript_to_ir(
|
236
|
-
enc_scripted_model,
|
237
|
-
input_names=[v[0] for v in enc_rbln_runtime_config.input_info],
|
238
|
-
name=enc_rbln_runtime_config.rbln_mod_name,
|
239
|
-
)
|
240
|
-
dec_ir = rebel.torchscript_to_ir(
|
241
|
-
dec_scripted_model,
|
242
|
-
input_names=[v[0] for v in dec_rbln_runtime_config.input_info],
|
243
|
-
name=dec_rbln_runtime_config.rbln_mod_name,
|
244
|
-
)
|
245
|
-
dec_ir.batch_size = dec_rbln_runtime_config.batch_size
|
246
|
-
|
247
|
-
# Caching encoder/decoder I/O
|
248
|
-
connections = [
|
249
|
-
(enc_ir.outputs[0], dec_ir.inputs[4]),
|
250
|
-
(dec_ir.outputs[1], dec_ir.inputs[3]),
|
251
|
-
]
|
252
|
-
compiled_model = rebel.compile(
|
253
|
-
enc_ir,
|
254
|
-
dec_ir,
|
255
|
-
connections=connections,
|
256
|
-
fusion=enc_rbln_runtime_config.fusion,
|
257
|
-
npu=enc_rbln_runtime_config.npu,
|
258
|
-
tensor_parallel_size=enc_rbln_runtime_config.tensor_parallel_size,
|
259
|
-
)
|
260
|
-
compiled_model.save(save_dir_path / f"{DEFAULT_COMPILED_MODEL_NAME}.rbln")
|
261
|
-
|
262
|
-
compile_whisper()
|
263
|
-
rbln_config.save(save_dir_path)
|
264
|
-
|
265
|
-
return cls._from_pretrained(
|
266
|
-
model_id=save_dir_path,
|
267
|
-
config=config,
|
268
|
-
model_save_dir=save_dir,
|
269
|
-
**rbln_constructor_kwargs,
|
270
|
-
**kwargs,
|
188
|
+
# Caching encoder/decoder I/O
|
189
|
+
connections = [
|
190
|
+
(enc_ir.outputs[0], dec_ir.inputs[4]),
|
191
|
+
(dec_ir.outputs[1], dec_ir.inputs[3]),
|
192
|
+
]
|
193
|
+
compiled_model = rebel.compile(
|
194
|
+
enc_ir,
|
195
|
+
dec_ir,
|
196
|
+
connections=connections,
|
197
|
+
fusion=enc_rbln_runtime_config.fusion,
|
198
|
+
npu=enc_rbln_runtime_config.npu,
|
199
|
+
tensor_parallel_size=enc_rbln_runtime_config.tensor_parallel_size,
|
271
200
|
)
|
201
|
+
return compiled_model
|
272
202
|
|
273
203
|
@classmethod
|
274
204
|
def _get_rbln_config(
|
@@ -357,11 +287,14 @@ class RBLNWhisperForConditionalGeneration(RBLNBaseModel, GenerationMixin):
|
|
357
287
|
|
358
288
|
return rbln_config
|
359
289
|
|
360
|
-
|
290
|
+
@classmethod
|
291
|
+
def _create_runtimes(
|
292
|
+
cls, compiled_models: List[rebel.RBLNCompiledModel], rbln_device_map: Dict[str, int]
|
293
|
+
) -> List[rebel.Runtime]:
|
361
294
|
device_val = rbln_device_map[DEFAULT_COMPILED_MODEL_NAME]
|
362
295
|
return [
|
363
|
-
|
364
|
-
|
296
|
+
compiled_models[0].create_runtime("encoder", tensor_type="pt", device=device_val),
|
297
|
+
compiled_models[0].create_runtime("decoder", tensor_type="pt", device=device_val),
|
365
298
|
]
|
366
299
|
|
367
300
|
def forward(
|
@@ -379,6 +312,3 @@ class RBLNWhisperForConditionalGeneration(RBLNBaseModel, GenerationMixin):
|
|
379
312
|
lm_logits = decoder_output.logits
|
380
313
|
|
381
314
|
return Seq2SeqLMOutput(logits=lm_logits)
|
382
|
-
|
383
|
-
def __repr__(self):
|
384
|
-
return repr(self.runtimes[0]) + "\n" + repr(self.runtimes[1])
|
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.7
|
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
|
23
|
+
Requires-Dist: torch<=2.2.1
|
24
24
|
Requires-Dist: optimum>=1.17.1
|
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,11 @@ 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
38
|
Requires-Dist: black>=24.3.0; extra == "quality"
|
40
39
|
Requires-Dist: ruff>=0.3.3; extra == "quality"
|
41
40
|
Requires-Dist: isort>=5.13.2; extra == "quality"
|
42
41
|
Requires-Dist: hf-doc-builder>=0.5.0; extra == "quality"
|
43
|
-
Provides-Extra: diffusers
|
44
42
|
Provides-Extra: tests
|
45
43
|
Provides-Extra: quality
|
46
44
|
Description-Content-Type: text/markdown
|
@@ -65,26 +63,28 @@ limitations under the License.
|
|
65
63
|
|
66
64
|
🤗 Optimum RBLN is the interface between the 🤗 Transformers library and RBLN Accelerators including [ATOM](https://atom_link) and [REBEL](https://rebel_link).
|
67
65
|
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](
|
66
|
+
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
67
|
|
70
68
|
## Install from PyPI
|
71
69
|
|
72
70
|
To install the latest release of this package:
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
- Export environment variables to access to RBLN private PyPI.
|
73
|
+
```bash
|
74
|
+
export REBEL_PYPI_USERNAME=<username>
|
75
|
+
export REBEL_PYPI_PASSWORD=<password>
|
76
|
+
```
|
77
|
+
|
78
|
+
- Install optimum-rbln package:
|
79
|
+
```bash
|
80
|
+
pip install --index-url https://pypi.rebellions.in/simple optimum-rbln
|
81
|
+
```
|
77
82
|
|
78
83
|
## Install from source
|
79
84
|
|
80
85
|
### Prerequisites
|
81
86
|
|
82
87
|
- 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
88
|
|
89
89
|
The below command installs optimum-rbln along with its dependencies.
|
90
90
|
|
@@ -106,40 +106,6 @@ pdm install -G:all
|
|
106
106
|
|
107
107
|
🤗 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
108
|
|
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
109
|
### Documentation
|
142
110
|
|
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.
|
111
|
+
Check out [the documentation of Optimum RBLN](https://docs.rbln.ai/software/optimum/optimum_rbln.html) for more advanced usage.
|
@@ -1,63 +1,65 @@
|
|
1
|
-
optimum/rbln/__init__.py,sha256=
|
2
|
-
optimum/rbln/__version__.py,sha256=
|
1
|
+
optimum/rbln/__init__.py,sha256=m2CcYYJw98tSvIFSNJJc5yzrjYKsUdEeBBvsX3a5koI,4251
|
2
|
+
optimum/rbln/__version__.py,sha256=V7LnX330m3uiAO0EYQbPUYETPj2br2y1Pv-a7ApMj40,21
|
3
3
|
optimum/rbln/diffusers/__init__.py,sha256=JWeu2ihHKiYD0Uzs9jXbaAq-bA1G86UCMPPx_oiJYFU,2606
|
4
4
|
optimum/rbln/diffusers/models/__init__.py,sha256=aY6Llq_31dZjdB9HPBDvi7sXVtdQT9r11gokXG5ffxA,1139
|
5
|
-
optimum/rbln/diffusers/models/autoencoder_kl.py,sha256=
|
5
|
+
optimum/rbln/diffusers/models/autoencoder_kl.py,sha256=qIhXCfEADNTm2U9I5ZFN1IfA01zwupUY0IBnJwvxLwI,9506
|
6
6
|
optimum/rbln/diffusers/models/controlnet.py,sha256=7T5E-RvGawT2uEtuJYxGTrzIDbApcF13zuXbVCcoQVI,9224
|
7
|
-
optimum/rbln/diffusers/models/unet_2d_condition.py,sha256=
|
7
|
+
optimum/rbln/diffusers/models/unet_2d_condition.py,sha256=tdNQHSdN92MlErpsvPpiUleRGhRa9GH0FSFZoSA6-wk,14468
|
8
8
|
optimum/rbln/diffusers/pipelines/__init__.py,sha256=Xr_bQbpbC5HbJB2NuUcVQu2BGebDkc2bhsGJmL6jgps,1449
|
9
9
|
optimum/rbln/diffusers/pipelines/controlnet/__init__.py,sha256=k0govvSBxBUR5qpxUGxRMHuQCMX7hXHVZ4EqVRw1LWk,1377
|
10
|
-
optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py,sha256
|
11
|
-
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py,sha256=
|
12
|
-
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py,sha256=
|
10
|
+
optimum/rbln/diffusers/pipelines/controlnet/multicontrolnet.py,sha256=-Mtot-EJbYnySLKX7v0Im9UQyo2H2HjlZiO31SosbbQ,9592
|
11
|
+
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet.py,sha256=QK8C9mCgCCPTy_sj6PjiwlQzj8sKwUSDWKYeMT3Vb7A,39936
|
12
|
+
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py,sha256=8wUn937eZvr8uVLhTtw-OwF9r_iwdQ1_RpD4XNkarAU,38481
|
13
13
|
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py,sha256=qe2ZW-ugpnfatx7bx1a21C_40kVMSp8DsQ5fl2DFoKM,49849
|
14
14
|
optimum/rbln/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py,sha256=DKai4mdW_fkhdD4yjIGKyKv00COFH-Nz5ux9jmatjWE,51196
|
15
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=
|
17
|
-
optimum/rbln/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py,sha256=
|
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
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=
|
20
|
-
optimum/rbln/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py,sha256=
|
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
21
|
optimum/rbln/modeling.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
optimum/rbln/modeling_alias.py,sha256=pyYGME31QaiBaLqnjQq3LwUF1T6dLeb8QLB91gzNsLM,1574
|
23
|
-
optimum/rbln/modeling_base.py,sha256=
|
23
|
+
optimum/rbln/modeling_base.py,sha256=779VbQy6gxCkCaa75KAbP87EqBkTQV4RW_roqjxrNMg,29564
|
24
24
|
optimum/rbln/modeling_config.py,sha256=R0GBd-upavJrpR-2SvfgCCxP7f5Zr0NxIqdKmwBfVCk,6439
|
25
|
-
optimum/rbln/modeling_seq2seq.py,sha256=
|
26
|
-
optimum/rbln/transformers/__init__.py,sha256=
|
25
|
+
optimum/rbln/modeling_seq2seq.py,sha256=XXYu_hpxOgQmMgayUy9URQwgMl9Ci2AfWyVHm7tMP5o,16783
|
26
|
+
optimum/rbln/transformers/__init__.py,sha256=fgRvfcQps-YEpXV3h0uz0VBXB1Ts9t-DZRwjS0zHUNU,1992
|
27
27
|
optimum/rbln/transformers/generation/__init__.py,sha256=6MmqS9D21ir4dcH6_fq8kRsX1VK3QspSn6Qw83F4ORE,1081
|
28
28
|
optimum/rbln/transformers/generation/streamers.py,sha256=X-dEmL1L_0Oy0QSFj2RNdamb_xbDWLXd-Ms8ckx6OZ4,5778
|
29
29
|
optimum/rbln/transformers/generation/utils.py,sha256=F8gnVYG79kzg_IvQynD-p409E_5loy5VaIXvfi094u0,19464
|
30
|
-
optimum/rbln/transformers/models/__init__.py,sha256=
|
30
|
+
optimum/rbln/transformers/models/__init__.py,sha256=8sOIypsvyrKk3bxsdiibCspmQVxc-xMx3WsUbDyMOfM,1319
|
31
31
|
optimum/rbln/transformers/models/bart/__init__.py,sha256=SGUcpQ_5iLsVxySxtbwhRpmGt7BgVUTxHAjxAjQStdU,1063
|
32
32
|
optimum/rbln/transformers/models/bart/bart_architecture.py,sha256=H8yVoBFa5uMXQv_wYCHKRW6tIIjdD50ho9C0vcMsbSo,14956
|
33
33
|
optimum/rbln/transformers/models/clip/__init__.py,sha256=tbco8qW9QhBe3dtWoKgslLZMsXu9dg_KfJ4IgjvK248,1071
|
34
|
-
optimum/rbln/transformers/models/clip/modeling_clip.py,sha256=
|
34
|
+
optimum/rbln/transformers/models/clip/modeling_clip.py,sha256=WEXc9LWbClEzxeIw-LliI1A5OpiL7nnDm0G2IzYdqp4,3990
|
35
|
+
optimum/rbln/transformers/models/dpt/__init__.py,sha256=R8OHDxOAYPjkk5t8osaPqRh85Pf1Cg1BtzqesqFRcTI,1045
|
36
|
+
optimum/rbln/transformers/models/dpt/modeling_dpt.py,sha256=uN_5DhjGbFmTbpm1JUBgPsDhMP_vIyc0QM2UK5DoRqc,3537
|
35
37
|
optimum/rbln/transformers/models/gpt2/__init__.py,sha256=jsOKYXUclG9G6cwUTUX4eeKqjCPfQUwev7TTFIMXS4Y,1040
|
36
|
-
optimum/rbln/transformers/models/gpt2/gpt2_architecture.py,sha256=
|
37
|
-
optimum/rbln/transformers/models/gpt2/modeling_gpt2.py,sha256=
|
38
|
+
optimum/rbln/transformers/models/gpt2/gpt2_architecture.py,sha256=QiNKLhBZ_-1bcq-7WQ4Bd2MK5xj9XR35IdkwEgCA6lk,10004
|
39
|
+
optimum/rbln/transformers/models/gpt2/modeling_gpt2.py,sha256=coWguusgbBhQ8yUfl7EFOCPnzeujDQpepRdd09czRZg,12471
|
38
40
|
optimum/rbln/transformers/models/llama/__init__.py,sha256=5mX-MuKzVBj6WQeVxyPhtvFTv0jeZXAFfg4RZ2nVUh0,1042
|
39
|
-
optimum/rbln/transformers/models/llama/llama_architecture.py,sha256=
|
40
|
-
optimum/rbln/transformers/models/llama/llama_architecture_cb.py,sha256=
|
41
|
-
optimum/rbln/transformers/models/llama/modeling_llama.py,sha256=
|
41
|
+
optimum/rbln/transformers/models/llama/llama_architecture.py,sha256=bBUZBAsBvsvxY-_gGUofm5zn-piu61pooZr86Ib2CuI,27086
|
42
|
+
optimum/rbln/transformers/models/llama/llama_architecture_cb.py,sha256=bhbi0MAee0k1cHeB20c0maD89fxT-53DSf1Mn8ZhgjA,32719
|
43
|
+
optimum/rbln/transformers/models/llama/modeling_llama.py,sha256=kTMxJwHRdK0XJFu_OfVWq3iWdOXZkDf4TdKzsi0uQWQ,19821
|
42
44
|
optimum/rbln/transformers/models/midm/__init__.py,sha256=_6kYchy47frGMZ8uoUspZ9IwrmCBQJ-8kVfXM7xOMew,1249
|
43
45
|
optimum/rbln/transformers/models/midm/hf_hub_cached/configuration_midm.py,sha256=P5JqTTcx56HOccxKbR14ZjA67BI0RNnJycG738JMaJ4,833
|
44
46
|
optimum/rbln/transformers/models/midm/hf_hub_cached/midm_bitext_tokenization.py,sha256=p8U2Owo8KJzOnrI5vAcDkT2DCt3r-05zFDD2m6D4pEg,12835
|
45
47
|
optimum/rbln/transformers/models/midm/hf_hub_cached/modeling_midm.py,sha256=v5M_uQsdRUyPaiWEATv_FHp-2Duq2moyQJKSFVY-k1U,61035
|
46
48
|
optimum/rbln/transformers/models/midm/hf_hub_cached/rotary_position_embedding.py,sha256=5ywaUVKTvqO8GRsHOSXOOGlbiEn-DbGkpJs59_dFb18,4059
|
47
49
|
optimum/rbln/transformers/models/midm/midm_architecture.py,sha256=G3fSKuh9CGZXyjM1UPZ3wQAYDDLJZcRlKmV_NgcyfJE,19138
|
48
|
-
optimum/rbln/transformers/models/midm/modeling_midm.py,sha256=
|
50
|
+
optimum/rbln/transformers/models/midm/modeling_midm.py,sha256=UAZRE9PIVomfA7XgCc1quXl3Kfb2J1rKH-dmSf50EdE,15214
|
49
51
|
optimum/rbln/transformers/models/t5/__init__.py,sha256=dK6F1jbBf001h79WZiVdiNZoXm5kOe2fskzhREhu0EE,1057
|
50
52
|
optimum/rbln/transformers/models/t5/t5_architecture.py,sha256=2nFovfOdiJdY9jdAR9BngwPO3d2Oofn9jqVWgZ-YYZ0,18091
|
51
53
|
optimum/rbln/transformers/models/wav2vec2/__init__.py,sha256=mz4cXqG9b0tDpTAw3qYn3FaJuolX601VmKBE3gohLSw,1043
|
52
54
|
optimum/rbln/transformers/models/wav2vec2/modeling_wav2vec2.py,sha256=kooQ1CC6p2mHvRHkFE48d69yNTnkG_V6g9Beu6Sy3XU,4063
|
53
55
|
optimum/rbln/transformers/models/whisper/__init__.py,sha256=PZ8qeAAFMas2MizwVYFxlpFWd5k1Pe1x-0IJfYAMhT8,1059
|
54
|
-
optimum/rbln/transformers/models/whisper/modeling_whisper.py,sha256=
|
56
|
+
optimum/rbln/transformers/models/whisper/modeling_whisper.py,sha256=L49ThCv5sqidNevBGsCpGrOSH4H6wzXOCmON1PCmY9M,11996
|
55
57
|
optimum/rbln/transformers/models/whisper/whisper_architecture.py,sha256=QX1Nmq26F_82EYgKmdgXEpE2F8ry-inkn2BB9Lx5M38,15885
|
56
|
-
optimum/rbln/utils/__init__.py,sha256=
|
57
|
-
optimum/rbln/utils/import_utils.py,sha256=
|
58
|
+
optimum/rbln/utils/__init__.py,sha256=F6hJP00eV1_hT_IVwqqYwLWcLQAvZbmmrNMJTia3mjI,1106
|
59
|
+
optimum/rbln/utils/import_utils.py,sha256=i2GmQJC9kl4BvXncVUrqx8VCqfv1omaHiWyCliBxChg,2632
|
58
60
|
optimum/rbln/utils/runtime_utils.py,sha256=EzEabg2E18nq2WZRDZWsZ_hgrdgQ7u_NElTMAYpSDvM,2545
|
59
61
|
optimum/rbln/utils/save_utils.py,sha256=eFIPtmiblCJ3MvtxEPxmAR3iuLEUrzpyzwtVotDauhw,3283
|
60
|
-
optimum_rbln-0.1.
|
61
|
-
optimum_rbln-0.1.
|
62
|
-
optimum_rbln-0.1.
|
63
|
-
optimum_rbln-0.1.
|
62
|
+
optimum_rbln-0.1.7.dist-info/METADATA,sha256=5B8Cx1-EWbf1C9VoUUiFJ2iXqIk8e-CExfgKgSZMGwU,4360
|
63
|
+
optimum_rbln-0.1.7.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
|
64
|
+
optimum_rbln-0.1.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
65
|
+
optimum_rbln-0.1.7.dist-info/RECORD,,
|
File without changes
|