Skip to content

Commit

Permalink
fix applyControlledMatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Oct 16, 2024
1 parent ed2df45 commit e06cd31
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ class StateVectorCudaManaged
if (opName == "Identity") {
return;
} else if (opName == "GlobalPhase") {
//TODO: Check the performance GlobalPhase implementation via scaling the statevector
// TODO: Check the performance GlobalPhase implementation via
// scaling the statevector
const std::vector<std::string> names(BaseType::getNumQubits(), "I");
std::vector<std::size_t> tgts_all(BaseType::getNumQubits());
std::iota(tgts_all.begin(), tgts_all.end(), 0);
Expand Down Expand Up @@ -486,7 +487,7 @@ class StateVectorCudaManaged
return static_cast<int>(BaseType::getNumQubits() - 1 - x);
});

std::transform(ctrls_values.begin(), ctrls_values.end(),
std::transform(ctrls_values.rbegin(), ctrls_values.rend(),
ctrls_valuesInt.begin(),
[&](bool x) { return static_cast<int>(x); });

Expand Down
2 changes: 1 addition & 1 deletion tests/lightning_qubit/test_adjoint_jacobian_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def test_not_expectation_return_type(self, lightning_sv):
self.calculate_jacobian(lightning_sv(num_wires=1), tape)

@pytest.mark.skipif(
device_name != "lightning.qubit",
device_name not in ("lightning.qubit", "lightning.gpu"),
reason="N-controlled operations only implemented in lightning.qubit.",
)
@pytest.mark.parametrize("n_qubits", [1, 2, 3, 4])
Expand Down
2 changes: 1 addition & 1 deletion tests/lightning_qubit/test_measurements_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def test_controlled_qubit_gates(self, operation, n_qubits, control_value, tol, l
assert np.allclose(result, expected, tol * 10)

@pytest.mark.skipif(
device_name not in ("lightning.qubit", "lightning.tensor"),
device_name not in ("lightning.qubit", "lightning.tensor", "lightning.gpu"),
reason="N-controlled operations only implemented in lightning.qubit.",
)
def test_controlled_qubit_unitary_from_op(self, tol, lightning_sv):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_adjoint_jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_Rot_gradient(self, stateprep, theta, dev):
assert np.allclose(calculated_val, numeric_val, atol=tol, rtol=0)

@pytest.mark.skipif(
device_name != "lightning.qubit",
device_name not in ("lightning.qubit", "lightning.gpu"),
reason="N-controlled operations only implemented in lightning.qubit.",
)
@pytest.mark.parametrize("n_qubits", [1, 2, 3, 4])
Expand Down Expand Up @@ -817,7 +817,7 @@ def circuit(p):
assert np.allclose(jac_ad, jac_bp, atol=tol, rtol=0)

@pytest.mark.skipif(
device_name != "lightning.qubit",
device_name not in ("lightning.qubit", "lightning.gpu"),
reason="N-controlled operations only implemented in lightning.qubit.",
)
@pytest.mark.parametrize(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def test_state_prep(n_targets, tol):


@pytest.mark.skipif(
device_name != "lightning.qubit",
device_name not in ("lightning.qubit", "lightning.gpu"),
reason="N-controlled operations only implemented in lightning.qubit.",
)
@pytest.mark.parametrize("control_value", [False, True])
Expand Down Expand Up @@ -497,7 +497,7 @@ def circuit():


@pytest.mark.skipif(
device_name != "lightning.qubit",
device_name not in ("lightning.qubit", "lightning.gpu"),
reason="N-controlled operations only implemented in lightning.qubit.",
)
def test_controlled_qubit_unitary_from_op(tol):
Expand Down Expand Up @@ -558,7 +558,7 @@ def test_paulirot(n_wires, n_targets, tol):


@pytest.mark.skipif(
device_name not in ("lightning.qubit", "lightning.tensor"),
device_name not in ("lightning.qubit", "lightning.tensor", "lightning.gpu"),
reason="N-controlled operations only implemented in lightning.qubit.",
)
@pytest.mark.parametrize("control_wires", range(4))
Expand Down

0 comments on commit e06cd31

Please sign in to comment.