Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/config/gitlab_commits.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nvidia-mgpu-repo: cuda-quantum/cuquantum-mgpu.git
nvidia-mgpu-commit: 17279375c13290a202ae5c5267f1f571227f1ef4
nvidia-mgpu-commit: de32bf2abae42f118a0da36be0066296d76b0dbc
22 changes: 22 additions & 0 deletions python/tests/visualization/test_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions runtime/nvqir/CircuitSimulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions runtime/nvqir/custatevec/CuStateVecCircuitSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ class CuStateVecCircuitSimulator
void applyExpPauli(double theta, const std::vector<std::size_t> &controlIds,
const std::vector<std::size_t> &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));
Expand Down
4 changes: 4 additions & 0 deletions runtime/nvqir/cutensornet/simulator_mps_register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class SimulatorMPS : public SimulatorTensorNetBase {
const std::vector<std::size_t> &controls,
const std::vector<std::size_t> &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
Expand Down
Loading