diff --git a/.github/workflows/config/gitlab_commits.txt b/.github/workflows/config/gitlab_commits.txt index 40b8604660b..d0a266f8bf5 100644 --- a/.github/workflows/config/gitlab_commits.txt +++ b/.github/workflows/config/gitlab_commits.txt @@ -1,2 +1,2 @@ nvidia-mgpu-repo: cuda-quantum/cuquantum-mgpu.git -nvidia-mgpu-commit: 17279375c13290a202ae5c5267f1f571227f1ef4 +nvidia-mgpu-commit: de32bf2abae42f118a0da36be0066296d76b0dbc diff --git a/python/tests/visualization/test_draw.py b/python/tests/visualization/test_draw.py index 733d97a24a6..b8c1756bbb5 100644 --- a/python/tests/visualization/test_draw.py +++ b/python/tests/visualization/test_draw.py @@ -105,6 +105,28 @@ def kernel(): assert expected_str == produced_string +# This test will run on the default simulator. For machines with GPUs, that +# will be a GPU-accelerated simulator, but for machines without GPUs, it +# will run on a CPU simulator. +def test_draw_with_exp_pauli(): + @cudaq.kernel + def kernel_exp_pauli(): + q = cudaq.qvector(2) + exp_pauli(0.2, q, "ZZ") + + + expected_str = R""" + +q0 : ──●────────────────●── + ╭─┴─╮╭──────────╮╭─┴─╮ +q1 : ┤ x ├┤ rz(-0.4) ├┤ x ├ + ╰───╯╰──────────╯╰───╯ +""" + expected_str = expected_str[1:] + produced_string = cudaq.draw(kernel_exp_pauli) + assert expected_str == produced_string + + def test_draw_hw_target(): @cudaq.kernel diff --git a/runtime/nvqir/CircuitSimulator.h b/runtime/nvqir/CircuitSimulator.h index 759cc971d58..f1dd2dc7387 100644 --- a/runtime/nvqir/CircuitSimulator.h +++ b/runtime/nvqir/CircuitSimulator.h @@ -386,13 +386,12 @@ class CircuitSimulatorBase : public CircuitSimulator { /// @brief Reference to the current circuit name. std::string currentCircuitName = ""; -private: +protected: /// @brief Return true if the simulator is in the tracer mode. bool isInTracerMode() const { return executionContext && executionContext->name == "tracer"; } -protected: /// @brief The current Execution Context (typically this is null, /// sampling, or spin_op observation. cudaq::ExecutionContext *executionContext = nullptr; diff --git a/runtime/nvqir/custatevec/CuStateVecCircuitSimulator.cpp b/runtime/nvqir/custatevec/CuStateVecCircuitSimulator.cpp index e5ee20cd184..580c7d602ed 100644 --- a/runtime/nvqir/custatevec/CuStateVecCircuitSimulator.cpp +++ b/runtime/nvqir/custatevec/CuStateVecCircuitSimulator.cpp @@ -456,6 +456,10 @@ class CuStateVecCircuitSimulator void applyExpPauli(double theta, const std::vector &controlIds, const std::vector &qubits, const cudaq::spin_op &op) override { + if (this->isInTracerMode()) { + nvqir::CircuitSimulator::applyExpPauli(theta, controlIds, qubits, op); + return; + } flushGateQueue(); cudaq::info(" [cusv decomposing] exp_pauli({}, {})", theta, op.to_string(false)); diff --git a/runtime/nvqir/cutensornet/simulator_mps_register.cpp b/runtime/nvqir/cutensornet/simulator_mps_register.cpp index 57b7f090bef..e9246a49949 100644 --- a/runtime/nvqir/cutensornet/simulator_mps_register.cpp +++ b/runtime/nvqir/cutensornet/simulator_mps_register.cpp @@ -112,6 +112,10 @@ class SimulatorMPS : public SimulatorTensorNetBase { const std::vector &controls, const std::vector &qubitIds, const cudaq::spin_op &op) override { + if (this->isInTracerMode()) { + nvqir::CircuitSimulator::applyExpPauli(theta, controls, qubitIds, op); + return; + } // Special handling for equivalence of Rxx(theta), Ryy(theta), Rzz(theta) // expressed as exp_pauli. // Note: for MPS, the runtime is ~ linear with the number of 2-body gates