gimlet-api 0.0.8__py3-none-any.whl → 0.0.10__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.
- {gimlet_api-0.0.8.dist-info → gimlet_api-0.0.10.dist-info}/METADATA +4 -2
- {gimlet_api-0.0.8.dist-info → gimlet_api-0.0.10.dist-info}/RECORD +22 -20
- gml/client.py +29 -20
- gml/compile.py +48 -2
- gml/device.py +2 -0
- gml/hf.py +240 -38
- gml/model.py +37 -0
- gml/pipelines.py +21 -1
- gml/preprocessing.py +17 -3
- gml/proto/opentelemetry/proto/metrics/v1/metrics_pb2.py +39 -38
- gml/proto/src/api/corepb/v1/compiled_pipeline_pb2.py +64 -0
- gml/proto/src/api/corepb/v1/controlplane_pb2.py +60 -29
- gml/proto/src/api/corepb/v1/cp_edge_pb2.py +37 -35
- gml/proto/src/api/corepb/v1/deployed_pipeline_pb2.py +37 -0
- gml/proto/src/api/corepb/v1/device_info_pb2.py +21 -9
- gml/proto/src/api/corepb/v1/gem_config_pb2.py +28 -15
- gml/proto/src/api/corepb/v1/mediastream_pb2.py +42 -39
- gml/proto/src/api/corepb/v1/model_exec_pb2.py +131 -107
- gml/proto/src/controlplane/compiler/cpb/v1/cpb_pb2.py +22 -7
- gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2.py +25 -23
- gml/tensor.py +4 -0
- {gimlet_api-0.0.8.dist-info → gimlet_api-0.0.10.dist-info}/WHEEL +0 -0
@@ -9,11 +9,13 @@ Classifier: Typing :: Typed
|
|
9
9
|
Requires-Python: >=3
|
10
10
|
Requires-Dist: protobuf
|
11
11
|
Requires-Dist: grpcio
|
12
|
-
Requires-Dist: torch>=2.
|
12
|
+
Requires-Dist: torch>=2.6.0
|
13
13
|
Requires-Dist: torch-mlir-gml
|
14
14
|
Requires-Dist: numpy<2.0.0
|
15
|
+
Requires-Dist: rich
|
15
16
|
Requires-Dist: transformers>=4.43.3
|
17
|
+
Requires-Dist: tokenizers>=0.21.0
|
16
18
|
Requires-Dist: safetensors-mlir
|
17
|
-
Version: 0.0.
|
19
|
+
Version: 0.0.10
|
18
20
|
|
19
21
|
UNKNOWN
|
@@ -1,14 +1,14 @@
|
|
1
1
|
gml/__init__.py,sha256=H3WQZ_RaN7VNeb__qeHEbKLEwkaG7gpL5FQ8s1IotUA,773
|
2
2
|
gml/_utils.py,sha256=mSCWHhCdzcUvHqmJIB2FS215K1LMgJCWcZ6e6FWK3hQ,1184
|
3
3
|
gml/asset_manager.py,sha256=VnbqUZHPOgPrAh6ri9C0EuNhS8tAHIrbUyJPAJuD9po,2053
|
4
|
-
gml/client.py,sha256=
|
5
|
-
gml/compile.py,sha256=
|
6
|
-
gml/device.py,sha256=
|
7
|
-
gml/hf.py,sha256=
|
8
|
-
gml/model.py,sha256=
|
4
|
+
gml/client.py,sha256=AcnG5mniHOfq-He-uCph2-xQ39cZwmXZePaUEed87b8,14378
|
5
|
+
gml/compile.py,sha256=3L5fpD8DK45RLiywj1b5NuDlbsxpzRxI87k1GahlMpc,9851
|
6
|
+
gml/device.py,sha256=Iw71NnuLcgjY32ZMXHlnlPkosTuHEmL9E98utmNChlM,2650
|
7
|
+
gml/hf.py,sha256=Kv2yffy8omTRQDPnoIZocG2EOyfhr7UvLFIvTmRxw0g,36170
|
8
|
+
gml/model.py,sha256=8fIYlLRduTsUZfYJr_YVPNxbEVIzr7_yaaTe4T-TZ2Y,8429
|
9
9
|
gml/model_utils.py,sha256=vZvE5cHZIDkUkeZ4Pk4hhV-zOYMiREluv4b8kdqQ3Ig,1375
|
10
|
-
gml/pipelines.py,sha256=
|
11
|
-
gml/preprocessing.py,sha256=
|
10
|
+
gml/pipelines.py,sha256=LKj_lh5I5HzyUUIPG4CImiqBnQPrJsj0CHPKhLiOOGo,8374
|
11
|
+
gml/preprocessing.py,sha256=YPcxwBOdx0h0ADzoloYbFw9qUGFbi167E8HA4Zwn7Pk,3928
|
12
12
|
gml/proto/gogoproto/gogo_pb2.py,sha256=WVMIAR8K--mCUkTPM7mEeeXGpQlRRtt_kco10iP3CZs,15728
|
13
13
|
gml/proto/mediapipe/framework/calculator_contract_test_pb2.py,sha256=hNjyZCBz3RYa6rN4xR3FOCZKA24gq_LsJ3EMegl5wK4,2031
|
14
14
|
gml/proto/mediapipe/framework/calculator_options_pb2.py,sha256=Nq1BQRtLdsIgfkw7ymD3eg2p2_RSlZhiHS7YbDhNHR0,1563
|
@@ -23,29 +23,31 @@ gml/proto/mediapipe/framework/stream_handler_pb2.py,sha256=kNo-2Fdua_CeyJInI3q5r
|
|
23
23
|
gml/proto/mediapipe/framework/test_calculators_pb2.py,sha256=tXF25VpGtHGArffRqFmjD6FO7xmuCPd5j9UYON2SVSM,2230
|
24
24
|
gml/proto/mediapipe/framework/thread_pool_executor_pb2.py,sha256=9TJ66fqSo1BiJmEAQesK0fnVe55zcJpOqVip6HotgyE,2345
|
25
25
|
gml/proto/opentelemetry/proto/common/v1/common_pb2.py,sha256=wQjeDti-C8JiNwRn-z5M5p-Fqxm-SmnbPaoitJcSK-4,2860
|
26
|
-
gml/proto/opentelemetry/proto/metrics/v1/metrics_pb2.py,sha256=
|
26
|
+
gml/proto/opentelemetry/proto/metrics/v1/metrics_pb2.py,sha256=k8oW5tmFlJK2574Ky6kDc0JmNNQCLroRwCCGyxDd7JA,9968
|
27
27
|
gml/proto/opentelemetry/proto/resource/v1/resource_pb2.py,sha256=cbNmE12Nm3PjW4NXU7-Z-9m_0Zs3Ab8R1xLkDnvclCg,1730
|
28
|
-
gml/proto/src/api/corepb/v1/
|
29
|
-
gml/proto/src/api/corepb/v1/
|
30
|
-
gml/proto/src/api/corepb/v1/
|
31
|
-
gml/proto/src/api/corepb/v1/
|
32
|
-
gml/proto/src/api/corepb/v1/
|
33
|
-
gml/proto/src/api/corepb/v1/
|
28
|
+
gml/proto/src/api/corepb/v1/compiled_pipeline_pb2.py,sha256=g3MxBqshtwaM9_Nrbvwo995_XWq-maXGP6mDeiEzZKo,7529
|
29
|
+
gml/proto/src/api/corepb/v1/controlplane_pb2.py,sha256=DylHEVXr36Deh5p-WK8aRwQF-uGW5mJ2mo8pJ3qg7KA,13213
|
30
|
+
gml/proto/src/api/corepb/v1/cp_edge_pb2.py,sha256=H0WgAgv6-qaf7wnnKALmSBpD_czmUNHNYpsnE3Tmcrs,14988
|
31
|
+
gml/proto/src/api/corepb/v1/deployed_pipeline_pb2.py,sha256=cZjoJuZ3fpCiw2Ox7bcHCXYqRTebb08n-aodwjE-xKI,3053
|
32
|
+
gml/proto/src/api/corepb/v1/device_info_pb2.py,sha256=pTZGPjfglje-Wu_-R4qiwPtewXNJIGq5Kedme9SHiaU,6713
|
33
|
+
gml/proto/src/api/corepb/v1/gem_config_pb2.py,sha256=vC0g3k9hDv-LhiV6LwaYCly6x00Xx_YA0i2AZSwCo_I,5396
|
34
|
+
gml/proto/src/api/corepb/v1/mediastream_pb2.py,sha256=mgi5-prV7Lz0XJ2wo04jGLSvbnDGtdmduSv_6d6I9oA,8368
|
35
|
+
gml/proto/src/api/corepb/v1/model_exec_pb2.py,sha256=_TXJvHSxkX1Il6xEVEiFIfei_ZV4KhdL3cSKaMgIYIw,33548
|
34
36
|
gml/proto/src/common/typespb/jwt_pb2.py,sha256=lxy-bqbyg96i9n_xr2JbkuWX-ldnoJavXPMnApzVSio,5580
|
35
37
|
gml/proto/src/common/typespb/status_pb2.py,sha256=IbBJnbsAlvsuTtyT285ZuW6k5VaPfl5kRSOnBxD_H8M,2109
|
36
38
|
gml/proto/src/common/typespb/uuid_pb2.py,sha256=5Fm3jYpCPX7sMrP6RhRYsF0SnuZNIBEQJk9f0jwZ2Rw,1188
|
37
|
-
gml/proto/src/controlplane/compiler/cpb/v1/cpb_pb2.py,sha256
|
39
|
+
gml/proto/src/controlplane/compiler/cpb/v1/cpb_pb2.py,sha256=4mp1QWV7FOzF_nC3RDKZ9vTA-ezMhukcjBEt1lcjGmM,4933
|
38
40
|
gml/proto/src/controlplane/compiler/cpb/v1/cpb_pb2_grpc.py,sha256=l-gTK9nYpTlVb7QGAckSQXlHhkRdKe2-nrxXc8NQavY,2912
|
39
41
|
gml/proto/src/controlplane/directory/directorypb/v1/directory_pb2.py,sha256=KgoUT8ccF-yJPe1r4otQjAPQoKBaQzdBlHoIUSkk0yE,11445
|
40
42
|
gml/proto/src/controlplane/directory/directorypb/v1/directory_pb2_grpc.py,sha256=p3OpT8-hfNHu4-29qr-ZahRwO-LoCYM9Q4jomAHTXGA,24572
|
41
43
|
gml/proto/src/controlplane/filetransfer/ftpb/v1/ftpb_pb2.py,sha256=r8mbJNTq45_c0amPnTr8OFZasCk7XWu2YS_eu7GfWJg,7050
|
42
44
|
gml/proto/src/controlplane/filetransfer/ftpb/v1/ftpb_pb2_grpc.py,sha256=XlE4R2PJaOmzQocx7y6SKJvuqt8tYBGzBuhajvzG0cc,12919
|
43
|
-
gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2.py,sha256=
|
45
|
+
gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2.py,sha256=2s2p6dURKJLboaR965m2-rGTo_63Bi1cXsA90Hz9u-M,6632
|
44
46
|
gml/proto/src/controlplane/logicalpipeline/lppb/v1/lppb_pb2_grpc.py,sha256=-snjW7n6JveUzJVPFcm25XlL19kowPSKgd61l_jPnHA,9541
|
45
47
|
gml/proto/src/controlplane/model/mpb/v1/mpb_pb2.py,sha256=RVedXkNYu2iF5OHiXoYyRw9AGRCUWG7qNyY-5QY71Go,3762
|
46
48
|
gml/proto/src/controlplane/model/mpb/v1/mpb_pb2_grpc.py,sha256=KSdb6V04qUHDsb1R2o3wixwTyZgrhwnPYobjnRgWX4I,4735
|
47
49
|
gml/register_submodules.py,sha256=U8IwjVygX2vxNi_aK6ljHOD4mmrOhbyVczvy4wwulqU,5027
|
48
|
-
gml/tensor.py,sha256=
|
49
|
-
gimlet_api-0.0.
|
50
|
-
gimlet_api-0.0.
|
51
|
-
gimlet_api-0.0.
|
50
|
+
gml/tensor.py,sha256=aPLm3I3qkYNDcJmntaUycqqN5rsZmcj8ql0EkupJudY,14977
|
51
|
+
gimlet_api-0.0.10.dist-info/WHEEL,sha256=sobxWSyDDkdg_rinUth-jxhXHqoNqlmNMJY3aTZn2Us,91
|
52
|
+
gimlet_api-0.0.10.dist-info/METADATA,sha256=i3n2dnjznNFL6XFsj1bL0T544E0FmMVQySLgiBkUW04,586
|
53
|
+
gimlet_api-0.0.10.dist-info/RECORD,,
|
gml/client.py
CHANGED
@@ -18,8 +18,12 @@ import os
|
|
18
18
|
import uuid
|
19
19
|
from pathlib import Path
|
20
20
|
from typing import BinaryIO, List, Optional, TextIO, Union
|
21
|
+
from urllib.parse import quote
|
21
22
|
|
22
23
|
import grpc
|
24
|
+
from rich.progress import (
|
25
|
+
Console,
|
26
|
+
)
|
23
27
|
|
24
28
|
import gml.proto.src.api.corepb.v1.model_exec_pb2 as modelexecpb
|
25
29
|
import gml.proto.src.common.typespb.uuid_pb2 as uuidpb
|
@@ -39,6 +43,7 @@ from gml.model import Model
|
|
39
43
|
from gml.pipelines import Pipeline
|
40
44
|
|
41
45
|
DEFAULT_CONTROLPLANE_ADDR = "app.gimletlabs.ai"
|
46
|
+
console = Console()
|
42
47
|
|
43
48
|
|
44
49
|
class _ChannelFactory:
|
@@ -282,31 +287,28 @@ class Client:
|
|
282
287
|
def create_model(self, model: Model) -> modelexecpb.Model:
|
283
288
|
existing_model = self._get_model_if_exists(model.name)
|
284
289
|
if existing_model is not None:
|
285
|
-
print(
|
286
|
-
'warning: model "{}" already exists and will not be uploaded.'
|
287
|
-
model.name
|
288
|
-
)
|
290
|
+
console.print(
|
291
|
+
f'[yellow]warning:[/yellow] model "{model.name}" already exists and will not be uploaded.'
|
289
292
|
)
|
290
293
|
return existing_model
|
291
|
-
|
292
294
|
model_info = model.to_proto()
|
293
|
-
with
|
294
|
-
|
295
|
-
|
296
|
-
file
|
297
|
-
|
298
|
-
sha256 = sha256sum(file)
|
295
|
+
with console.status(f'Creating model "{model.name}"...'):
|
296
|
+
with model.collect_assets() as model_assets:
|
297
|
+
for asset_name, file in model_assets.items():
|
298
|
+
if isinstance(file, Path) or isinstance(file, str):
|
299
|
+
file = open(file, "rb")
|
299
300
|
|
300
|
-
|
301
|
-
if asset_name:
|
302
|
-
upload_name += ":" + asset_name
|
303
|
-
print(f"Uploading {upload_name}...")
|
301
|
+
sha256 = sha256sum(file)
|
304
302
|
|
305
|
-
|
303
|
+
upload_name = model.name
|
304
|
+
if asset_name:
|
305
|
+
upload_name += ":" + asset_name
|
306
|
+
file_info = self._upload_file_if_not_exists(sha256, file, sha256)
|
307
|
+
console.print(f"Uploaded {upload_name}.")
|
306
308
|
|
307
|
-
|
309
|
+
model_info.file_assets[asset_name].MergeFrom(file_info.file_id)
|
308
310
|
|
309
|
-
|
311
|
+
file.close()
|
310
312
|
|
311
313
|
return self._create_model(model_info)
|
312
314
|
|
@@ -331,6 +333,8 @@ class Client:
|
|
331
333
|
else:
|
332
334
|
raise ValueError("must specify one of 'pipeline_file' or 'pipeline'")
|
333
335
|
|
336
|
+
console.print(f'Uploading pipeline "{name}" to {self._org_name}...')
|
337
|
+
|
334
338
|
for model in models:
|
335
339
|
self.create_model(model)
|
336
340
|
|
@@ -343,6 +347,11 @@ class Client:
|
|
343
347
|
resp: lppb.CreateLogicalPipelineResponse = stub.CreateLogicalPipeline(
|
344
348
|
req, metadata=self._get_request_metadata(idempotent=True)
|
345
349
|
)
|
350
|
+
|
351
|
+
url = f"https://{os.getenv('GML_CONTROLPLANE_ADDR')}/orgs/{quote(self._org_name)}/pipelines/{quote(name)}"
|
352
|
+
console.print(
|
353
|
+
f"[green]Pipeline upload complete![/green]\nView your pipeline at: [cyan]{url}[/cyan]"
|
354
|
+
)
|
346
355
|
return resp.id
|
347
356
|
|
348
357
|
def check_compile(
|
@@ -351,8 +360,8 @@ class Client:
|
|
351
360
|
models: List[Model],
|
352
361
|
pipeline_file: Optional[Path] = None,
|
353
362
|
pipeline: Optional[Union[str, Pipeline]] = None,
|
354
|
-
runtimes
|
355
|
-
cameras
|
363
|
+
runtimes: List[str],
|
364
|
+
cameras: List[str],
|
356
365
|
):
|
357
366
|
model_with_assets = []
|
358
367
|
for model in models:
|
gml/compile.py
CHANGED
@@ -16,10 +16,11 @@
|
|
16
16
|
|
17
17
|
import contextlib
|
18
18
|
import functools
|
19
|
-
from typing import Any, Dict, List, Optional, Sequence, Union
|
19
|
+
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
|
20
20
|
|
21
21
|
import safetensors_mlir
|
22
22
|
import torch
|
23
|
+
import torch.utils._pytree
|
23
24
|
import torch_mlir
|
24
25
|
from mlir.ir import (
|
25
26
|
BF16Type,
|
@@ -28,6 +29,7 @@ from mlir.ir import (
|
|
28
29
|
F16Type,
|
29
30
|
F32Type,
|
30
31
|
F64Type,
|
32
|
+
Float8E4M3FNType,
|
31
33
|
IntegerType,
|
32
34
|
Operation,
|
33
35
|
RankedTensorType,
|
@@ -40,6 +42,7 @@ from torch_mlir.dialects import torch as torch_d
|
|
40
42
|
from torch_mlir.extras.fx_decomp_util import get_decomposition_table
|
41
43
|
from torch_mlir.extras.fx_importer import FxImporter, FxImporterHooks, InputInfo
|
42
44
|
from torch_mlir.fx import export_and_import
|
45
|
+
from transformers import DynamicCache
|
43
46
|
|
44
47
|
from gml.asset_manager import AssetManager
|
45
48
|
from gml.register_submodules import submodule_registration_workarounds
|
@@ -53,6 +56,45 @@ def _default_decomposition_denylist():
|
|
53
56
|
]
|
54
57
|
|
55
58
|
|
59
|
+
_registered_dynamic_cache_pytree_node = False
|
60
|
+
|
61
|
+
|
62
|
+
def register_dynamic_cache_pytree_node():
|
63
|
+
"""
|
64
|
+
Registers flattening/unflattening for transformers.DynamicCache
|
65
|
+
Pytree is a representation of tensor collections used inside torch.export.
|
66
|
+
"""
|
67
|
+
|
68
|
+
global _registered_dynamic_cache_pytree_node
|
69
|
+
if _registered_dynamic_cache_pytree_node:
|
70
|
+
return
|
71
|
+
_registered_dynamic_cache_pytree_node = True
|
72
|
+
|
73
|
+
def flatten_cache_with_keys(dynamic_cache: DynamicCache):
|
74
|
+
return [
|
75
|
+
(
|
76
|
+
torch.utils._pytree.MappingKey(i),
|
77
|
+
list(value),
|
78
|
+
)
|
79
|
+
for i, value in enumerate(dynamic_cache.to_legacy_cache())
|
80
|
+
], None
|
81
|
+
|
82
|
+
def flatten_cache(dynamic_cache: DynamicCache):
|
83
|
+
flattened, ctx = flatten_cache_with_keys(dynamic_cache)
|
84
|
+
return [v for _, v in flattened], ctx
|
85
|
+
|
86
|
+
def unflatten_cache(flattened: Iterable[Any], context: Any):
|
87
|
+
return DynamicCache.from_legacy_cache(flattened)
|
88
|
+
|
89
|
+
torch.utils._pytree.register_pytree_node(
|
90
|
+
DynamicCache,
|
91
|
+
flatten_cache,
|
92
|
+
unflatten_cache,
|
93
|
+
serialized_type_name=f"{DynamicCache.__module__}.{DynamicCache.__name__}",
|
94
|
+
flatten_with_keys_fn=flatten_cache_with_keys,
|
95
|
+
)
|
96
|
+
|
97
|
+
|
56
98
|
@contextlib.contextmanager
|
57
99
|
def _patch_aot_export_module():
|
58
100
|
"""This contextmanager prevents PyTorch dispatch from running when calling aot_export_module.
|
@@ -91,6 +133,8 @@ _torch_dtype_to_builtin_element_type = {
|
|
91
133
|
torch.complex32: lambda: ComplexType.get(F16Type.get()),
|
92
134
|
torch.complex64: lambda: ComplexType.get(F32Type.get()),
|
93
135
|
torch.complex128: lambda: ComplexType.get(F64Type.get()),
|
136
|
+
# Quantized types.
|
137
|
+
torch.float8_e4m3fn: lambda: Float8E4M3FNType.get(),
|
94
138
|
}
|
95
139
|
|
96
140
|
|
@@ -179,6 +223,7 @@ def to_torch_mlir(
|
|
179
223
|
] = None,
|
180
224
|
decomposition_denylist: Optional[List[torch._ops.OperatorBase]] = None,
|
181
225
|
weight_manager: Optional[AssetManager] = None,
|
226
|
+
export_predispatch: bool = False,
|
182
227
|
):
|
183
228
|
if dynamic_shapes is not None:
|
184
229
|
for shape in dynamic_shapes:
|
@@ -205,10 +250,11 @@ def to_torch_mlir(
|
|
205
250
|
# Ignore errors running the model. This can happen when the model has data dependent branches.
|
206
251
|
pass
|
207
252
|
|
253
|
+
register_dynamic_cache_pytree_node()
|
208
254
|
prog = _export(
|
209
255
|
model,
|
210
256
|
tuple(example_inputs),
|
211
|
-
pre_dispatch=
|
257
|
+
pre_dispatch=export_predispatch,
|
212
258
|
strict=False,
|
213
259
|
dynamic_shapes=dynamic_shapes,
|
214
260
|
)
|
gml/device.py
CHANGED
@@ -57,6 +57,8 @@ def _runtime_str_to_runtime_protos(
|
|
57
57
|
return deviceinfopb.ModelRuntimeType.MODEL_RUNTIME_TYPE_TENSORRT
|
58
58
|
case "openvino":
|
59
59
|
return deviceinfopb.ModelRuntimeType.MODEL_RUNTIME_TYPE_OPENVINO
|
60
|
+
case "hailort":
|
61
|
+
return deviceinfopb.ModelRuntimeType.MODEL_RUNTIME_TYPE_HAILORT
|
60
62
|
case _:
|
61
63
|
raise ValueError("invalid runtime: {}".format(runtime))
|
62
64
|
|