Skip to content

Commit

Permalink
tidy up naming
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Oct 22, 2024
1 parent fbae962 commit b7ec1da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,21 +361,22 @@ class StateVectorCudaManaged
* @param params Optional std gate matrix if opName doesn't exist.
*/
void applyOperation(
const std::string &opName, const std::vector<std::size_t> &ctrl_wires,
const std::vector<bool> &ctrl_values,
const std::string &opName,
const std::vector<std::size_t> &controlled_wires,
const std::vector<bool> &controlled_values,
const std::vector<std::size_t> &tgt_wires, bool adjoint = false,
const std::vector<Precision> &params = {0.0},
[[maybe_unused]] const std::vector<ComplexT> &gate_matrix = {}) {
PL_ABORT_IF_NOT(opName == "GlobalPhase",
"Only GlobalPhase gate is supported.");
PL_ABORT_IF(ctrl_wires.size() != ctrl_values.size(),
PL_ABORT_IF(controlled_wires.size() != controlled_values.size(),
"`ctrls` and `ctrls_values` must have the same size.");
std::vector<int> ctrlsInt(ctrl_wires.size());
std::vector<int> ctrlsInt(controlled_wires.size());
std::vector<int> tgtsInt(tgt_wires.size());
std::vector<int> ctrls_valuesInt(ctrl_wires.size());
std::vector<int> ctrls_valuesInt(controlled_wires.size());

std::transform(ctrl_wires.begin(), ctrl_wires.end(), ctrlsInt.begin(),
[&](std::size_t x) {
std::transform(controlled_wires.begin(), controlled_wires.end(),
ctrlsInt.begin(), [&](std::size_t x) {
return static_cast<int>(BaseType::getNumQubits() -
1 - x);
});
Expand All @@ -385,7 +386,7 @@ class StateVectorCudaManaged
1 - x);
});

std::transform(ctrl_values.begin(), ctrl_values.end(),
std::transform(controlled_values.begin(), controlled_values.end(),
ctrls_valuesInt.begin(),
[&](bool x) { return static_cast<int>(x); });
if (opName == "GlobalPhase") {
Expand Down Expand Up @@ -1425,10 +1426,10 @@ class StateVectorCudaManaged
/**
* @brief Apply parametric Pauli gates using custateVec calls.
*
* @param angle Rotation angle.
* @param pauli_words List of Pauli words representing operation.
* @param ctrls Control wires
* @param tgts target wires.
* @param params Rotation parameters.
* @param use_adjoint Take adjoint of operation.
*/
void applyParametricPauliGate_(const std::vector<std::string> &pauli_words,
Expand Down Expand Up @@ -1458,9 +1459,9 @@ class StateVectorCudaManaged
* @brief Apply a parametric Pauli gate using custateVec calls.
*
* @param pauli_words List of Pauli words representing operation.
* @param ctrls Control wires
* @param ctrls_values Control values
* @param tgts target wires.
* @param ctrlsInt Control wires
* @param ctrls_valuesInt Control values
* @param tgtsInt target wires.
* @param param Rotation angle.
* @param use_adjoint Take adjoint of operation.
*/
Expand Down
7 changes: 3 additions & 4 deletions pennylane_lightning/lightning_gpu/_state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ def _apply_lightning_controlled(self, operation):
Returns:
None
"""
if self._mpi_handler.use_mpi:
raise DeviceError("Lightning-GPU-MPI does not support Controlled GlobalPhase gates.")

state = self.state_vector

basename = operation.base.name

Check warning on line 246 in pennylane_lightning/lightning_gpu/_state_vector.py

View check run for this annotation

Codecov / codecov/patch

pennylane_lightning/lightning_gpu/_state_vector.py#L246

Added line #L246 was not covered by tests
Expand Down Expand Up @@ -323,10 +326,6 @@ def _apply_lightning(
operation.base, qml.GlobalPhase
): # apply n-controlled gate
# LGPU do not support the controlled gates except for GlobalPhase
if self._mpi_handler.use_mpi:
raise DeviceError(
"Lightning-GPU-MPI does not support Controlled GlobalPhase gates."
)
self._apply_lightning_controlled(operation)
else: # apply gate as a matrix
try:
Expand Down

0 comments on commit b7ec1da

Please sign in to comment.