onnx-diagnostic 0.8.9__py3-none-any.whl → 0.8.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.
@@ -3,5 +3,5 @@ Patches, Investigates onnx models.
3
3
  Functions, classes to dig into a model when this one is right, slow, wrong...
4
4
  """
5
5
 
6
- __version__ = "0.8.9"
6
+ __version__ = "0.8.10"
7
7
  __author__ = "Xavier Dupré"
@@ -445,10 +445,6 @@ class WrapperToExportMethodToOnnx(torch.nn.Module):
445
445
  and not isinstance(v, (bool, int, float))
446
446
  }
447
447
  )
448
- if self.expand_batch_for:
449
- # extends the inputs to artificially create a batch dimension != 1.
450
- inp_args = self._expand_batch_dimension(inp_args, self.expand_batch_for)
451
- inp_kwargs = self._expand_batch_dimension(inp_kwargs, self.expand_batch_for)
452
448
  inp_args, inp_kwargs = torch_deepcopy((inp_args, inp_kwargs))
453
449
  # reorders the parameter following the method signature.
454
450
  inp_kwargs = self._reorder_kwargs(inp_kwargs)
@@ -557,6 +553,10 @@ class WrapperToExportMethodToOnnx(torch.nn.Module):
557
553
  else:
558
554
  a, kw = self._inputs[-1]
559
555
  nds = [self.dynamic_shapes]
556
+ if self.expand_batch_for:
557
+ # extends the inputs to artificially create a batch dimension != 1.
558
+ a = self._expand_batch_dimension(a, self.expand_batch_for)
559
+ kw = self._expand_batch_dimension(kw, self.expand_batch_for)
560
560
  if self.verbose:
561
561
  print(f"[method_to_onnx] export args={string_type(a, with_shape=True)}")
562
562
  print(f"[method_to_onnx] export kwargs={string_type(kw, with_shape=True)}")
@@ -738,7 +738,9 @@ class WrapperToExportMethodToOnnx(torch.nn.Module):
738
738
  :param verbose: verbosity
739
739
  :return: results, a list of dictionaries, ready to be consumed by a dataframe
740
740
  """
741
- assert self._export_done, "The onnx export was not done."
741
+ assert (
742
+ self._export_done
743
+ ), f"The onnx export was not done, only {len(self._inputs)} were stored."
742
744
  assert os.path.exists(self._input_file), f"input file {self._input_file!r} not found"
743
745
  assert os.path.exists(
744
746
  self._output_file
@@ -750,17 +752,29 @@ class WrapperToExportMethodToOnnx(torch.nn.Module):
750
752
  classes = [
751
753
  cls
752
754
  for cls in self._serialization_classes
753
- if cls not in {int, float, bool, str, torch.Tensor, list, set, dict, torch.device}
755
+ if cls
756
+ not in {
757
+ int,
758
+ float,
759
+ bool,
760
+ str,
761
+ torch.Tensor,
762
+ list,
763
+ set,
764
+ dict,
765
+ torch.device,
766
+ torch.dtype,
767
+ }
754
768
  ]
755
769
  if verbose:
756
770
  print(f"[method_to_onnx.check_discrepancies] register classes {classes}")
757
771
  print(f"[method_to_onnx.check_discrepancies] load {self._input_file!r}")
758
772
  with torch.serialization.safe_globals(classes):
759
- inputs = torch.load(self._input_file)
773
+ inputs = torch.load(self._input_file, weights_only=False)
760
774
  if verbose:
761
775
  print(f"[method_to_onnx.check_discrepancies] load {self._output_file!r}")
762
776
  with torch.serialization.safe_globals(classes):
763
- outputs = torch.load(self._output_file)
777
+ outputs = torch.load(self._output_file, weights_only=False)
764
778
  assert len(inputs) == len(outputs), (
765
779
  f"Unexpected number of inputs {len(inputs)} and outputs {len(outputs)}, "
766
780
  f"inputs={string_type(inputs, with_shape=True)}, "
@@ -305,7 +305,7 @@ def serialization_functions(
305
305
 
306
306
 
307
307
  def unregister_class_serialization(cls: type, verbose: int = 0):
308
- """Undo the registration."""
308
+ """Undo the registration for a class."""
309
309
  # torch.utils._pytree._deregister_pytree_flatten_spec(cls)
310
310
  if cls in torch.fx._pytree.SUPPORTED_NODES:
311
311
  del torch.fx._pytree.SUPPORTED_NODES[cls]
@@ -333,6 +333,10 @@ def unregister_class_serialization(cls: type, verbose: int = 0):
333
333
 
334
334
 
335
335
  def unregister_cache_serialization(undo: Dict[str, bool], verbose: int = 0):
336
+ """
337
+ Undo the registration made by
338
+ :func:`onnx_diagnostic.torch_export_patches.onnx_export_serialization.register_cache_serialization`.
339
+ """
336
340
  cls_ensemble = {DynamicCache, EncoderDecoderCache} | set(undo)
337
341
  for cls in cls_ensemble:
338
342
  if undo.get(cls.__name__, False):
@@ -524,13 +524,16 @@ class patched_ShapeEnv:
524
524
 
525
525
  transmute_into_runtime_assert = False
526
526
 
527
+ backed_var_to_val = getattr(
528
+ self, "backed_var_to_val", getattr(self, "var_to_val", {})
529
+ )
527
530
  concrete_val = None
528
- if not (expr.free_symbols <= self.var_to_val.keys()):
531
+ if not (expr.free_symbols <= backed_var_to_val.keys()):
529
532
  # TODO: dedupe this with _maybe_evaluate_static
530
533
  # Attempt to eliminate the unbacked SymInt
531
534
  new_expr = self._maybe_evaluate_static(expr, unbacked_only=True)
532
535
  assert new_expr is not None
533
- if not (new_expr.free_symbols <= self.var_to_val.keys()):
536
+ if not (new_expr.free_symbols <= backed_var_to_val.keys()):
534
537
  ok = False
535
538
 
536
539
  # fallback_value is set when guard_or_true or guard_or_false are used.
@@ -541,17 +544,15 @@ class patched_ShapeEnv:
541
544
  # oblivious_var_to_val will be defined iff we have sizes
542
545
  # with DimDynamic.OBLIVIOUS_SIZE type.
543
546
  # See https://github.com/pytorch/pytorch/issues/137100#issuecomment-2495778113
544
- var_to_val = getattr(
545
- self,
546
- "unbacked_var_to_val",
547
- getattr(self, "oblivious_var_to_val", False),
548
- )
549
547
  if (
550
- var_to_val
551
- and not (correct_hint := orig_expr.xreplace(var_to_val)).free_symbols
548
+ backed_var_to_val
549
+ and getattr(self, "real_tensor_prop_unbacked_vals", True)
550
+ and not (
551
+ correct_hint := orig_expr.xreplace(backed_var_to_val)
552
+ ).free_symbols
552
553
  and not (
553
554
  counterfactual_hint := orig_expr.xreplace(
554
- {k: max(2, v) for k, v in var_to_val.items()}
555
+ {k: max(2, v) for k, v in backed_var_to_val.items()}
555
556
  )
556
557
  ).free_symbols
557
558
  and correct_hint == counterfactual_hint
@@ -574,10 +575,10 @@ class patched_ShapeEnv:
574
575
  # and if they pass we add a runtime assertions and continue.
575
576
  if (
576
577
  not ok
577
- and var_to_val
578
+ and backed_var_to_val
578
579
  and not (
579
- unsound_result := orig_expr.xreplace(var_to_val).xreplace(
580
- var_to_val
580
+ unsound_result := orig_expr.xreplace(backed_var_to_val).xreplace(
581
+ backed_var_to_val
581
582
  )
582
583
  ).free_symbols
583
584
  ):
@@ -143,6 +143,7 @@ def _ccached_microsoft_phi2():
143
143
  "transformers_version": "4.51.0.dev0",
144
144
  "use_cache": true,
145
145
  "vocab_size": 51200,
146
+ "pad_token_id": 0,
146
147
  }
147
148
  )
148
149
 
@@ -53,6 +53,7 @@ def get_phi2(
53
53
  "transformers_version": "4.37.0",
54
54
  "use_cache": True,
55
55
  "vocab_size": 51200,
56
+ "pad_token_id": 0,
56
57
  }
57
58
  config.update(**kwargs)
58
59
  conf = transformers.PhiConfig(**config)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onnx-diagnostic
3
- Version: 0.8.9
3
+ Version: 0.8.10
4
4
  Summary: Tools to help converting pytorch models into ONNX.
5
5
  Home-page: https://github.com/sdpython/onnx-diagnostic
6
6
  Author: Xavier Dupré
@@ -1,4 +1,4 @@
1
- onnx_diagnostic/__init__.py,sha256=9vcutQbxSFR9MMn3ikZxIH3SQ1tgKjRC1yhyumWJ0Go,173
1
+ onnx_diagnostic/__init__.py,sha256=hheb1Xv21S-ukwOrWVc48HZ9f_jgwqg27V4HdlvfuZQ,174
2
2
  onnx_diagnostic/__main__.py,sha256=YmyV_Aq_ianDlHyKLHMa6h8YK3ZmFPpLVHLKjM91aCk,79
3
3
  onnx_diagnostic/_command_lines_parser.py,sha256=g_udwHBHmY6X_d41Qby_DqMpEHL1p9GfUhJGBCihl8c,57784
4
4
  onnx_diagnostic/api.py,sha256=BhCl_yCd78N7TlVtPOHjeYv1QBEy39TjZ647rcHqLh0,345
@@ -9,7 +9,7 @@ onnx_diagnostic/ci_models/ci_helpers.py,sha256=lblOF7z2kLcCRAwMOdqp-Tz1EL1oBywHf
9
9
  onnx_diagnostic/ci_models/export_phi4_mm.py,sha256=DH225jXhOG_S8KZE9Kn7FGNE4VqFyc9ZDnG-qxZn-hk,41668
10
10
  onnx_diagnostic/ci_models/export_qwen25_vl.py,sha256=_rYPr8PPraWizr2MPcGuYjrJ55ilJOyKl8kg0wq4L90,20405
11
11
  onnx_diagnostic/export/__init__.py,sha256=yEIoWiOeTwBsDhyYt2fTKuhtA0Ya1J9u9ZzMTOTWaWs,101
12
- onnx_diagnostic/export/api.py,sha256=iowYszK9ygdciW6P-C0isvW8ZAJW4yvI-3bjiWr2WAE,42945
12
+ onnx_diagnostic/export/api.py,sha256=7CL_IfVERPKTvKSkFfxlfXfVqUDuYAmDykCEW5CktMo,43202
13
13
  onnx_diagnostic/export/cf_simple_loop_for.py,sha256=OHPGQc9AC-0TBtCYpP6cm-iHP9gmNt8WYRrPlO9ewlc,21158
14
14
  onnx_diagnostic/export/control_flow_onnx.py,sha256=izGlctqQANrHzSxPMbT7hoauNbnIBdx6hb8ry7HtVmM,18263
15
15
  onnx_diagnostic/export/dynamic_shapes.py,sha256=_3xnWXa4n7fTkAT0NSLyLkcEJqm896wHKA8ilEyxvm0,44746
@@ -105,7 +105,7 @@ onnx_diagnostic/tasks/data/__init__.py,sha256=uJoemrWgEjI6oA-tMX7r3__x-b3siPmkgq
105
105
  onnx_diagnostic/tasks/data/dummies_imagetext2text_generation_gemma3.onnx,sha256=UbtvmWMqcZOKJ-I-HXWI1A6YR6QDaFS5u_yXm5C3ZBw,10299
106
106
  onnx_diagnostic/torch_export_patches/__init__.py,sha256=0SaZedwznm1hQUCvXZsGZORV5vby954wEExr5faepGg,720
107
107
  onnx_diagnostic/torch_export_patches/onnx_export_errors.py,sha256=XHYtU7w3vsaTMCuF5X1YtOKxgwL8eEuktXzVZpRz55o,43431
108
- onnx_diagnostic/torch_export_patches/onnx_export_serialization.py,sha256=zvvtKlqKiC0625vrKP3JNrUHCM3sFV_rPoKWH8Yq9OM,12523
108
+ onnx_diagnostic/torch_export_patches/onnx_export_serialization.py,sha256=KZgr8WbLvmZte1G1hKA0zIlio5ZHz9MKIwGPqNamB6E,12690
109
109
  onnx_diagnostic/torch_export_patches/patch_details.py,sha256=UHBo4QTLF3ZgQ4951yYHIQqxOeRYNaG7x56XFcRTtg4,11794
110
110
  onnx_diagnostic/torch_export_patches/patch_expressions.py,sha256=VOsv71FsR_UZtxz4-5_VKL2sHQhOkHy9RkPJME2h7UU,3271
111
111
  onnx_diagnostic/torch_export_patches/patch_inputs.py,sha256=-TgcyjVzxTb5Y-_ibssTeaA5PFz6FJrV6q84HMUAsJw,8075
@@ -129,7 +129,7 @@ onnx_diagnostic/torch_export_patches/patches/_patch_transformers_qwen3.py,sha256
129
129
  onnx_diagnostic/torch_export_patches/patches/_patch_transformers_rotary_embedding.py,sha256=LAqoL5SWISekZO15G1HIcCkN1JlBxGqb9XbK_eLzalA,16949
130
130
  onnx_diagnostic/torch_export_patches/patches/_patch_transformers_sam_mask_decoder.py,sha256=-6TuBm3sLAFEGuW3vRfOTtE5uP6aINFfu7xMnl27Dws,5703
131
131
  onnx_diagnostic/torch_export_patches/patches/patch_helper.py,sha256=kK_CGW643iVXxa-m6pttDBS7HTyMQaPypza7iqIInn4,721
132
- onnx_diagnostic/torch_export_patches/patches/patch_torch.py,sha256=hia-wQRv2LNvUlb-GqML5JGu4a1LEs-lAvooQZefmyM,45196
132
+ onnx_diagnostic/torch_export_patches/patches/patch_torch.py,sha256=IpvyM5yhA3tioyDAwAEe3gZDvbRUwCI_CzKmm76zwyU,45297
133
133
  onnx_diagnostic/torch_export_patches/patches/patch_transformers.py,sha256=1W3iKVYx2QT2xJTKlz1UmtjySuwv-rfT5yVL9DjOfzI,3376
134
134
  onnx_diagnostic/torch_export_patches/serialization/__init__.py,sha256=BHLdRPtNAtNPAS-bPKEj3-foGSPvwAbZXrHzGGPDLEw,1876
135
135
  onnx_diagnostic/torch_export_patches/serialization/diffusers_impl.py,sha256=drq3EH_yjcSuIWYsVeUWm8Cx6YCZFU6bP_1PLtPfY5I,945
@@ -141,19 +141,19 @@ onnx_diagnostic/torch_models/validate.py,sha256=JsEMv7aeg9tGGriKZ_CJeqGDfNUmZNdG
141
141
  onnx_diagnostic/torch_models/hghub/__init__.py,sha256=vi1Q7YHdddj1soiBN42MSvJdFqe2_KUoWafHISjwOu8,58
142
142
  onnx_diagnostic/torch_models/hghub/hub_api.py,sha256=V3azxUqb7mkmHQ8m5DCgg1WUU2NYBK12USEUy_sfYIA,14709
143
143
  onnx_diagnostic/torch_models/hghub/hub_data.py,sha256=6jR8A83cGP4Xw1Wg-q1zzKFpqzoVrybqm0Fm3yurkrE,9030
144
- onnx_diagnostic/torch_models/hghub/hub_data_cached_configs.py,sha256=Dxa13rsnTQ8eH_BcQvbY2bp1AYFtzuFrJ-J_urrSmeQ,292694
144
+ onnx_diagnostic/torch_models/hghub/hub_data_cached_configs.py,sha256=Q4rZz81erNAXzSoezR5kR1Qe_l_Rtn7k4egOx_L8LQU,292725
145
145
  onnx_diagnostic/torch_models/hghub/model_inputs.py,sha256=XahJ-m6ajdXg6vFGUOfV5IvFwn-yjAsIOU37nISbBoo,17646
146
146
  onnx_diagnostic/torch_models/hghub/model_specific.py,sha256=j50Nu7wddJMoqmD4QzMbNdFDUUgUmSBKRzPDH55TlUQ,2498
147
147
  onnx_diagnostic/torch_models/untrained/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
148
- onnx_diagnostic/torch_models/untrained/llm_phi2.py,sha256=y_akbdApi136qHcEQgykwIAYVw0Yfi0lbjb3DNuafaU,3948
148
+ onnx_diagnostic/torch_models/untrained/llm_phi2.py,sha256=HKj0krVNDI--mWHaTzagZ2RWAwe68P2n4JHKuW2ybFI,3975
149
149
  onnx_diagnostic/torch_models/untrained/llm_tiny_llm.py,sha256=QXw_Bs2SzfeiQMf-tmtVl83SmVOL4-Um7Qy-f0E48QI,2507
150
150
  onnx_diagnostic/torch_onnx/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
151
151
  onnx_diagnostic/torch_onnx/compare.py,sha256=O0lws4kzn8WAXr8-x-YMPr7oyBC9DtSIs4OfOr4S5-E,12305
152
152
  onnx_diagnostic/torch_onnx/runtime_info.py,sha256=u1bD6VXqzBCRmqmbzQtDswaPs1PH_ygr1r-CrcfXpNU,8562
153
153
  onnx_diagnostic/torch_onnx/sbs.py,sha256=8okBEIupMgw7TtKc80YFimMtwnY3GchdY05FsA9ooa0,40749
154
154
  onnx_diagnostic/torch_onnx/sbs_dataclasses.py,sha256=UctdBjzoPTQG1LS0tZ8A6E9hpoq5HWUYaJLPOPJc9FI,20299
155
- onnx_diagnostic-0.8.9.dist-info/licenses/LICENSE.txt,sha256=Vv6TXglX6Rc0d-f8aREhayhT-6PMQXEyOmI2NKlUCMc,1045
156
- onnx_diagnostic-0.8.9.dist-info/METADATA,sha256=cVfclVmpVRwo-9HRCRdVH-YIvWjMWaJloPzmCyN_WOg,6903
157
- onnx_diagnostic-0.8.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
158
- onnx_diagnostic-0.8.9.dist-info/top_level.txt,sha256=KwNkXewmcobM3ZT1DJLVWH6ebJzA5qKg7cWqKfpGNT4,16
159
- onnx_diagnostic-0.8.9.dist-info/RECORD,,
155
+ onnx_diagnostic-0.8.10.dist-info/licenses/LICENSE.txt,sha256=Vv6TXglX6Rc0d-f8aREhayhT-6PMQXEyOmI2NKlUCMc,1045
156
+ onnx_diagnostic-0.8.10.dist-info/METADATA,sha256=dvG6WDkXq8Y56whBI15kB40qx1XhXSQyyUvN7Q6JOYo,6904
157
+ onnx_diagnostic-0.8.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
158
+ onnx_diagnostic-0.8.10.dist-info/top_level.txt,sha256=KwNkXewmcobM3ZT1DJLVWH6ebJzA5qKg7cWqKfpGNT4,16
159
+ onnx_diagnostic-0.8.10.dist-info/RECORD,,