cuda-quantum icon indicating copy to clipboard operation
cuda-quantum copied to clipboard

[RFC] Handle device pointer for state initialization

Open sacpis opened this issue 1 year ago • 9 comments

Fixes #1788

This PR checks if the pointer is a device pointer and then does memcpy from device to device.

sacpis avatar Jul 21 '24 03:07 sacpis

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Jul 21 '24 18:07 github-actions[bot]

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Jul 21 '24 22:07 github-actions[bot]

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Jul 22 '24 17:07 github-actions[bot]

@1tnguyen May I please request for you review?

sacpis avatar Jul 23 '24 14:07 sacpis

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Jul 24 '24 00:07 github-actions[bot]

Here I am blocked on including nvqir/CircuitSimulator in get_state_tester. Seems like the builder is not happy including it in the file as it throws the below error.

In file included from /workspaces/cuda-quantum/runtime/common/Logger.h:14,
                 from /workspaces/cuda-quantum/runtime/nvqir/CircuitSimulator.h:13,
                 from /workspaces/cuda-quantum/unittests/gpu/get_state_tester.cu:12:
/workspaces/cuda-quantum/runtime/common/FmtCore.h:16:10: fatal error: fmt/chrono.h: No such file or directory
   16 | #include <fmt/chrono.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

sacpis avatar Jul 25 '24 23:07 sacpis

Here I am blocked on including nvqir/CircuitSimulator in get_state_tester. Seems like the builder is not happy including it in the file as it throws the below error.

In file included from /workspaces/cuda-quantum/runtime/common/Logger.h:14,
                 from /workspaces/cuda-quantum/runtime/nvqir/CircuitSimulator.h:13,
                 from /workspaces/cuda-quantum/unittests/gpu/get_state_tester.cu:12:
/workspaces/cuda-quantum/runtime/common/FmtCore.h:16:10: fatal error: fmt/chrono.h: No such file or directory
   16 | #include <fmt/chrono.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

Thanks, Sachin. I'm definitely open to any other ideas for testing here. I just think that we need to have some sort of test to prove that code changes are working as intended. If a unit test isn't working out, perhaps an application-level test (one where the user is providing a pointer to GPU memory) would work better than a unit test?

bmhowe23 avatar Jul 26 '24 15:07 bmhowe23

Just had a call with @1tnguyen regarding passing the pointer to GPU memory. Putting this PR into the draft mode and adding RFC here.

Seems like it might involve introduction of some new APIs to qvector, something like these

  qubit::qubit(const vector<complex<double>>&);
  qubit::qubit(const initializer_list<complex<double>>&);
  qvector::qvector(const vector<complex<double>>&);
  qvector::qvector(const initializer_list<complex<double>>&);

in order to support passing a pointer to the GPU memory. This is related to issue #1086.

@1tnguyen @amccaskey Would you please add your thoughts here?

sacpis avatar Aug 01 '24 22:08 sacpis

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Aug 01 '24 23:08 github-actions[bot]