Synthetic diffusion MGN example. - #198
Open
YohannDudouit wants to merge 18 commits into
Open
Conversation
YohannDudouit
temporarily deployed
to
github-pages
June 9, 2026 22:52 — with
GitHub Actions
Inactive
YohannDudouit
temporarily deployed
to
github-pages
June 9, 2026 23:48 — with
GitHub Actions
Inactive
YohannDudouit
force-pushed
the
yohann/diffusion-MGN
branch
from
July 1, 2026 00:13
1a76b77 to
1294d99
Compare
YohannDudouit
temporarily deployed
to
github-pages
July 1, 2026 00:13 — with
GitHub Actions
Inactive
YohannDudouit
force-pushed
the
yohann/diffusion-MGN
branch
from
August 21, 2026 17:25
1294d99 to
4dd29d7
Compare
YohannDudouit
temporarily deployed
to
github-pages
August 21, 2026 17:25 — with
GitHub Actions
Inactive
YohannDudouit
temporarily deployed
to
github-pages
August 21, 2026 22:34 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Cpp-linter Review
Used clang-format v18.1.8
Click here for the full clang-format patch
diff --git a/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp b/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp
index ed1b823..9e4cfeb 100644
--- a/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp
+++ b/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp
@@ -176,4 +176,6 @@ static json loadManifest(const std::filesystem::path& fixture_dir)
- CATCH_FAIL("Missing MGN graph diffusion fixtures at "
- << manifest_path
- << ". Regenerate and commit mgn_graph_diffusion.pt and "
- "fixtures.json.");
+ CATCH_FAIL("Missing MGN graph diffusion fixtures at " << manifest_path
+ << ". Regenerate and "
+ "commit "
+ "mgn_graph_"
+ "diffusion.pt and "
+ "fixtures.json.");
@@ -248,8 +250,12 @@ static AMSHomogeneousGraph makeGraph(const json& graph_case)
- auto node_features = readTensorValues<float>(
- tensors.at("node_features"), "float32", {num_nodes, node_dim});
- auto edge_index = readTensorValues<std::int64_t>(
- tensors.at("edge_index"), "int64", {2, num_edges});
- auto edge_features = readTensorValues<float>(
- tensors.at("edge_features"), "float32", {num_edges, edge_dim});
- auto global_features = readTensorValues<float>(
- tensors.at("global_features"), "float32", {global_dim});
+ auto node_features = readTensorValues<float>(tensors.at("node_features"),
+ "float32",
+ {num_nodes, node_dim});
+ auto edge_index = readTensorValues<std::int64_t>(tensors.at("edge_index"),
+ "int64",
+ {2, num_edges});
+ auto edge_features = readTensorValues<float>(tensors.at("edge_features"),
+ "float32",
+ {num_edges, edge_dim});
+ auto global_features = readTensorValues<float>(tensors.at("global_features"),
+ "float32",
+ {global_dim});
@@ -273,4 +279,4 @@ static std::vector<float> loadReferenceDeltaU(const json& graph_case)
- return readTensorValues<float>(
- graph_case.at("tensors").at("reference_delta_u"),
- "float32",
- {num_nodes, output_dim});
+ return readTensorValues<float>(graph_case.at("tensors").at("reference_delta_"
+ "u"),
+ "float32",
+ {num_nodes, output_dim});
@@ -383,2 +389 @@ CATCH_TEST_CASE("AMSExecute homogeneous graph MGN diffusion surrogate",
- std::vector<float> reference_delta_u =
- loadReferenceDeltaU(graph_case);
+ std::vector<float> reference_delta_u = loadReferenceDeltaU(graph_case);
Have any feedback or feature suggestions? Share it here.
YohannDudouit
temporarily deployed
to
github-pages
August 21, 2026 23:12 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Cpp-linter Review
Used clang-format v18.1.8
Click here for the full clang-format patch
diff --git a/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp b/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp
index ed1b823..9e4cfeb 100644
--- a/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp
+++ b/tests/AMSlib/ams_interface/test_graph_mgn_surrogate.cpp
@@ -176,4 +176,6 @@ static json loadManifest(const std::filesystem::path& fixture_dir)
- CATCH_FAIL("Missing MGN graph diffusion fixtures at "
- << manifest_path
- << ". Regenerate and commit mgn_graph_diffusion.pt and "
- "fixtures.json.");
+ CATCH_FAIL("Missing MGN graph diffusion fixtures at " << manifest_path
+ << ". Regenerate and "
+ "commit "
+ "mgn_graph_"
+ "diffusion.pt and "
+ "fixtures.json.");
@@ -248,8 +250,12 @@ static AMSHomogeneousGraph makeGraph(const json& graph_case)
- auto node_features = readTensorValues<float>(
- tensors.at("node_features"), "float32", {num_nodes, node_dim});
- auto edge_index = readTensorValues<std::int64_t>(
- tensors.at("edge_index"), "int64", {2, num_edges});
- auto edge_features = readTensorValues<float>(
- tensors.at("edge_features"), "float32", {num_edges, edge_dim});
- auto global_features = readTensorValues<float>(
- tensors.at("global_features"), "float32", {global_dim});
+ auto node_features = readTensorValues<float>(tensors.at("node_features"),
+ "float32",
+ {num_nodes, node_dim});
+ auto edge_index = readTensorValues<std::int64_t>(tensors.at("edge_index"),
+ "int64",
+ {2, num_edges});
+ auto edge_features = readTensorValues<float>(tensors.at("edge_features"),
+ "float32",
+ {num_edges, edge_dim});
+ auto global_features = readTensorValues<float>(tensors.at("global_features"),
+ "float32",
+ {global_dim});
@@ -273,4 +279,4 @@ static std::vector<float> loadReferenceDeltaU(const json& graph_case)
- return readTensorValues<float>(
- graph_case.at("tensors").at("reference_delta_u"),
- "float32",
- {num_nodes, output_dim});
+ return readTensorValues<float>(graph_case.at("tensors").at("reference_delta_"
+ "u"),
+ "float32",
+ {num_nodes, output_dim});
@@ -383,2 +389 @@ CATCH_TEST_CASE("AMSExecute homogeneous graph MGN diffusion surrogate",
- std::vector<float> reference_delta_u =
- loadReferenceDeltaU(graph_case);
+ std::vector<float> reference_delta_u = loadReferenceDeltaU(graph_case);
Have any feedback or feature suggestions? Share it here.
YohannDudouit
temporarily deployed
to
github-pages
August 21, 2026 23:21 — with
GitHub Actions
Inactive
lpottier
requested changes
Aug 25, 2026
lpottier
left a comment
Member
There was a problem hiding this comment.
LGTM overall, I've added a few comments. The only thing that is annoying in the current version is the dependency to torch. MGN_DIFFUSION_FEASIBILITY runs by default, so it makes a Python torch install a requirement at test time. Can we deactivate it by default or maybe check for torch like we do for hdf5 in tests/CMakeLists.txt and if torch is not there we mark these tests DISABLED?
YohannDudouit
temporarily deployed
to
github-pages
August 26, 2026 22:11 — with
GitHub Actions
Inactive
YohannDudouit
temporarily deployed
to
github-pages
August 26, 2026 22:32 — with
GitHub Actions
Inactive
YohannDudouit
force-pushed
the
yohann/diffusion-MGN
branch
from
August 27, 2026 16:48
26c1dd2 to
3acb0d8
Compare
YohannDudouit
temporarily deployed
to
github-pages
August 27, 2026 16:48 — with
GitHub Actions
Inactive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a pure-Torch MGN-like graph diffusion validation workflow for AMS homogeneous graph surrogates. It trains a small synthetic diffusion model, exports an AMS-compatible TorchScript model, writes runtime fixtures, and validates C++ AMS inference against Python TorchScript reference output.
What Changed
generate_mgn_graph_diffusion.pywith separate modes:feasibility: eager/script/reload checks on dynamic graph sizestrain: trains the synthetic graph diffusion surrogate and saves checkpoint/metricsfixtures: exports TorchScript and writes runtime fixture infixtures.jsontest_graph_mgn_surrogate.cppto load runtime fixtures and compare AMSnode:delta_uoutput against Python TorchScript references forN=24andN=73.MGN_DIFFUSION_*CTest workflow entries with dependency ordering:ENABLE_TRAINING_TESTSoption,Offby default. EnablingENABLE_TRAINING_TESTScurrently enables thetrainandfixturesmodes of the MGN diffusion tests.Testing
Normal CTest can skip this training workflow with:
Note: This PR is built on top of #194 and therefore include the graph construction and unit tests, until #194 is merged.