litert-torch-nightly 0.9.0.dev20260130__py3-none-any.whl → 0.9.0.dev20260201__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.
- litert_torch/generative/export_hf/core/export_lib.py +21 -3
- litert_torch/generative/export_hf/export.py +2 -0
- litert_torch/version.py +1 -1
- {litert_torch_nightly-0.9.0.dev20260130.dist-info → litert_torch_nightly-0.9.0.dev20260201.dist-info}/METADATA +1 -1
- {litert_torch_nightly-0.9.0.dev20260130.dist-info → litert_torch_nightly-0.9.0.dev20260201.dist-info}/RECORD +9 -9
- {litert_torch_nightly-0.9.0.dev20260130.dist-info → litert_torch_nightly-0.9.0.dev20260201.dist-info}/WHEEL +0 -0
- {litert_torch_nightly-0.9.0.dev20260130.dist-info → litert_torch_nightly-0.9.0.dev20260201.dist-info}/entry_points.txt +0 -0
- {litert_torch_nightly-0.9.0.dev20260130.dist-info → litert_torch_nightly-0.9.0.dev20260201.dist-info}/licenses/LICENSE +0 -0
- {litert_torch_nightly-0.9.0.dev20260130.dist-info → litert_torch_nightly-0.9.0.dev20260201.dist-info}/top_level.txt +0 -0
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# ==============================================================================
|
|
15
15
|
"""Export library for HF integration."""
|
|
16
16
|
|
|
17
|
+
import gc
|
|
17
18
|
import os
|
|
18
19
|
import time
|
|
19
20
|
|
|
@@ -258,8 +259,18 @@ def export_text_prefill_decode_model(
|
|
|
258
259
|
elapsed_time = end_time - start_time
|
|
259
260
|
print(f'Model conversion executed in {elapsed_time} seconds.')
|
|
260
261
|
|
|
262
|
+
del lrt_model
|
|
263
|
+
del converter
|
|
264
|
+
gc.collect()
|
|
265
|
+
|
|
261
266
|
# Quantization
|
|
262
|
-
|
|
267
|
+
quantization_recipe_list = (
|
|
268
|
+
quantization_recipe.split(',') if quantization_recipe else [None]
|
|
269
|
+
)
|
|
270
|
+
for recipe in quantization_recipe_list:
|
|
271
|
+
model_path = maybe_quantize_model(model_path, recipe)
|
|
272
|
+
gc.collect()
|
|
273
|
+
return model_path
|
|
263
274
|
|
|
264
275
|
|
|
265
276
|
def maybe_quantize_model(
|
|
@@ -271,7 +282,8 @@ def maybe_quantize_model(
|
|
|
271
282
|
return model_path
|
|
272
283
|
start_time = time.perf_counter()
|
|
273
284
|
quantized_model_path = (
|
|
274
|
-
model_path.removesuffix('.tflite')
|
|
285
|
+
model_path.removesuffix('.tflite').removesuffix('_quantized')
|
|
286
|
+
+ '_quantized.tflite'
|
|
275
287
|
)
|
|
276
288
|
qt = quantizer_lib.Quantizer(model_path)
|
|
277
289
|
try:
|
|
@@ -316,7 +328,13 @@ def export_embedder_model(
|
|
|
316
328
|
lrt_model = converter.convert(strict_export=False)
|
|
317
329
|
model_path = os.path.join(work_dir, 'model.tflite')
|
|
318
330
|
lrt_model.export(model_path)
|
|
319
|
-
|
|
331
|
+
quantization_recipe_list = (
|
|
332
|
+
quantization_recipe.split(',') if quantization_recipe else [None]
|
|
333
|
+
)
|
|
334
|
+
for recipe in quantization_recipe_list:
|
|
335
|
+
model_path = maybe_quantize_model(model_path, recipe)
|
|
336
|
+
gc.collect()
|
|
337
|
+
return model_path
|
|
320
338
|
|
|
321
339
|
|
|
322
340
|
def export_tokenizer(
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# ==============================================================================
|
|
15
15
|
"""Export functions for HuggingFace Transformers models."""
|
|
16
16
|
|
|
17
|
+
import gc
|
|
17
18
|
import os
|
|
18
19
|
|
|
19
20
|
from litert_torch.generative.export_hf.core import export_lib
|
|
@@ -60,6 +61,7 @@ def export(
|
|
|
60
61
|
export_lib.export_text_prefill_decode_model(
|
|
61
62
|
pt_model, text_model_config, export_config, work_dir, quantization_recipe
|
|
62
63
|
)
|
|
64
|
+
gc.collect()
|
|
63
65
|
tokenizer_model_path = export_lib.export_tokenizer(tokenizer, work_dir)
|
|
64
66
|
tflite_model_path = os.path.join(
|
|
65
67
|
work_dir,
|
litert_torch/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: litert-torch-nightly
|
|
3
|
-
Version: 0.9.0.
|
|
3
|
+
Version: 0.9.0.dev20260201
|
|
4
4
|
Summary: Support PyTorch model conversion with LiteRT.
|
|
5
5
|
Home-page: https://github.com/google-ai-edge/litert-torch
|
|
6
6
|
Keywords: On-Device ML,AI,Google,TFLite,LiteRT,PyTorch,LLMs,GenAI
|
|
@@ -3,7 +3,7 @@ litert_torch/_config.py,sha256=zDnki83sBsQzDAea6bvzwccylWHnPUzbEyGGRh6B14w,2526
|
|
|
3
3
|
litert_torch/cli.py,sha256=TiAUbgbWm3ecTUJtJ1_hjKJuC1LrG-Qwnm8_zws-sVY,984
|
|
4
4
|
litert_torch/conftest.py,sha256=gYmFrsR4c_fjIidbyrDnek26yS0crDP6-UoyMvy-WFg,757
|
|
5
5
|
litert_torch/model.py,sha256=KXFTyyfPM6AnP0JoSwsTqQR3lUQbMkTGSr3dUsfQ5Jk,5635
|
|
6
|
-
litert_torch/version.py,sha256=
|
|
6
|
+
litert_torch/version.py,sha256=jPqHwTtx_Gfw0GK4kZOc4sdTa7c31XbCKu370N9eYBE,804
|
|
7
7
|
litert_torch/_convert/__init__.py,sha256=qdLdbj5NjhNG-QgY5O_8TzOr2XaDoWvmdY9JNPStQmw,670
|
|
8
8
|
litert_torch/_convert/conversion.py,sha256=NuQEphyYp3W19IKvyTWo9pe7zt1-XmWM4zU9PDkUm54,6108
|
|
9
9
|
litert_torch/_convert/conversion_utils.py,sha256=MWpB-3eN-rvQzTtXsPL30cDIK431SQuwvw3ia2K2ONM,2158
|
|
@@ -179,7 +179,7 @@ litert_torch/generative/examples/tiny_llama/verify.py,sha256=6geA8OUOSj8_sTRyoo0
|
|
|
179
179
|
litert_torch/generative/examples/tiny_llama/verify_util.py,sha256=FKMC6Olex6bJbB8HXvC1KwxPbKgRBfT1CjoWcmyaPD8,2989
|
|
180
180
|
litert_torch/generative/export_hf/__init__.py,sha256=5xWIp2ziIwapcZcjSKfeaFgBnIooa8ckhTQ7mazZC3c,670
|
|
181
181
|
litert_torch/generative/export_hf/__main__.py,sha256=8VuBDkZ2sL-q2XdQ45qwzeHQk39-MM_6TdkxOU_23xE,782
|
|
182
|
-
litert_torch/generative/export_hf/export.py,sha256=
|
|
182
|
+
litert_torch/generative/export_hf/export.py,sha256=BIgdZxD3BhJ5ImZkwGAi7mSqyspbafx_AcYwMMooD_U,2711
|
|
183
183
|
litert_torch/generative/export_hf/export_main.py,sha256=bQidNXz0MEP_gil86LSfnpCW0pUiqZq2-F9ZOrSb3Yk,1183
|
|
184
184
|
litert_torch/generative/export_hf/core/__init__.py,sha256=5xWIp2ziIwapcZcjSKfeaFgBnIooa8ckhTQ7mazZC3c,670
|
|
185
185
|
litert_torch/generative/export_hf/core/attention.py,sha256=FFqq5TZ-V4Bdn2jb06_VWjAzVj1dlDuV1Llkftf_J54,2454
|
|
@@ -187,7 +187,7 @@ litert_torch/generative/export_hf/core/attention_test.py,sha256=RevOczfPncmbIBth
|
|
|
187
187
|
litert_torch/generative/export_hf/core/cache.py,sha256=pfWh2SACdhNY2of2Z8KJC0wrSQ2jrkXgPHWe7PSEiuU,10263
|
|
188
188
|
litert_torch/generative/export_hf/core/cache_base.py,sha256=FXMm9B8nDwC8uTyLmuBnYKLTnNtoeGN8gUnWwDCcH08,1714
|
|
189
189
|
litert_torch/generative/export_hf/core/cache_test.py,sha256=y-v-oOGtRNPGWRfIfW3FcpDxvJbzrBU6Pb2o66FkUzU,6203
|
|
190
|
-
litert_torch/generative/export_hf/core/export_lib.py,sha256=
|
|
190
|
+
litert_torch/generative/export_hf/core/export_lib.py,sha256=BLEmSuaOQpivSWJuw4ei8TGXH_vSu2o9nC43OXpw_lU,12458
|
|
191
191
|
litert_torch/generative/export_hf/core/exportable_module.py,sha256=XEqsV9M34OP-_vsxH7bnmxSCD6erAPl0a9I9JQM7v6k,8305
|
|
192
192
|
litert_torch/generative/export_hf/core/litert_lm_builder.py,sha256=f8Q2ifVyt65V-kRL0X9FRpQNKIer0R_Yx2lECZTMGPU,7965
|
|
193
193
|
litert_torch/generative/export_hf/core/patches.py,sha256=i1fzs0anIFbBH-Q_PwCtp9VKXy64olJKwnGpnJUjkEo,1815
|
|
@@ -318,9 +318,9 @@ litert_torch/testing/__init__.py,sha256=AfYP1HwTYSQmupveonEHCDV5dEyshzUgbwUrCUhb
|
|
|
318
318
|
litert_torch/testing/export.py,sha256=3dR6oxnrdtX0MfqAfMv233cf3sHA4e0F2TBQotoo8xc,3292
|
|
319
319
|
litert_torch/testing/model_coverage/__init__.py,sha256=uPXeAhWiD1O0aMDLCX7FTOSNQiea8yOtoIYPCuHEAG4,763
|
|
320
320
|
litert_torch/testing/model_coverage/model_coverage.py,sha256=EPCI7PbNPb7GV28lo3qQvFdzJwJ_ZDrbCGdpeiBZhVo,4715
|
|
321
|
-
litert_torch_nightly-0.9.0.
|
|
322
|
-
litert_torch_nightly-0.9.0.
|
|
323
|
-
litert_torch_nightly-0.9.0.
|
|
324
|
-
litert_torch_nightly-0.9.0.
|
|
325
|
-
litert_torch_nightly-0.9.0.
|
|
326
|
-
litert_torch_nightly-0.9.0.
|
|
321
|
+
litert_torch_nightly-0.9.0.dev20260201.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
322
|
+
litert_torch_nightly-0.9.0.dev20260201.dist-info/METADATA,sha256=zD3nf00lv-vEuoU-v0B-qL-kc6Pf39JBcJJoQeAND2k,2463
|
|
323
|
+
litert_torch_nightly-0.9.0.dev20260201.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
324
|
+
litert_torch_nightly-0.9.0.dev20260201.dist-info/entry_points.txt,sha256=roYAi9hp0uYrMudMR59hGNF2pz0TSAtqNl4vQLJzxnE,55
|
|
325
|
+
litert_torch_nightly-0.9.0.dev20260201.dist-info/top_level.txt,sha256=mGrsl2SYcjQSLBJX4ZXrHnFqHZe6QLRR7uk0tLfzwfM,13
|
|
326
|
+
litert_torch_nightly-0.9.0.dev20260201.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|