From b7ec1daf5a9f4468b033134ec2c180f8d7e1ef82 Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Tue, 22 Oct 2024 14:53:28 +0000 Subject: [PATCH] tidy up naming --- .../lightning_gpu/StateVectorCudaManaged.hpp | 25 ++++++++++--------- .../lightning_gpu/_state_vector.py | 7 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pennylane_lightning/core/src/simulators/lightning_gpu/StateVectorCudaManaged.hpp b/pennylane_lightning/core/src/simulators/lightning_gpu/StateVectorCudaManaged.hpp index 2e31bbe2f..2612e8766 100644 --- a/pennylane_lightning/core/src/simulators/lightning_gpu/StateVectorCudaManaged.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_gpu/StateVectorCudaManaged.hpp @@ -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 &ctrl_wires, - const std::vector &ctrl_values, + const std::string &opName, + const std::vector &controlled_wires, + const std::vector &controlled_values, const std::vector &tgt_wires, bool adjoint = false, const std::vector ¶ms = {0.0}, [[maybe_unused]] const std::vector &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 ctrlsInt(ctrl_wires.size()); + std::vector ctrlsInt(controlled_wires.size()); std::vector tgtsInt(tgt_wires.size()); - std::vector ctrls_valuesInt(ctrl_wires.size()); + std::vector 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(BaseType::getNumQubits() - 1 - x); }); @@ -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(x); }); if (opName == "GlobalPhase") { @@ -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 &pauli_words, @@ -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. */ diff --git a/pennylane_lightning/lightning_gpu/_state_vector.py b/pennylane_lightning/lightning_gpu/_state_vector.py index c4bce5db3..99b9a91ef 100644 --- a/pennylane_lightning/lightning_gpu/_state_vector.py +++ b/pennylane_lightning/lightning_gpu/_state_vector.py @@ -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 @@ -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: