Skip to content

Isolate AMS from PyTorch - #196

Open
lpottier wants to merge 12 commits into
developfrom
features/remove-torch
Open

Isolate AMS from PyTorch#196
lpottier wants to merge 12 commits 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

…CH=On except integration tests)

Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
Signed-off-by: Loic Pottier <pottier1@llnl.gov>
@github-actions

Copy link
Copy Markdown
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v18.1.8) reports: 8 concern(s)
  • src/AMSlib/include/SmallVector.hpp:227:53: warning: [clang-diagnostic-unused-parameter]

    unused parameter 'Elt'

      227 |   void assertSafeToReferenceAfterResize(const void* Elt, size_t NewSize)
          |                                                     ^
  • src/AMSlib/include/SmallVector.hpp:227:65: warning: [clang-diagnostic-unused-parameter]

    unused parameter 'NewSize'

      227 |   void assertSafeToReferenceAfterResize(const void* Elt, size_t NewSize)
          |                                                                 ^
  • src/AMSlib/wf/hdf5db.cpp:38:20: warning: [clang-diagnostic-unused-function]

    unused function 'tensorSizeToString'

       38 | static std::string tensorSizeToString(ArrayRef<AMSTensor::IntDimType> shape)
          |                    ^~~~~~~~~~~~~~~~~~
  • tests/AMSlib/ams_interface/ams_ete_env.cpp:88:30: warning: [clang-diagnostic-vla-cxx-extension]

    variable length arrays in C++ are a Clang extension

       88 |             const DType* ins[num_inputs];
          |                              ^~~~~~~~~~
    /home/runner/work/AMS/AMS/tests/AMSlib/ams_interface/ams_ete_env.cpp:87:59: note: while substituting into a lambda expression here
       87 |               ams::SmallVector<ams::AMSTensor>& ams_outs) {
          |                                                           ^
    /home/runner/work/AMS/AMS/tests/AMSlib/ams_interface/ams_ete_env.cpp:178:12: note: in instantiation of member function 'Problem<float>::ams_run' requested here
      178 |       prob.ams_run(wf, resource, num_iterations, avg_elements);
          |            ^
    /home/runner/work/AMS/AMS/tests/AMSlib/ams_interface/ams_ete_env.cpp:88:30: note: implicit use of 'this' pointer is only allowed within the evaluation of a call to a 'constexpr' member function
       88 |             const DType* ins[num_inputs];
          |                              ^
  • tests/AMSlib/core/amstensor_torch_benchmark.cpp:77:19: error: [clang-diagnostic-error]

    use of undeclared identifier 'AMS_TENSOR_BENCHMARK_CSV_DEFAULT'

       77 |                 : AMS_TENSOR_BENCHMARK_CSV_DEFAULT;
          |                   ^
  • tests/AMSlib/core/amstensor_torch_benchmark.cpp:93:56: error: [clang-diagnostic-error]

    use of undeclared identifier 'AMS_BENCHMARK_GIT_COMMIT'

       93 |     _output << csvField(_timestamp) << ',' << csvField(AMS_BENCHMARK_GIT_COMMIT)
          |                                                        ^
  • tests/AMSlib/core/amstensor_torch_benchmark.cpp:94:32: error: [clang-diagnostic-error]

    use of undeclared identifier 'AMS_BENCHMARK_SOURCE_STATE'

       94 |             << ',' << csvField(AMS_BENCHMARK_SOURCE_STATE) << ','
          |                                ^
  • tests/AMSlib/perf_regression/ams_bench_db.cpp:2:10: error: [clang-diagnostic-error]

    'mpi.h' file not found

        2 | #include <mpi.h>
          |          ^~~~~~~

Have any feedback or feature suggestions? Share it here.

Signed-off-by: Loic Pottier <pottier1@llnl.gov>
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