From 62b06965bee91fb883fe0bbd507971e8e0d660a1 Mon Sep 17 00:00:00 2001 From: xadupre Date: Fri, 19 Sep 2025 19:27:55 +0200 Subject: [PATCH 1/5] upgrade to 7.12 --- CHANGELOGS.rst | 3 +++ _doc/index.rst | 3 +-- onnx_diagnostic/__init__.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOGS.rst b/CHANGELOGS.rst index 2cfbdc43..ae050a2d 100644 --- a/CHANGELOGS.rst +++ b/CHANGELOGS.rst @@ -1,6 +1,9 @@ Change Logs =========== +0.7.12 +++++++ + 0.7.11 ++++++ diff --git a/_doc/index.rst b/_doc/index.rst index 752332ac..3c1af76a 100644 --- a/_doc/index.rst +++ b/_doc/index.rst @@ -239,9 +239,8 @@ The function replaces dynamic dimensions defined as strings by Older versions ============== +* `0.7.12 <../v0.7.12/index.html>`_ * `0.7.11 <../v0.7.11/index.html>`_ -* `0.7.10 <../v0.7.10/index.html>`_ -* `0.7.9 <../v0.7.9/index.html>`_ * `0.6.3 <../v0.6.3/index.html>`_ * `0.5.0 <../v0.5.0/index.html>`_ * `0.4.4 <../v0.4.4/index.html>`_ diff --git a/onnx_diagnostic/__init__.py b/onnx_diagnostic/__init__.py index a0efbc84..821b7cff 100644 --- a/onnx_diagnostic/__init__.py +++ b/onnx_diagnostic/__init__.py @@ -3,5 +3,5 @@ Functions, classes to dig into a model when this one is right, slow, wrong... """ -__version__ = "0.7.11" +__version__ = "0.7.12" __author__ = "Xavier Dupré" From 9b4ed678edb5c50f8421127f1e6bcbadd16e54ef Mon Sep 17 00:00:00 2001 From: xadupre Date: Fri, 19 Sep 2025 19:38:33 +0200 Subject: [PATCH 2/5] g --- _doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_doc/conf.py b/_doc/conf.py index 4c1cc9fa..766d4c02 100644 --- a/_doc/conf.py +++ b/_doc/conf.py @@ -122,6 +122,7 @@ def linkcode_resolve(domain, info): ("py:class", "CacheProcessor"), ("py:class", "default=sklearn.utils.metadata_routing.UNCHANGED"), ("py:class", "diffusers.models.unets.unet_2d_condition.UNet2DConditionOutput"), + ("py:class", "MambaCache"), ("py:class", "ModelProto"), ("py:class", "Model"), ("py:class", "Module"), From 5c56c9d351d8160ca739fbe1b11f22889e528fe8 Mon Sep 17 00:00:00 2001 From: xadupre Date: Sat, 20 Sep 2025 09:26:56 +0200 Subject: [PATCH 3/5] doc --- CHANGELOGS.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOGS.rst b/CHANGELOGS.rst index b84bcea6..a7f634b1 100644 --- a/CHANGELOGS.rst +++ b/CHANGELOGS.rst @@ -4,6 +4,9 @@ Change Logs 0.7.12 ++++++ +* :pr:`226`: fix input order for models created with modelbuilder + + 0.7.11 ++++++ From 2d1e38ad2f441796731c2a0693369d6fbd67e4a5 Mon Sep 17 00:00:00 2001 From: xadupre Date: Sat, 20 Sep 2025 18:09:11 +0200 Subject: [PATCH 4/5] last fix for modelbuilder --- _unittests/ut_torch_models/test_validate_whole_models.py | 5 +++-- onnx_diagnostic/helpers/rt_helper.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/_unittests/ut_torch_models/test_validate_whole_models.py b/_unittests/ut_torch_models/test_validate_whole_models.py index 9f53ef73..a29be5cf 100644 --- a/_unittests/ut_torch_models/test_validate_whole_models.py +++ b/_unittests/ut_torch_models/test_validate_whole_models.py @@ -195,17 +195,18 @@ def test_k_filter_inputs(self): @ignore_warnings(FutureWarning) @requires_transformers("4.51") def test_l_validate_model_modelbuilder(self): - mid = "meta-llama/Llama-2-7b-hf" + mid = "microsoft/phi-2" summary, data = validate_model( mid, do_run=True, verbose=10, exporter="modelbuilder", dump_folder="dump_test/validate_model_modelbuilder", + patch=True, ) self.assertIsInstance(summary, dict) self.assertIsInstance(data, dict) - self.assertLess(summary["disc_onnx_ort_run_abs"], 1e-2) + self.assertLess(summary["disc_onnx_ort_run_abs"], 3e-2) onnx_filename = data["onnx_filename"] self.assertExists(onnx_filename) diff --git a/onnx_diagnostic/helpers/rt_helper.py b/onnx_diagnostic/helpers/rt_helper.py index a3b06898..7bf807d1 100644 --- a/onnx_diagnostic/helpers/rt_helper.py +++ b/onnx_diagnostic/helpers/rt_helper.py @@ -41,7 +41,7 @@ def make_feeds( """ # NOTE: position_ids is a special case because ModelBuilder does not usually use it, # because it's fued into rotary embedding in GQA. - if isinstance(inputs, dict): + if is_modelbuilder and isinstance(inputs, dict): inputs.pop("position_ids", None) # Ensure 'position_ids' absent before removing. flat = flatten_object(inputs, drop_keys=True) From f8f2c6a5566dc21832a43e26bf3cfec3762f4fc1 Mon Sep 17 00:00:00 2001 From: xadupre Date: Sat, 20 Sep 2025 18:34:00 +0200 Subject: [PATCH 5/5] doc --- onnx_diagnostic/helpers/rt_helper.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/onnx_diagnostic/helpers/rt_helper.py b/onnx_diagnostic/helpers/rt_helper.py index 7bf807d1..eb65063f 100644 --- a/onnx_diagnostic/helpers/rt_helper.py +++ b/onnx_diagnostic/helpers/rt_helper.py @@ -112,19 +112,23 @@ def reorder_modelbuilder_cache_to_torch(past_kv: List[Any]) -> List[Any]: Reorders the past_kvs for ModelBuilder to match the expected order by PyTorch exported models. - NOTE: This function can take either the names or the actual tensors - as long as they are in a list. + .. note:: + This function can take either the names or the actual tensors + as long as they are in a list. Conceptually, - From: - [past_key_values.0.key, past_key_values.0.value, - past_key_values.1.key, past_key_values.1.value, ...] - To: - [past_key_values.0.key, past_key_values.1.key, - ..., past_key_values.0.value, past_key_values.1.value, ...] + From:: - :param flat: list of flattened inputs + [past_key_values.0.key, past_key_values.0.value, + past_key_values.1.key, past_key_values.1.value, ...] + + To:: + + [past_key_values.0.key, past_key_values.1.key, + ..., past_key_values.0.value, past_key_values.1.value, ...] + + :param past_kv: list of flattened inputs :return: reordered list of flattened inputs """ total_len = len(past_kv)