onnx-diagnostic 0.7.6__py3-none-any.whl → 0.7.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.
Files changed (35) hide show
  1. onnx_diagnostic/__init__.py +1 -1
  2. onnx_diagnostic/_command_lines_parser.py +56 -3
  3. onnx_diagnostic/export/dynamic_shapes.py +24 -10
  4. onnx_diagnostic/export/shape_helper.py +6 -2
  5. onnx_diagnostic/helpers/cache_helper.py +79 -6
  6. onnx_diagnostic/helpers/config_helper.py +10 -0
  7. onnx_diagnostic/helpers/helper.py +6 -1
  8. onnx_diagnostic/reference/ops/op_cast_like.py +15 -11
  9. onnx_diagnostic/reference/torch_ops/__init__.py +1 -0
  10. onnx_diagnostic/reference/torch_ops/unary_ops.py +7 -0
  11. onnx_diagnostic/tasks/automatic_speech_recognition.py +6 -2
  12. onnx_diagnostic/tasks/feature_extraction.py +7 -3
  13. onnx_diagnostic/tasks/fill_mask.py +6 -2
  14. onnx_diagnostic/tasks/image_classification.py +6 -2
  15. onnx_diagnostic/tasks/image_text_to_text.py +33 -10
  16. onnx_diagnostic/tasks/mask_generation.py +6 -2
  17. onnx_diagnostic/tasks/mixture_of_expert.py +2 -2
  18. onnx_diagnostic/tasks/object_detection.py +6 -2
  19. onnx_diagnostic/tasks/sentence_similarity.py +6 -2
  20. onnx_diagnostic/tasks/summarization.py +7 -2
  21. onnx_diagnostic/tasks/text2text_generation.py +7 -2
  22. onnx_diagnostic/tasks/text_classification.py +6 -2
  23. onnx_diagnostic/tasks/text_generation.py +8 -14
  24. onnx_diagnostic/torch_export_patches/onnx_export_errors.py +3 -3
  25. onnx_diagnostic/torch_export_patches/patch_inputs.py +1 -1
  26. onnx_diagnostic/torch_export_patches/patches/patch_torch.py +4 -4
  27. onnx_diagnostic/torch_export_patches/patches/patch_transformers.py +119 -0
  28. onnx_diagnostic/torch_export_patches/serialization/transformers_impl.py +3 -1
  29. onnx_diagnostic/torch_models/hghub/hub_data.py +5 -0
  30. onnx_diagnostic/torch_models/validate.py +1 -0
  31. {onnx_diagnostic-0.7.6.dist-info → onnx_diagnostic-0.7.7.dist-info}/METADATA +2 -2
  32. {onnx_diagnostic-0.7.6.dist-info → onnx_diagnostic-0.7.7.dist-info}/RECORD +35 -35
  33. {onnx_diagnostic-0.7.6.dist-info → onnx_diagnostic-0.7.7.dist-info}/WHEEL +0 -0
  34. {onnx_diagnostic-0.7.6.dist-info → onnx_diagnostic-0.7.7.dist-info}/licenses/LICENSE.txt +0 -0
  35. {onnx_diagnostic-0.7.6.dist-info → onnx_diagnostic-0.7.7.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@ from typing import Any, Callable, Dict, Optional, Tuple
2
2
  import torch
3
3
 
4
4
  # from ..helpers.cache_helper import make_dynamic_cache
5
- from ..helpers.config_helper import update_config # , check_hasattr, _pick
5
+ from ..helpers.config_helper import update_config, default_num_hidden_layers as nhl
6
6
 
7
7
  __TASK__ = "MoE"
8
8
 
@@ -11,7 +11,7 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
11
11
  """Reduces a model size."""
12
12
  kwargs: Dict[str, Any] = {}
13
13
  if hasattr(config, "num_hidden_layers"):
14
- config.num_hidden_layers = min(config.num_hidden_layers, 2)
14
+ config.num_hidden_layers = min(config.num_hidden_layers, nhl())
15
15
  if hasattr(config, "vision_config") and hasattr(config.vision_config, "num_hidden_layers"):
16
16
  config.vision_config.num_hidden_layers = min(config.vision_config.num_hidden_layers, 2)
17
17
  if hasattr(config, "audio_processor") and hasattr(
@@ -1,6 +1,10 @@
1
1
  from typing import Any, Callable, Dict, Optional, Tuple
2
2
  import torch
3
- from ..helpers.config_helper import update_config, check_hasattr
3
+ from ..helpers.config_helper import (
4
+ update_config,
5
+ check_hasattr,
6
+ default_num_hidden_layers as nhl,
7
+ )
4
8
 
5
9
  __TASK__ = "object-detection"
6
10
 
@@ -10,7 +14,7 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
10
14
  check_hasattr(config, ("num_hidden_layers", "hidden_sizes"))
11
15
  kwargs = dict(
12
16
  num_hidden_layers=(
13
- min(config.num_hidden_layers, 2)
17
+ min(config.num_hidden_layers, nhl())
14
18
  if hasattr(config, "num_hidden_layers")
15
19
  else len(config.hidden_sizes)
16
20
  )
@@ -1,6 +1,10 @@
1
1
  from typing import Any, Callable, Dict, Optional, Tuple
2
2
  import torch
3
- from ..helpers.config_helper import update_config, check_hasattr
3
+ from ..helpers.config_helper import (
4
+ update_config,
5
+ check_hasattr,
6
+ default_num_hidden_layers as nhl,
7
+ )
4
8
 
5
9
  __TASK__ = "sentence-similarity"
6
10
 
@@ -9,7 +13,7 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
9
13
  """Reduces a model size."""
10
14
  check_hasattr(config, "num_attention_heads", "num_hidden_layers")
11
15
  kwargs = dict(
12
- num_hidden_layers=min(config.num_hidden_layers, 2),
16
+ num_hidden_layers=min(config.num_hidden_layers, nhl()),
13
17
  num_attention_heads=min(config.num_attention_heads, 4),
14
18
  )
15
19
  update_config(config, kwargs)
@@ -1,7 +1,12 @@
1
1
  from typing import Any, Callable, Dict, Optional, Tuple
2
2
  import torch
3
3
  from ..helpers.cache_helper import make_dynamic_cache, make_encoder_decoder_cache
4
- from ..helpers.config_helper import update_config, check_hasattr, _pick
4
+ from ..helpers.config_helper import (
5
+ update_config,
6
+ check_hasattr,
7
+ _pick,
8
+ default_num_hidden_layers as nhl,
9
+ )
5
10
 
6
11
  __TASK__ = "summarization"
7
12
 
@@ -12,7 +17,7 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
12
17
  if hasattr(config, "num_decoder_layers"):
13
18
  config.num_decoder_layers = min(config.num_decoder_layers, 2)
14
19
  if hasattr(config, "num_hidden_layers"):
15
- config.num_hidden_layers = min(config.num_hidden_layers, 2)
20
+ config.num_hidden_layers = min(config.num_hidden_layers, nhl())
16
21
  update_config(config, kwargs)
17
22
  return kwargs
18
23
 
@@ -1,7 +1,12 @@
1
1
  from typing import Any, Callable, Dict, Optional, Tuple
2
2
  import torch
3
3
  from ..helpers.cache_helper import make_dynamic_cache, make_encoder_decoder_cache
4
- from ..helpers.config_helper import update_config, check_hasattr, _pick
4
+ from ..helpers.config_helper import (
5
+ update_config,
6
+ check_hasattr,
7
+ _pick,
8
+ default_num_hidden_layers as nhl,
9
+ )
5
10
 
6
11
  __TASK__ = "text2text-generation"
7
12
 
@@ -12,7 +17,7 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
12
17
  if hasattr(config, "num_decoder_layers"):
13
18
  config.num_decoder_layers = min(config.num_decoder_layers, 2)
14
19
  if hasattr(config, "num_hidden_layers"):
15
- config.num_hidden_layers = min(config.num_hidden_layers, 2)
20
+ config.num_hidden_layers = min(config.num_hidden_layers, nhl())
16
21
  update_config(config, kwargs)
17
22
  return kwargs
18
23
 
@@ -1,6 +1,10 @@
1
1
  from typing import Any, Callable, Dict, Optional, Tuple
2
2
  import torch
3
- from ..helpers.config_helper import update_config, check_hasattr
3
+ from ..helpers.config_helper import (
4
+ update_config,
5
+ check_hasattr,
6
+ default_num_hidden_layers as nhl,
7
+ )
4
8
 
5
9
  __TASK__ = "text-classification"
6
10
 
@@ -9,7 +13,7 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
9
13
  """Reduces a model size."""
10
14
  check_hasattr(config, "num_attention_heads", "num_hidden_layers")
11
15
  kwargs = dict(
12
- num_hidden_layers=min(config.num_hidden_layers, 2),
16
+ num_hidden_layers=min(config.num_hidden_layers, nhl()),
13
17
  num_attention_heads=min(config.num_attention_heads, 4),
14
18
  )
15
19
  update_config(config, kwargs)
@@ -6,7 +6,12 @@ from ..helpers.cache_helper import (
6
6
  make_sliding_window_cache,
7
7
  make_static_cache,
8
8
  )
9
- from ..helpers.config_helper import update_config, check_hasattr, _pick
9
+ from ..helpers.config_helper import (
10
+ update_config,
11
+ check_hasattr,
12
+ _pick,
13
+ default_num_hidden_layers as nhl,
14
+ )
10
15
 
11
16
  __TASK__ = "text-generation"
12
17
 
@@ -25,7 +30,7 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
25
30
  if config.__class__.__name__ == "FalconMambaConfig":
26
31
  check_hasattr(config, "conv_kernel", "state_size", "intermediate_size") # 4 and 8
27
32
  kwargs = dict(
28
- num_hidden_layers=min(config.num_hidden_layers, 2),
33
+ num_hidden_layers=min(config.num_hidden_layers, nhl()),
29
34
  intermediate_size=256 if config is None else min(512, config.intermediate_size),
30
35
  hidden_size=512 if config is None else min(512, config.hidden_size),
31
36
  cls_cache="MambaCache",
@@ -37,24 +42,13 @@ def reduce_model_config(config: Any) -> Dict[str, Any]:
37
42
  head_dim=getattr(
38
43
  config, "head_dim", config.hidden_size // config.num_attention_heads
39
44
  ),
40
- num_hidden_layers=min(config.num_hidden_layers, 2),
45
+ num_hidden_layers=min(config.num_hidden_layers, nhl()),
41
46
  num_key_value_heads=(
42
47
  config.num_key_value_heads
43
48
  if hasattr(config, "num_key_value_heads")
44
49
  else config.num_attention_heads
45
50
  ),
46
- hidden_size=(
47
- min(config.hidden_size, 4096 // 4)
48
- if config.hidden_size % 64 == 0
49
- else config.hidden_size
50
- ),
51
51
  )
52
- if config is None or hasattr(config, "intermediate_size"):
53
- kwargs["intermediate_size"] = (
54
- min(config.intermediate_size, 24576 // 4)
55
- if config.intermediate_size % 4 == 0
56
- else config.intermediate_size
57
- )
58
52
  update_config(config, kwargs)
59
53
  return kwargs
60
54
 
@@ -361,7 +361,7 @@ def torch_export_patches(
361
361
  torch._meta_registrations._broadcast_shapes = patched__broadcast_shapes
362
362
 
363
363
  # torch._export.non_strict_utils.produce_guards_and_solve_constraints
364
- if catch_constraints:
364
+ if patch_torch and catch_constraints:
365
365
  if verbose:
366
366
  print("[torch_export_patches] modifies shape constraints")
367
367
  f_produce_guards_and_solve_constraints = (
@@ -513,7 +513,7 @@ def torch_export_patches(
513
513
  if verbose:
514
514
  print("[torch_export_patches] restored pytorch functions")
515
515
 
516
- if stop_if_static:
516
+ if patch_torch and stop_if_static:
517
517
  if verbose:
518
518
  print("[torch_export_patches] restored ShapeEnv._set_replacement")
519
519
 
@@ -529,7 +529,7 @@ def torch_export_patches(
529
529
  print("[torch_export_patches] restored ShapeEnv._check_frozen")
530
530
  ShapeEnv._check_frozen = f_shape_env__check_frozen
531
531
 
532
- if catch_constraints:
532
+ if patch_torch and catch_constraints:
533
533
  # to catch or skip dynamic_shapes issues
534
534
  torch._export.non_strict_utils.produce_guards_and_solve_constraints = (
535
535
  f_produce_guards_and_solve_constraints
@@ -34,7 +34,7 @@ def _make_shape(subset: Dict, cls: type, value: Any) -> Any:
34
34
  f"Inconsistencies in subset={subset}, found={values}, "
35
35
  f"it cannot be a {cls}, value={string_type(value)}"
36
36
  )
37
- cache_length = len(value.key_cache)
37
+ cache_length = len(value.layers if hasattr(value, "layers") else value.key_cache)
38
38
  for v in subset.values():
39
39
  axes = v
40
40
  break
@@ -27,8 +27,8 @@ def _catch_produce_guards_and_solve_constraints(
27
27
  dynamic_shapes: Union[Dict[str, Any], Tuple[Any], List[Any], None],
28
28
  equalities_inputs: "EqualityConstraint", # noqa: F821
29
29
  original_signature: inspect.Signature,
30
- _is_torch_jit_trace: bool = False,
31
30
  verbose: int = 0,
31
+ **kwargs,
32
32
  ):
33
33
  try:
34
34
  return previous_function(
@@ -37,7 +37,7 @@ def _catch_produce_guards_and_solve_constraints(
37
37
  dynamic_shapes=dynamic_shapes,
38
38
  equalities_inputs=equalities_inputs,
39
39
  original_signature=original_signature,
40
- _is_torch_jit_trace=_is_torch_jit_trace,
40
+ **kwargs,
41
41
  )
42
42
  except Exception as e:
43
43
  if not int(os.environ.get("SKIP_SOLVE_CONSTRAINTS", "1")):
@@ -51,7 +51,7 @@ def _catch_produce_guards_and_solve_constraints(
51
51
  f"dynamic_shapes={dynamic_shapes}\n"
52
52
  f"equalities_inputs={equalities_inputs}\n"
53
53
  f"original_signature={original_signature}\n"
54
- f"_is_torch_jit_trace={_is_torch_jit_trace}\n"
54
+ f"kwargs={kwargs}\n"
55
55
  f"exc={e}\ngm={gm}"
56
56
  )
57
57
  torch._dynamo.reset()
@@ -174,7 +174,7 @@ class patched_ShapeEnv:
174
174
  self.counter["ignored_backward_guard"] += 1
175
175
  raise AssertionError(
176
176
  f"[patched_ShapeEnv] Ignored guard {expr} == {concrete_val}, "
177
- f"this could result in accuracy problems."
177
+ f"this could result in accuracy problems"
178
178
  )
179
179
 
180
180
  def _set_replacement(
@@ -1,4 +1,5 @@
1
1
  import inspect
2
+ import math
2
3
  from dataclasses import dataclass
3
4
  from functools import wraps
4
5
  from typing import Callable, List, Optional, Tuple
@@ -23,6 +24,14 @@ except ImportError:
23
24
  patch_masking_utils = False
24
25
 
25
26
 
27
+ try:
28
+ # transformers>= 4.55.1
29
+ from transformers.cache_utils import DynamicLayer
30
+
31
+ patch_DynamicLayer = hasattr(DynamicLayer, "lazy_initialization")
32
+ except ImportError:
33
+ patch_DynamicLayer = False
34
+
26
35
  from ...ext_test_case import has_transformers
27
36
  from ...helpers.torch_helper import is_torchdynamo_exporting
28
37
 
@@ -157,6 +166,20 @@ if patch_parse_processor_args:
157
166
  return processor_kwargs, remaining_kwargs
158
167
 
159
168
 
169
+ if patch_DynamicLayer:
170
+
171
+ class patched_DynamicLayer:
172
+ _PATCHES_ = ["lazy_initialization"]
173
+ _PATCHED_CLASS_ = DynamicLayer
174
+
175
+ def lazy_initialization(self, key_states: torch.Tensor):
176
+ self.dtype, self.device = key_states.dtype, key_states.device
177
+ new_shape = list(key_states.shape)
178
+ new_shape[-2] = 0
179
+ self.keys = torch.empty(new_shape, dtype=self.dtype, device=self.device)
180
+ self.values = torch.empty(new_shape, dtype=self.dtype, device=self.device)
181
+
182
+
160
183
  def _patch_make_causal_mask(
161
184
  input_ids_shape: torch.Size,
162
185
  dtype: torch.dtype,
@@ -323,6 +346,14 @@ if pv.Version(transformers.__version__) < pv.Version("4.51"):
323
346
  self.key_cache[layer_idx] = key_states
324
347
  self.value_cache[layer_idx] = value_states
325
348
  else:
349
+ torch._check(
350
+ len(self.key_cache[layer_idx].shape) == len(key_states.shape),
351
+ lambda: (
352
+ f"Rank mismatch len(self.key_cache[layer_idx].shape)="
353
+ f"{len(self.key_cache[layer_idx].shape)}, "
354
+ f"len(key_states.shape)={len(key_states.shape)}"
355
+ ),
356
+ )
326
357
  self.key_cache[layer_idx] = torch.cat(
327
358
  [self.key_cache[layer_idx], key_states], dim=-2
328
359
  )
@@ -1363,3 +1394,91 @@ class patched_SamMaskDecoder(torch.nn.Module):
1363
1394
  else:
1364
1395
  outputs = outputs + (None,) # noqa: RUF005
1365
1396
  return outputs
1397
+
1398
+
1399
+ def rewrite_loop_for_square_mask(mask: torch.Tensor, seq: torch.Tensor):
1400
+ """
1401
+ Rewrites the loop in:
1402
+
1403
+ .. code-block:: python
1404
+
1405
+ attention_mask = torch.full(
1406
+ [1, seq_length, seq_length], torch.finfo(q.dtype).min, dtype=q.dtype
1407
+ )
1408
+ for i in range(1, len(seq)):
1409
+ attention_mask[..., seq[i - 1] : seq[i], seq[i - 1] : seq[i]] = 0
1410
+ """
1411
+ r = torch.arange(0, mask.shape[-1], dtype=torch.int64)
1412
+ less0 = (r.reshape((-1, 1)) < seq.reshape((1, -1))).to(torch.int64)
1413
+ less = less0.sum(axis=-1, keepdim=True) + 1
1414
+ sq = less * less.T
1415
+ look = (
1416
+ torch.max(seq.min() == 0, less != less.max())
1417
+ * torch.max(seq.max() == mask.shape[-1], less != less.min())
1418
+ * less
1419
+ )
1420
+ filt = (sq != look**2).to(mask.dtype)
1421
+ return mask * filt
1422
+
1423
+
1424
+ class patched_VisionAttention(torch.nn.Module):
1425
+ _PATCHES_ = ["forward"]
1426
+ _PATCHED_CLASS_ = transformers.models.qwen2_vl.modeling_qwen2_vl.VisionAttention
1427
+
1428
+ def forward(
1429
+ self,
1430
+ hidden_states: torch.Tensor,
1431
+ cu_seqlens: torch.Tensor,
1432
+ rotary_pos_emb: Optional[torch.Tensor] = None,
1433
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
1434
+ ) -> torch.Tensor:
1435
+ seq_length = hidden_states.shape[0]
1436
+ q, k, v = (
1437
+ self.qkv(hidden_states)
1438
+ .reshape(seq_length, 3, self.num_heads, -1)
1439
+ .permute(1, 0, 2, 3)
1440
+ .unbind(0)
1441
+ )
1442
+ if position_embeddings is None:
1443
+ transformers.models.qwen2_vl.modeling_qwen2_vl.logger.warning_once(
1444
+ "The attention layers in this model are transitioning from "
1445
+ " computing the RoPE embeddings internally "
1446
+ "through `rotary_pos_emb` (2D tensor of RoPE theta values), "
1447
+ "to using externally computed "
1448
+ "`position_embeddings` (Tuple of tensors, containing cos and sin)."
1449
+ " In v4.54 `rotary_pos_emb` will be "
1450
+ "removed and `position_embeddings` will be mandatory."
1451
+ )
1452
+ emb = torch.cat((rotary_pos_emb, rotary_pos_emb), dim=-1)
1453
+ cos = emb.cos()
1454
+ sin = emb.sin()
1455
+ else:
1456
+ cos, sin = position_embeddings
1457
+ q, k = transformers.models.qwen2_vl.modeling_qwen2_vl.apply_rotary_pos_emb_vision(
1458
+ q, k, cos, sin
1459
+ )
1460
+
1461
+ attention_mask = torch.full(
1462
+ [1, seq_length, seq_length],
1463
+ torch.finfo(q.dtype).min,
1464
+ device=q.device,
1465
+ dtype=q.dtype,
1466
+ )
1467
+ # for i in range(1, len(cu_seqlens)):
1468
+ # attention_mask[..., cu_seqlens[i - 1] : cu_seqlens[i],
1469
+ # cu_seqlens[i - 1] : cu_seqlens[i]] = 0
1470
+ attention_mask = rewrite_loop_for_square_mask(attention_mask, cu_seqlens)
1471
+
1472
+ q = q.transpose(0, 1)
1473
+ k = k.transpose(0, 1)
1474
+ v = v.transpose(0, 1)
1475
+ attn_weights = torch.matmul(q, k.transpose(1, 2)) / math.sqrt(self.head_dim)
1476
+ attn_weights = attn_weights + attention_mask
1477
+ attn_weights = torch.nn.functional.softmax(
1478
+ attn_weights, dim=-1, dtype=torch.float32
1479
+ ).to(q.dtype)
1480
+ attn_output = torch.matmul(attn_weights, v)
1481
+ attn_output = attn_output.transpose(0, 1)
1482
+ attn_output = attn_output.reshape(seq_length, -1)
1483
+ attn_output = self.proj(attn_output)
1484
+ return attn_output
@@ -261,7 +261,9 @@ def unflatten_encoder_decoder_cache(
261
261
  ) -> EncoderDecoderCache:
262
262
  """Restores a :class:`transformers.cache_utils.EncoderDecoderCache` from python objects."""
263
263
  dictionary = torch.utils._pytree._dict_unflatten(values, context)
264
- return EncoderDecoderCache(**dictionary)
264
+ return EncoderDecoderCache(
265
+ dictionary["self_attention_cache"], dictionary["cross_attention_cache"]
266
+ )
265
267
 
266
268
 
267
269
  #############
@@ -37,6 +37,7 @@ __data_arch__ = textwrap.dedent(
37
37
  DebertaModel,feature-extraction
38
38
  DebertaV2Model,feature-extraction
39
39
  DecisionTransformerModel,reinforcement-learning
40
+ DeepseekV3ForCausalLM,text-generation
40
41
  DeiTModel,image-feature-extraction
41
42
  DetrModel,image-feature-extraction
42
43
  Dinov2Model,image-feature-extraction
@@ -52,9 +53,12 @@ __data_arch__ = textwrap.dedent(
52
53
  GPTJModel,feature-extraction
53
54
  GPTNeoModel,feature-extraction
54
55
  GPTNeoXForCausalLM,text-generation
56
+ GptOssForCausalLM,text-generation
55
57
  GemmaForCausalLM,text-generation
56
58
  Gemma2ForCausalLM,text-generation
57
59
  Gemma3ForConditionalGeneration,image-text-to-text
60
+ Gemma3ForCausalLM,text-generation
61
+ Glm4vMoeForConditionalGeneration,image-text-to-text
58
62
  GraniteForCausalLM,text-generation
59
63
  GroupViTModel,feature-extraction
60
64
  HieraForImageClassification,image-classification
@@ -107,6 +111,7 @@ __data_arch__ = textwrap.dedent(
107
111
  PvtForImageClassification,image-classification
108
112
  Qwen2ForCausalLM,text-generation
109
113
  Qwen2_5_VLForConditionalGeneration,image-text-to-text
114
+ Qwen3MoeForCausalLM,text-generation
110
115
  RTDetrForObjectDetection,object-detection
111
116
  RegNetModel,image-feature-extraction
112
117
  RemBertModel,feature-extraction
@@ -426,6 +426,7 @@ def validate_model(
426
426
  print(f"[validate_model] validate model id {model_id!r}, subfolder={subfolder!r}")
427
427
  else:
428
428
  print(f"[validate_model] validate model id {model_id!r}")
429
+ print(f"[validate_model] patch={patch!r}")
429
430
  if model_options:
430
431
  print(f"[validate_model] model_options={model_options!r}")
431
432
  print(f"[validate_model] get dummy inputs with input_options={input_options}...")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onnx-diagnostic
3
- Version: 0.7.6
3
+ Version: 0.7.7
4
4
  Summary: Investigate ONNX models
5
5
  Home-page: https://github.com/sdpython/onnx-diagnostic
6
6
  Author: Xavier Dupré
@@ -27,7 +27,7 @@ Requires-Dist: numpy
27
27
  Requires-Dist: onnx>=1.16.0
28
28
  Requires-Dist: onnxruntime>=1.21
29
29
  Requires-Dist: optree
30
- Requires-Dist: torch>=2.7
30
+ Requires-Dist: torch>=2.8
31
31
  Requires-Dist: torch_geometric
32
32
  Dynamic: author
33
33
  Dynamic: author-email
@@ -1,22 +1,22 @@
1
- onnx_diagnostic/__init__.py,sha256=p8ROK5tw0ZrpyWOL_GKb_10U5K4JDHEGIZP4h9WHz_w,173
1
+ onnx_diagnostic/__init__.py,sha256=JdBGK1KI9-G1MdBmNPIE7pLfaEHkMhgCq6h_YPJEYdw,173
2
2
  onnx_diagnostic/__main__.py,sha256=YmyV_Aq_ianDlHyKLHMa6h8YK3ZmFPpLVHLKjM91aCk,79
3
- onnx_diagnostic/_command_lines_parser.py,sha256=wU8L2C6f4BOrZMYM4WbHF6PDndeL7XKa__bx6BrKQs0,31227
3
+ onnx_diagnostic/_command_lines_parser.py,sha256=8JlT1vzyGztkJT2v6lpQx5itLKY4FYlpFng3z8n3TAU,32937
4
4
  onnx_diagnostic/api.py,sha256=BhCl_yCd78N7TlVtPOHjeYv1QBEy39TjZ647rcHqLh0,345
5
5
  onnx_diagnostic/doc.py,sha256=t3RELgfooYnVMAi0JSpggWkQEgUsREz8NmRvn0TnLI8,2829
6
6
  onnx_diagnostic/ext_test_case.py,sha256=emfQGiQSz5FVDhyJ1Acsv_Tast7tWl426TjtpNqxDBU,43558
7
7
  onnx_diagnostic/export/__init__.py,sha256=yEIoWiOeTwBsDhyYt2fTKuhtA0Ya1J9u9ZzMTOTWaWs,101
8
- onnx_diagnostic/export/dynamic_shapes.py,sha256=HYf2OEi7PmRSj8uxMD-wbdVxxejkWXTPBAkxoFeM27A,40811
9
- onnx_diagnostic/export/shape_helper.py,sha256=EQXHRVxwGpHRYhx8Y44Crqs640pmaIuKSwW1KJOW0IU,7501
8
+ onnx_diagnostic/export/dynamic_shapes.py,sha256=Go4_sIwiolCy_m1djQ3U_bX6C1EFw4al3x-ty-PsuME,41393
9
+ onnx_diagnostic/export/shape_helper.py,sha256=PI_SgE1MNRKSrQ414eYoBZ54QGZbYisHSvqi9tstL2s,7795
10
10
  onnx_diagnostic/export/validate.py,sha256=_PGUql2DJhIgGKo0WjTGUc5AgsZUx8fEs00MePy-w98,6043
11
11
  onnx_diagnostic/helpers/__init__.py,sha256=GJ2GT7cgnlIveVUwMZhuvUwidbTJaKv8CsSIOpZDsJg,83
12
12
  onnx_diagnostic/helpers/_log_helper.py,sha256=zZ7AqGpiF3O2-9N8fLuPeB5VfJpbg3tQ20ccDRdQPVE,16753
13
13
  onnx_diagnostic/helpers/args_helper.py,sha256=SRWnqC7EENg09RZlA50B_PcdiIhdbgA4C3ACfzl5nMs,4419
14
14
  onnx_diagnostic/helpers/bench_run.py,sha256=CGA6VMJZMH2gDhVueT9ypNm4PMcjGrrGFYp08nhWj9k,16539
15
- onnx_diagnostic/helpers/cache_helper.py,sha256=0DBawuOi9dYXmKmgAyT7dcZxbEINQWVaAcD4mkK_0N8,21912
16
- onnx_diagnostic/helpers/config_helper.py,sha256=9h1NWC9RLmu43Yf5Cz9usjMdLiyLWXMhwgE4Lg-eOU8,3889
15
+ onnx_diagnostic/helpers/cache_helper.py,sha256=sd9hnOW8uCU3yqvIB8tnxANRYEl1V_Ej8WDZMMI9VR8,24566
16
+ onnx_diagnostic/helpers/config_helper.py,sha256=ZrwdQwG3atXzto1VLUzCVOzyBIWkih_EGc3qKHuluZw,4139
17
17
  onnx_diagnostic/helpers/doc_helper.py,sha256=pl5MZd3_FaE8BqQnqoBuSBxoNCFcd2OJd3eITUSku5c,5897
18
18
  onnx_diagnostic/helpers/graph_helper.py,sha256=hevQT5a7_QuriVPQcbT5qe18n99Doyl5h3-qshx1-uk,14093
19
- onnx_diagnostic/helpers/helper.py,sha256=Vz06pWFvkkTUHgHJQv2VXrAja1a6jqCT9Cz-_EKx6Ec,62757
19
+ onnx_diagnostic/helpers/helper.py,sha256=OsQz2um10DgGiX3fgOulTDFQop0wCMX6shPonQgN71w,62940
20
20
  onnx_diagnostic/helpers/log_helper.py,sha256=rBYtZo85n61uQRIpxKpxkKTtKv-bDZvAc1J1uHRDosc,82567
21
21
  onnx_diagnostic/helpers/memory_peak.py,sha256=OT6mz0muBbBZY0pjgW2_eCk_lOtFRo-5w4jFo2Z6Kok,6380
22
22
  onnx_diagnostic/helpers/mini_onnx_builder.py,sha256=FgK-Kws1WpSYdYJCPyONwQYY3AjbgUHimZlaYyiNUfE,21286
@@ -36,7 +36,7 @@ onnx_diagnostic/reference/ops/op_add_add_mul_mul.py,sha256=CXQVtgVrT066gDJFwxL4n
36
36
  onnx_diagnostic/reference/ops/op_attention.py,sha256=ThALMDF53v3QeG1bohi0bvX2o90HZhGJbbAFOtwEHPE,2027
37
37
  onnx_diagnostic/reference/ops/op_average_pool_grad.py,sha256=zMcOtjB7hWySfIIFXogcmj3xxCWwxEX_g2VKg-SOAEs,2360
38
38
  onnx_diagnostic/reference/ops/op_bias_softmax.py,sha256=dcXsw2chxc8-puIkI0LFsBxKOJaCSovDcF1HkgboQp0,524
39
- onnx_diagnostic/reference/ops/op_cast_like.py,sha256=tH2pYFPluHK9r_cdkqnk9k2q3dPzaeKgQZt_Pjw9N4o,1383
39
+ onnx_diagnostic/reference/ops/op_cast_like.py,sha256=Sn0QA47bQ8laXJUl7VaxtsWCzCTpwkAQdv7F4A-AB5c,1557
40
40
  onnx_diagnostic/reference/ops/op_complex.py,sha256=OobDrRNYcktdCdTJzOQBesrKC8vsKxuHIi7Yev1DJrs,651
41
41
  onnx_diagnostic/reference/ops/op_concat.py,sha256=seW71-QDKzv9QQhjhjThKip0Y3d9nkVd7Hs1A2nNQjk,519
42
42
  onnx_diagnostic/reference/ops/op_constant_of_shape.py,sha256=3G9TRxaUoqYudnKrVHBEblo_16qMl0c9wNZqnQeNJJ4,2009
@@ -60,7 +60,7 @@ onnx_diagnostic/reference/ops/op_skip_layer_normalization.py,sha256=oJ7fQNx2iQh9
60
60
  onnx_diagnostic/reference/ops/op_slice.py,sha256=yRxfYBs8b7QezyyG9JHCD8MIJHij2qR2NNDpBmD3FJI,705
61
61
  onnx_diagnostic/reference/ops/op_transpose_cast.py,sha256=ifef74rvh0Yvq1Zx51B4mfnISbxV9uRg9DFjkdL1_68,361
62
62
  onnx_diagnostic/reference/ops/op_tri_matrix.py,sha256=Yn2gxAyygcwtF5Hjau9ihXDAzul0BAkdqVimVahtFBU,519
63
- onnx_diagnostic/reference/torch_ops/__init__.py,sha256=eZ7FBYH9Ta3BC0f7BJQAnIqiebqRkCt2_T3ktpVV6iQ,1150
63
+ onnx_diagnostic/reference/torch_ops/__init__.py,sha256=fIDMG0KhNYuB4q_57Z5zz0ME6_w8Q0tnqUCooijoOW4,1163
64
64
  onnx_diagnostic/reference/torch_ops/_op_run.py,sha256=EEUIwfbRldEFDhULquYhk9x5ZDa9t6f2mKJ1sM__D6A,10517
65
65
  onnx_diagnostic/reference/torch_ops/access_ops.py,sha256=Zfs5OF03PV1CqlCqKI5VV-c4MY3KyQxmO7QZksxQjX8,3274
66
66
  onnx_diagnostic/reference/torch_ops/binary_ops.py,sha256=-KxMcCYGDTcZyOss9qU1nU0rmdyg9SdVHJQohseSTcQ,2653
@@ -71,44 +71,44 @@ onnx_diagnostic/reference/torch_ops/other_ops.py,sha256=FnCY60mhdrzrsiHgvN-XpFRH
71
71
  onnx_diagnostic/reference/torch_ops/reduce_ops.py,sha256=9gFfraPTQbe_ZEUNCUis1JSmA5dj4tSzjAOpZPJKG4Y,5102
72
72
  onnx_diagnostic/reference/torch_ops/sequence_ops.py,sha256=3EiVKpGfN4d1Iry4hgnr3MIJyEEKUrAIDgmRGsUXXa0,2297
73
73
  onnx_diagnostic/reference/torch_ops/shape_ops.py,sha256=pJrNR2UB4PlWl6cv4EDl1uGl8YTBUUMQkhJcsh5K4sA,4291
74
- onnx_diagnostic/reference/torch_ops/unary_ops.py,sha256=E8Ys1eZsOTsucBKoXb1_Kl5LbBDygniDvW2BvN4IPMo,1708
74
+ onnx_diagnostic/reference/torch_ops/unary_ops.py,sha256=dwu6HPr4V_roxu85U3VLTtDLx5bfxKalT_-zlQxZ5wc,1850
75
75
  onnx_diagnostic/tasks/__init__.py,sha256=uWFP7HIr-VnxmXD5i_QAfXnLXc1HwUq2e8v9cKLqraQ,2492
76
- onnx_diagnostic/tasks/automatic_speech_recognition.py,sha256=H94rxeiAjcJdECA1g95G_U9fZfpXk6dfjNKKYuvc4Qc,7130
77
- onnx_diagnostic/tasks/feature_extraction.py,sha256=4M5bE6lGf7KG9qnlim9EzVmqptL17jsSnWgT-gYtcYg,5534
78
- onnx_diagnostic/tasks/fill_mask.py,sha256=Rvrz0j_DQu-vf4CSSAZMBMXb2EuHvOCzRZwj8Cy8yfg,2620
79
- onnx_diagnostic/tasks/image_classification.py,sha256=x1XfeWAOe0r_s9kU6WENoYxjfoRTp1pkwKgIveoLbUw,4627
80
- onnx_diagnostic/tasks/image_text_to_text.py,sha256=xAp3RcFGwVYdByDqAlTvO82mPZiwiFhVQMWL1yV7ZZU,16224
81
- onnx_diagnostic/tasks/mask_generation.py,sha256=UQExMner3As8KznK-y4MjycYeUz5POcVR-oLEiAXmK4,5002
82
- onnx_diagnostic/tasks/mixture_of_expert.py,sha256=DgIsbwzV4smysOK83wny91k3ix1Qt2tSFXLGLoz4WOo,2796
83
- onnx_diagnostic/tasks/object_detection.py,sha256=xRBH9JZxBQf0SVSTJP6d-VVCKqrw7JAeif1joHfiYng,4224
84
- onnx_diagnostic/tasks/sentence_similarity.py,sha256=soL6QxLvyjtQ-3tQ3nCFxrcrk_4a8tuAjil8zYQ_pXk,2635
85
- onnx_diagnostic/tasks/summarization.py,sha256=LZ8A8wl6cd8kWSc6k5vLHa_XZkm35rYkTRv8iUYtr6I,8268
86
- onnx_diagnostic/tasks/text2text_generation.py,sha256=SzmgECK05H_fieIa2rlY-MQUmvNRotOo05J2eiMwjIM,8578
87
- onnx_diagnostic/tasks/text_classification.py,sha256=dO_LLbwwv0OJfIa9DqxQqAGUDuz3iIF1XkafzaYJdJw,2691
88
- onnx_diagnostic/tasks/text_generation.py,sha256=xudXQlCC-chd3p_T1k5qmvLE698wIWoVLAUgAsJ8GaQ,13257
76
+ onnx_diagnostic/tasks/automatic_speech_recognition.py,sha256=tguoQO77okXo8vcJrN2FAmpO9zkq04WSY8OKgm5sqRw,7185
77
+ onnx_diagnostic/tasks/feature_extraction.py,sha256=pcFON5uGKoykjg52bMsvpYG7KJvXd8JDC43rAjXIzB0,5572
78
+ onnx_diagnostic/tasks/fill_mask.py,sha256=Z0OyDs3pcnjJLzZBbS52d6pa6jh6m2Uy8-h3nF5wbDA,2675
79
+ onnx_diagnostic/tasks/image_classification.py,sha256=nLpBBB1Gkog3Fk6pu2waiHcuQr4ILPptc9FhQ-pn460,4682
80
+ onnx_diagnostic/tasks/image_text_to_text.py,sha256=syi7MzOKnHlWfqsfQsbmY6zcwtj8flg5_jVqodmIKcY,16806
81
+ onnx_diagnostic/tasks/mask_generation.py,sha256=fjdD3rd-O-mFL0hQy3la3JXKth_0bH2HL7Eelq-3Dbs,5057
82
+ onnx_diagnostic/tasks/mixture_of_expert.py,sha256=al4tk1BrHidtRiHlAaiflWiJaAte0d5M8WcBioANG9k,2808
83
+ onnx_diagnostic/tasks/object_detection.py,sha256=3FiT8ya5FCd9lwjQCRXhAwXspNwYTlAD3Gpk8aAcG5w,4279
84
+ onnx_diagnostic/tasks/sentence_similarity.py,sha256=Azpw9hxLwxM7O14Rj0mzH73LrrYGhiBm8fIb_tVnXCM,2690
85
+ onnx_diagnostic/tasks/summarization.py,sha256=tH2aX8undH8n-CGzDp-d-nBil2TD4Kv3PqeiaiFLkqY,8327
86
+ onnx_diagnostic/tasks/text2text_generation.py,sha256=-5Iy938AsQBXmA2chxYc7MUZQ7ZlmWJQ7k_O66wGTTo,8637
87
+ onnx_diagnostic/tasks/text_classification.py,sha256=JbKjnMoocr-k3-RVC5b-68kZaKJTPTm3aKSTXShHEo0,2746
88
+ onnx_diagnostic/tasks/text_generation.py,sha256=i1tX_cOMnKwIvEcm2EFNWtZ4DwJGcQ6EGQGSJmu69Oc,12858
89
89
  onnx_diagnostic/tasks/text_to_image.py,sha256=mOS3Ruosi3hzRMxXLDN7ZkAbi7NnQb7MWwQP_okGVHs,2962
90
90
  onnx_diagnostic/tasks/zero_shot_image_classification.py,sha256=1iqYamkq5kZNXEXsySw748ernc0O94GkwpYAIEl6Kj4,4659
91
91
  onnx_diagnostic/torch_export_patches/__init__.py,sha256=0SaZedwznm1hQUCvXZsGZORV5vby954wEExr5faepGg,720
92
- onnx_diagnostic/torch_export_patches/onnx_export_errors.py,sha256=NVJNhwr5LVwKzU9RsR2b8fOounmQ1W3nx_k-6XirASc,23701
92
+ onnx_diagnostic/torch_export_patches/onnx_export_errors.py,sha256=Nx3HLII-KIemfMydraTRlwK9O0kgVug57SiLT9y9KOY,23749
93
93
  onnx_diagnostic/torch_export_patches/onnx_export_serialization.py,sha256=klvqiMjccwGhiRnLRVbwTi5WWkMfvtnOV5ycirPcAdA,11354
94
94
  onnx_diagnostic/torch_export_patches/patch_expressions.py,sha256=vr4tt61cbDnaaaduzMj4UBZ8OUtr6GfDpIWwOYqjWzs,3213
95
- onnx_diagnostic/torch_export_patches/patch_inputs.py,sha256=_z6hcabYRGJ6VYiHuMzxYyFF8pYW-Xwcm60Wst3O8zA,7779
95
+ onnx_diagnostic/torch_export_patches/patch_inputs.py,sha256=3ySY1nAzINSS1hAzTycwfdbPas8G5CDL2MjnaAHBkMU,7825
96
96
  onnx_diagnostic/torch_export_patches/patch_module.py,sha256=R2d9IHM-RwsBKDsxuBIJnEqMoxbS9gd4YWFGG2wwV5A,39881
97
97
  onnx_diagnostic/torch_export_patches/patch_module_helper.py,sha256=2U0AdyZuU0W54QTdE7tY7imVzMnpQ5091ADNtTCkT8Y,6967
98
98
  onnx_diagnostic/torch_export_patches/eval/__init__.py,sha256=57x62uZNA80XiWgkG8Fe0_8YJcIVrvKLPqvwLDPJwgc,24008
99
99
  onnx_diagnostic/torch_export_patches/eval/model_cases.py,sha256=DTvdHPtNQh25Akv5o3D4Jxf1L1-SJ7w14tgvj8AAns8,26577
100
100
  onnx_diagnostic/torch_export_patches/patches/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
101
- onnx_diagnostic/torch_export_patches/patches/patch_torch.py,sha256=KaZ8TjDa9ATgT4HllYzzoNf_51q_yOj_GuF5NYjPCrU,18913
102
- onnx_diagnostic/torch_export_patches/patches/patch_transformers.py,sha256=ZmBCpkHx7FV8eIQDXavxjK4PZLSOn5ApT4bVQbJIqMg,56770
101
+ onnx_diagnostic/torch_export_patches/patches/patch_torch.py,sha256=g1UjL6A6iB7Qh2Cs1efuKk5377IvsSnZXUk3jNeRu_E,18830
102
+ onnx_diagnostic/torch_export_patches/patches/patch_transformers.py,sha256=3pAm3cPDq_HxpKCJNLLyrO53ZAnByjg7uKzpUPhz7nc,61378
103
103
  onnx_diagnostic/torch_export_patches/serialization/__init__.py,sha256=BHLdRPtNAtNPAS-bPKEj3-foGSPvwAbZXrHzGGPDLEw,1876
104
104
  onnx_diagnostic/torch_export_patches/serialization/diffusers_impl.py,sha256=drq3EH_yjcSuIWYsVeUWm8Cx6YCZFU6bP_1PLtPfY5I,945
105
- onnx_diagnostic/torch_export_patches/serialization/transformers_impl.py,sha256=jcSO2pvzbLA3JXVl3uDfoak7gM3J1SnmxshdSFxzE9w,9280
105
+ onnx_diagnostic/torch_export_patches/serialization/transformers_impl.py,sha256=dAKi4zujlBxDvxvaVI_qH4qW9AlpVFMtCkvGTNCJCUY,9353
106
106
  onnx_diagnostic/torch_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
107
  onnx_diagnostic/torch_models/llms.py,sha256=soyg4yC87ptGoeulJhKqw5opGmuLvH1pn_ZDXZ4Jr8E,90
108
- onnx_diagnostic/torch_models/validate.py,sha256=FNqi-Dg7-S_dSQDdcUjc5ERgTquiXclwGv0UZxVHYbY,64866
108
+ onnx_diagnostic/torch_models/validate.py,sha256=hMe4fbRDubSLfWc3XguRl_fjqQBa7-2zVKxhge9iaqc,64917
109
109
  onnx_diagnostic/torch_models/hghub/__init__.py,sha256=vi1Q7YHdddj1soiBN42MSvJdFqe2_KUoWafHISjwOu8,58
110
110
  onnx_diagnostic/torch_models/hghub/hub_api.py,sha256=Bvr-sTAhS6s6UCkt-KsY_7Mdai08-AQzvHrzbYCSuvk,13186
111
- onnx_diagnostic/torch_models/hghub/hub_data.py,sha256=NTTDsCtIVvYnr5J3rlcq0GSGDOzOPzq9Tsnb3oVf4q8,8309
111
+ onnx_diagnostic/torch_models/hghub/hub_data.py,sha256=W05mciqUqhaYEfYNHtUeuwOMOZoQTuDidRLEIx4z1CE,8523
112
112
  onnx_diagnostic/torch_models/hghub/hub_data_cached_configs.py,sha256=XZ_PsMUmMooJw5pBqEtDMOWbbLYxDcJdRWf-FNz2cYg,279674
113
113
  onnx_diagnostic/torch_models/hghub/model_inputs.py,sha256=SDRLCA2zivEHIKr2RRRP-dZNiNUcpYS3EgP0unLExxY,11046
114
114
  onnx_diagnostic/torch_models/untrained/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -117,8 +117,8 @@ onnx_diagnostic/torch_models/untrained/llm_tiny_llm.py,sha256=QXw_Bs2SzfeiQMf-tm
117
117
  onnx_diagnostic/torch_onnx/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
118
  onnx_diagnostic/torch_onnx/runtime_info.py,sha256=1g9F_Jf9AAgYQU4stbsrFXwQl-30mWlQrFbQ7val8Ps,9268
119
119
  onnx_diagnostic/torch_onnx/sbs.py,sha256=1EL25DeYFzlBSiFG_XjePBLvsiItRXbdDrr5-QZW2mA,16878
120
- onnx_diagnostic-0.7.6.dist-info/licenses/LICENSE.txt,sha256=Vv6TXglX6Rc0d-f8aREhayhT-6PMQXEyOmI2NKlUCMc,1045
121
- onnx_diagnostic-0.7.6.dist-info/METADATA,sha256=dPByK3aJs_ydnyy_Vfzlavdm00um0Ad3V6pu-78dWw0,7431
122
- onnx_diagnostic-0.7.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
- onnx_diagnostic-0.7.6.dist-info/top_level.txt,sha256=KwNkXewmcobM3ZT1DJLVWH6ebJzA5qKg7cWqKfpGNT4,16
124
- onnx_diagnostic-0.7.6.dist-info/RECORD,,
120
+ onnx_diagnostic-0.7.7.dist-info/licenses/LICENSE.txt,sha256=Vv6TXglX6Rc0d-f8aREhayhT-6PMQXEyOmI2NKlUCMc,1045
121
+ onnx_diagnostic-0.7.7.dist-info/METADATA,sha256=zus-hHQ_QtzpPCf--m_YA8MnWvfb8rmwbCGEy-ZlLro,7431
122
+ onnx_diagnostic-0.7.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
+ onnx_diagnostic-0.7.7.dist-info/top_level.txt,sha256=KwNkXewmcobM3ZT1DJLVWH6ebJzA5qKg7cWqKfpGNT4,16
124
+ onnx_diagnostic-0.7.7.dist-info/RECORD,,