ai-edge-torch-nightly 0.6.0.dev20250603__py3-none-any.whl → 0.6.0.dev20250605__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.
@@ -79,7 +79,9 @@ class MinCutSolver:
79
79
 
80
80
  @property
81
81
  def graph(self):
82
- edges = np.array(self.edges)
82
+ # Ensure edges is a 2D array with shape (N, 3) and int32 dtype.
83
+ # If self.edges is empty, this will result in an array with shape (0, 3).
84
+ edges = np.array(self.edges, dtype=np.int32).reshape(-1, 3)
83
85
  return scipy.sparse.csr_matrix(
84
86
  (
85
87
  np.minimum(edges[:, 2], MinCutSolver.INF_COST),
@@ -42,12 +42,18 @@ _TRANSPOSE_KV_CACHE = flags.DEFINE_bool(
42
42
  True,
43
43
  "Transpose the KV cache to reduce memory usage.",
44
44
  )
45
+ _WEIGHT_FILENAME = flags.DEFINE_string(
46
+ "weight_filename",
47
+ "model.ckpt",
48
+ "Name of the weight file in the checkpoint directory.",
49
+ )
45
50
 
46
51
  def main(_):
47
52
  checkpoint = kagglehub.model_download("google/gemma-2/pyTorch/gemma-2-2b-it")
48
53
 
49
54
  verify_util.verify_gemma2(
50
55
  checkpoint,
56
+ _WEIGHT_FILENAME.value,
51
57
  _PROMPTS.value,
52
58
  _MAX_NEW_TOKENS.value,
53
59
  _MASK_AS_INPUT.value,
@@ -62,6 +62,8 @@ class GemmaWrapper(verifier.ModelWrapper):
62
62
  actual_input_len = self._get_actual_input_len(tokens)
63
63
  input_pos = torch.arange(0, actual_input_len, dtype=torch.long)
64
64
  mask_cache = attn_utils.build_causal_mask_cache(tokens.shape[1])
65
+ local_mask_cache = attn_utils.build_sliding_window_mask_cache(
66
+ tokens.shape[1], self.model.config.sliding_window_size)
65
67
  _, logits = self.model.forward(
66
68
  input_token_ids=tokens[0, :actual_input_len].unsqueeze(0),
67
69
  input_positions=input_pos,
@@ -72,6 +74,7 @@ class GemmaWrapper(verifier.ModelWrapper):
72
74
  temperatures=None,
73
75
  top_ps=torch.tensor([1.0], dtype=torch.float),
74
76
  top_ks=torch.tensor([1], dtype=torch.long),
77
+ local_mask=local_mask_cache.index_select(2, input_pos)
75
78
  )
76
79
  return logits
77
80
 
ai_edge_torch/version.py CHANGED
@@ -15,4 +15,4 @@
15
15
 
16
16
  # The next version of ai-edge-torch.
17
17
  # The minor version code should be bumped after every release.
18
- __version__ = "0.6.0.dev20250603"
18
+ __version__ = "0.6.0.dev20250605"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ai-edge-torch-nightly
3
- Version: 0.6.0.dev20250603
3
+ Version: 0.6.0.dev20250605
4
4
  Summary: Supporting PyTorch models with the Google AI Edge TFLite runtime.
5
5
  Home-page: https://github.com/google-ai-edge/ai-edge-torch
6
6
  Keywords: On-Device ML,AI,Google,TFLite,PyTorch,LLMs,GenAI
@@ -2,7 +2,7 @@ ai_edge_torch/__init__.py,sha256=lemyLCNoGYRnJsmDuGZu7qOqLbLqG6CGDFtu3ue1syU,129
2
2
  ai_edge_torch/_config.py,sha256=AiqhbcheF7j_ozIGDLC89k1we95aVgFDa-tR6h7UI0s,2529
3
3
  ai_edge_torch/conftest.py,sha256=r0GTrhMRhlmOGrrkvumHN8hkmyug6WvF60vWq8wRIBI,758
4
4
  ai_edge_torch/model.py,sha256=A7loFu8jE9CsXsfMmHYZ-KDFJiaD8Kkqwm_9d3IVzk0,5638
5
- ai_edge_torch/version.py,sha256=f6FvzLfBr0rauYb71ctwa8qlWkafgMxM73v4jYRgUzY,806
5
+ ai_edge_torch/version.py,sha256=tal_cofRwZa9E1zv9D8Tyl7wHRdq5cJ7rBbTi7ZF0t0,806
6
6
  ai_edge_torch/_convert/__init__.py,sha256=hHLluseD2R0Hh4W6XZRIXY_dRQeYudjsrKGf6LZz65g,671
7
7
  ai_edge_torch/_convert/conversion.py,sha256=iQk3R-pLq4c1nfLqPB4xTRj78gghxPGzJCJtILLdg5o,6123
8
8
  ai_edge_torch/_convert/conversion_utils.py,sha256=Sr8qXVcTwc-ZnZmK7yxVrIOOp1S_vNrwzC0zUvLTI2o,2160
@@ -25,7 +25,7 @@ ai_edge_torch/_convert/fx_passes/optimize_layout_transposes_pass/pass_body.py,sh
25
25
  ai_edge_torch/_convert/fx_passes/optimize_layout_transposes_pass/utils.py,sha256=YLMttMg5PdvXTtQ8lxpKb434UGVvYVALV1-xeuH4UGc,2131
26
26
  ai_edge_torch/_convert/fx_passes/optimize_layout_transposes_pass/layout_partitioners/__init__.py,sha256=D8VX8SbCzfoyvPgMFHK7yxD7R-bzLxp2gfdKxgrWekA,742
27
27
  ai_edge_torch/_convert/fx_passes/optimize_layout_transposes_pass/layout_partitioners/greedy.py,sha256=L_x8BrF7UDah-SYl-pG11I6CIckdU9kBTUHcmwW4cts,2420
28
- ai_edge_torch/_convert/fx_passes/optimize_layout_transposes_pass/layout_partitioners/min_cut.py,sha256=mzfL9cf0qBnpmxM_OlMQFvQsEZV2B_Mia9yEJV4J7rI,7135
28
+ ai_edge_torch/_convert/fx_passes/optimize_layout_transposes_pass/layout_partitioners/min_cut.py,sha256=oXbr9G5Jc21xd1dr2CDrp774I4crs0_kkN490K5fNn0,7312
29
29
  ai_edge_torch/_convert/test/__init__.py,sha256=hHLluseD2R0Hh4W6XZRIXY_dRQeYudjsrKGf6LZz65g,671
30
30
  ai_edge_torch/_convert/test/test_convert.py,sha256=yQC0WZk_gzReguTOfgWWodK71jnfMjYoRF29_Kafnuw,18692
31
31
  ai_edge_torch/_convert/test/test_convert_composites.py,sha256=BCIODgxMI_3MxMLfNWYMGjcz-al-J3z5eDHCiZJXNwY,7992
@@ -68,8 +68,8 @@ ai_edge_torch/generative/examples/gemma/convert_gemma2_to_tflite.py,sha256=fR486
68
68
  ai_edge_torch/generative/examples/gemma/gemma1.py,sha256=TH9XQAp5p4S829XbaWbJQZBwB18WizDRIQMsUkKqj38,3377
69
69
  ai_edge_torch/generative/examples/gemma/gemma2.py,sha256=E6jotWYYIx6SXUWqurKWjiZpbfj_M2jJrBc2rQ90z1s,11782
70
70
  ai_edge_torch/generative/examples/gemma/verify_gemma1.py,sha256=ip-Gmk4CI5f0GWSdAIdrectxQWJ0t328KCsA4nfHuGg,1736
71
- ai_edge_torch/generative/examples/gemma/verify_gemma2.py,sha256=jhiyinOqPt5ZZjEadDRZt_wY5fiLSCpMo54PcxFaL_Q,1789
72
- ai_edge_torch/generative/examples/gemma/verify_util.py,sha256=bbbdwuP4DKekvVuWHZ-jYYOQISto5ZkK1hC0r1Vhq00,7907
71
+ ai_edge_torch/generative/examples/gemma/verify_gemma2.py,sha256=eAM7EVVMW-QCqjeZEss7TOkVKArgUs1La51LAC-5a9A,1962
72
+ ai_edge_torch/generative/examples/gemma/verify_util.py,sha256=kSGifZobCvvRVoNAb8OumwuMKea-Mar_wIlJ5S2qF0Y,8101
73
73
  ai_edge_torch/generative/examples/gemma3/__init__.py,sha256=JaAnrFoXTl3RJX97XspklkTyqOHVyAgRJsZtzNDd10c,671
74
74
  ai_edge_torch/generative/examples/gemma3/convert_gemma3_to_tflite.py,sha256=UEDNN3JmI31WfE2pvacxeJpqumKK86L2dEus3yTURaY,2114
75
75
  ai_edge_torch/generative/examples/gemma3/decoder.py,sha256=1UVv9SFFg5degX3wf-Fefx7nor1AzJj2NWBVuo8bRnM,15540
@@ -268,8 +268,8 @@ ai_edge_torch/testing/__init__.py,sha256=_yGgvnBZWb7T3IN3mc4x1sS4vM96HZwM8pwIcPG
268
268
  ai_edge_torch/testing/export.py,sha256=k5mGDGzwc23Z4zaIVDs8CNh-oOt64gsf9MS9NjhbPy4,3293
269
269
  ai_edge_torch/testing/model_coverage/__init__.py,sha256=5P8J6Zk5YYtDvTBucFvB9NGSRI7Gw_24WnrbhXgycEE,765
270
270
  ai_edge_torch/testing/model_coverage/model_coverage.py,sha256=UPB448aMDUyC0HNYVqio2rcJPnDN0tBQMP08J6vPYew,4718
271
- ai_edge_torch_nightly-0.6.0.dev20250603.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
272
- ai_edge_torch_nightly-0.6.0.dev20250603.dist-info/METADATA,sha256=3c68vDxxobFxHDgitrg9QPmEUuuN4_jNi7dZap5mcio,2074
273
- ai_edge_torch_nightly-0.6.0.dev20250603.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
274
- ai_edge_torch_nightly-0.6.0.dev20250603.dist-info/top_level.txt,sha256=5KXRaF2hwkApYxf7Y8y_tVb9aulGTlbOoNdbx1aKRkE,14
275
- ai_edge_torch_nightly-0.6.0.dev20250603.dist-info/RECORD,,
271
+ ai_edge_torch_nightly-0.6.0.dev20250605.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
272
+ ai_edge_torch_nightly-0.6.0.dev20250605.dist-info/METADATA,sha256=Lj15e9lPEa-ZIThKHQtIih6i1ovPHWYE_cXi2qRphwM,2074
273
+ ai_edge_torch_nightly-0.6.0.dev20250605.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
274
+ ai_edge_torch_nightly-0.6.0.dev20250605.dist-info/top_level.txt,sha256=5KXRaF2hwkApYxf7Y8y_tVb9aulGTlbOoNdbx1aKRkE,14
275
+ ai_edge_torch_nightly-0.6.0.dev20250605.dist-info/RECORD,,