Skip to content

Isolate AMS from PyTorch - #196

Merged
lpottier merged 1 commit into
developfrom
features/remove-torch
Oct 21, 2026
Merged

lpottier merged 1 commit into
developfrom
features/remove-torch

Conversation

@lpottier

@lpottier lpottier commented Jun 4, 2026

Copy link
Copy Markdown
Member

This PR aims at removing PyTorch from the critical path in AMS. The strict dependency on PyTorch prevents AMS from being used in some multi-physics codes and thus must be removed. This PR introduces the CMake flag -DWITH_TORCH=[On|Off].

This PR replaces Torch tensors with AMSTensor when possible. By default, -DWITH_TORCH=On, when AMS is compiled with Torch we can perform inference but when we do not compile AMS with Torch we can still store physics and it acts as a training only mode.

TODO:

  • Remove Torch dependency in evaluate()
  • Adapt tests to the no torch path
  • Test with RabbitMQ backend

@lpottier
lpottier force-pushed the features/remove-torch branch from 94df04e to 1820329 Compare August 21, 2026 21:41
@lpottier
lpottier force-pushed the features/remove-torch branch 2 times, most recently from 7666df2 to 448f08d Compare September 10, 2026 23:21
@lpottier
lpottier deployed to github-pages September 10, 2026 23:21 — with GitHub Actions Active

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.8

Click here for the full clang-format patch
diff --git a/src/AMSlib/wf/hdf5db.cpp b/src/AMSlib/wf/hdf5db.cpp
index c84bb01..d7425ba 100644
--- a/src/AMSlib/wf/hdf5db.cpp
+++ b/src/AMSlib/wf/hdf5db.cpp
@@ -12 +11,0 @@
-
@@ -14 +12,0 @@
-#include <stdexcept>

Have any feedback or feature suggestions? Share it here.

Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
@lpottier
lpottier deployed to github-pages September 11, 2026 22:26 — with GitHub Actions Active

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.8

Click here for the full clang-format patch
diff --git a/src/AMSlib/wf/hdf5db.cpp b/src/AMSlib/wf/hdf5db.cpp
index c84bb01..d7425ba 100644
--- a/src/AMSlib/wf/hdf5db.cpp
+++ b/src/AMSlib/wf/hdf5db.cpp
@@ -12 +11,0 @@
-
@@ -14 +12,0 @@
-#include <stdexcept>

Have any feedback or feature suggestions? Share it here.

Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
@lpottier
lpottier deployed to github-pages September 11, 2026 22:45 — with GitHub Actions Active

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.8

Click here for the full clang-format patch
diff --git a/src/AMSlib/wf/hdf5db.cpp b/src/AMSlib/wf/hdf5db.cpp
index 1d04a98..d7425ba 100644
--- a/src/AMSlib/wf/hdf5db.cpp
+++ b/src/AMSlib/wf/hdf5db.cpp
@@ -13 +12,0 @@
-#include <stdexcept>
@@ -14,0 +14 @@
+#include <stdexcept>

Have any feedback or feature suggestions? Share it here.

Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
@lpottier
lpottier deployed to github-pages September 11, 2026 22:52 — with GitHub Actions Active

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.8

Click here for the full clang-format patch
diff --git a/src/AMSlib/wf/hdf5db.cpp b/src/AMSlib/wf/hdf5db.cpp
index 1d04a98..d7425ba 100644
--- a/src/AMSlib/wf/hdf5db.cpp
+++ b/src/AMSlib/wf/hdf5db.cpp
@@ -13 +12,0 @@
-#include <stdexcept>
@@ -14,0 +14 @@
+#include <stdexcept>

Have any feedback or feature suggestions? Share it here.

Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
Comment thread src/AMSlib/wf/hdf5db.cpp Resolved
@lpottier
lpottier deployed to github-pages September 11, 2026 23:25 — with GitHub Actions Active
@lpottier
lpottier deployed to github-pages September 12, 2026 00:14 — with GitHub Actions Active
@lpottier
lpottier deployed to github-pages September 12, 2026 00:24 — with GitHub Actions Active
@lpottier
lpottier deployed to github-pages September 23, 2026 22:12 — with GitHub Actions Active
@lpottier
lpottier deployed to github-pages October 1, 2026 00:43 — with GitHub Actions Active
@lpottier
lpottier deployed to github-pages October 13, 2026 18:03 — with GitHub Actions Active

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.8

Click here for the full clang-format patch
diff --git a/src/AMSlib/AMSTensor.cpp b/src/AMSlib/AMSTensor.cpp
index e8575d7..ac45005 100644
--- a/src/AMSlib/AMSTensor.cpp
+++ b/src/AMSlib/AMSTensor.cpp
@@ -495,4 +495 @@ namespace ams
-bool isContiguous(const AMSTensor& tensor)
-{
-  return tensor.contiguous();
-}
+bool isContiguous(const AMSTensor& tensor) { return tensor.contiguous(); }
@@ -566 +563,2 @@ AMSTensor makeContiguousCPU(const AMSTensor& tensor,
-      throw std::invalid_argument("Unsupported AMSTensor dtype in makeContiguousCPU");
+      throw std::invalid_argument(
+          "Unsupported AMSTensor dtype in makeContiguousCPU");
diff --git a/src/AMSlib/wf/workflow.hpp b/src/AMSlib/wf/workflow.hpp
index fafbefe..76114cc 100644
--- a/src/AMSlib/wf/workflow.hpp
+++ b/src/AMSlib/wf/workflow.hpp
@@ -111 +111,2 @@ class AMSWorkflow
-        bool needsConversion = !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
+        bool needsConversion =
+            !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
@@ -128 +129,2 @@ class AMSWorkflow
-        bool needsConversion = !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
+        bool needsConversion =
+            !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
@@ -145 +147,2 @@ class AMSWorkflow
-        bool needsConversion = !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
+        bool needsConversion =
+            !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
@@ -162 +165,2 @@ class AMSWorkflow
-        bool needsConversion = !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
+        bool needsConversion =
+            !ams::isContiguous(Tensor) || !ams::onCPU(Tensor);
@@ -191 +195,3 @@ class AMSWorkflow
-      AMS_DBG(Workflow, "RMQ: cleaned up {} temporary buffers", tempAllocations.size());
+      AMS_DBG(Workflow,
+              "RMQ: cleaned up {} temporary buffers",
+              tempAllocations.size());
diff --git a/tests/AMSlib/perf_regression/ams_bench_db.cpp b/tests/AMSlib/perf_regression/ams_bench_db.cpp
index c9b0c35..61248fa 100644
--- a/tests/AMSlib/perf_regression/ams_bench_db.cpp
+++ b/tests/AMSlib/perf_regression/ams_bench_db.cpp
@@ -184 +184 @@ int main(int argc, char** argv)
-                false);
+                 false);
@@ -189 +189 @@ int main(int argc, char** argv)
-                false);
+                 false);
@@ -200,3 +200,15 @@ int main(int argc, char** argv)
-  args.AddOption(&num_inputs, "-di", "--dim-inputs", "Dimension of inputs, default: 8", false);
-  args.AddOption(&num_outputs, "-do", "--dim-outputs", "Dimension of outputs, default: 9", false);
-  args.AddOption(&num_iterations, "-i", "--num-iter", "Number of iterations, default: 1", false);
+  args.AddOption(&num_inputs,
+                 "-di",
+                 "--dim-inputs",
+                 "Dimension of inputs, default: 8",
+                 false);
+  args.AddOption(&num_outputs,
+                 "-do",
+                 "--dim-outputs",
+                 "Dimension of outputs, default: 9",
+                 false);
+  args.AddOption(&num_iterations,
+                 "-i",
+                 "--num-iter",
+                 "Number of iterations, default: 1",
+                 false);

Have any feedback or feature suggestions? Share it here.

Comment thread src/AMSlib/AMSTensor.cpp Resolved
Comment thread src/AMSlib/AMSTensor.cpp Resolved
Comment thread src/AMSlib/wf/workflow.hpp Resolved
Comment thread src/AMSlib/wf/workflow.hpp Resolved
Comment thread src/AMSlib/wf/workflow.hpp Resolved
Comment thread src/AMSlib/wf/workflow.hpp Resolved
Comment thread src/AMSlib/wf/workflow.hpp Resolved
@lpottier
lpottier deployed to github-pages October 13, 2026 18:16 — with GitHub Actions Active
Torch is not needed to compile and use AMS. When not using
Torch AMS cannot perform inference but can be used to gather
training data.

Signed-off-by: Loic Pottier <pottier1@llnl.gov>
@lpottier
lpottier force-pushed the features/remove-torch branch from 220d038 to 54abd64 Compare October 14, 2026 22:19
@lpottier
lpottier deployed to github-pages October 14, 2026 22:19 — with GitHub Actions Active
@lpottier
lpottier merged commit e415d66 into develop Oct 21, 2026
22 checks passed

This branch was successfully deployed

1 active deployment
github-pages — 54abd64e Deployed Oct 14, 2026 by lpottier via build-docs #118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant