NVIDIA / cuda-quantum

C++ and Python support for the CUDA Quantum programming model for heterogeneous quantum-classical workflows
https://nvidia.github.io/cuda-quantum/
Other
515 stars 184 forks source link

Add support for random seed in tensornet and tensornet-mps backends #895

Open 1tnguyen opened 12 months ago

1tnguyen commented 12 months ago

Currently, these 2 backends don't support random seed since cutensornetsamplersample is using a random default seed.

When cutensornetsamplersample allows resetting the seed to a user-defined value, we need to update the backends to support cudaq::set_random_seed.

Enable these tests once this issue is fixed (PR #863): https://github.com/NVIDIA/cuda-quantum/blob/6edf1cdb6081d52075dc04fabc3973b3a0fae04a/unittests/integration/ghz_nisq_tester.cpp#L97

bmhowe23 commented 3 months ago

Related: https://github.com/NVIDIA/cuda-quantum/actions/runs/10104408125 failed with this error while processing docs/sphinx/examples/cpp/other/random_walk_qpe.cpp on the tensornet-mps backend:

Exited with code 134
a.out: /workspaces/cuda-quantum/runtime/nvqir/cutensornet/simulator_cutensornet.cpp:162: virtual bool nvqir::SimulatorTensorNetBase::measureQubit(std::size_t): Assertion `std::abs(1.0 - (prob0 + prob1)) < 1e-9' failed.

The docs link provided above still says the ability to reset the seed to a user-defined value may be provided in the future.

The problem in the Publishing run cannot easily be debugged without the ability to set the random seed.

CUDA-Q version used in the publishing run above: bac06f881109b9753d78b71105555012293bf010 (main)