From 1104ab7dbd104281b8c77ae331cb6a81be8357e8 Mon Sep 17 00:00:00 2001 From: Ali Asadi <10773383+maliasadi@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:00:10 -0400 Subject: [PATCH] Update support --- mpitests/test_adjoint_jacobian.py | 8 ++++++-- pennylane_lightning/core/_serialize.py | 4 +++- pennylane_lightning/core/_state_vector_base.py | 1 - .../core/src/algorithms/JacobianData.hpp | 12 ++++++------ .../lightning_kokkos/gates/BasicGateFunctors.hpp | 16 ++++++++++++++++ .../lightning_qubit/StateVectorLQubit.hpp | 4 ++-- .../lightning_qubit/gates/RegisterKernel.hpp | 5 +++-- .../gates/cpu_kernels/GateImplementationsLM.hpp | 1 - .../gates/cpu_kernels/avx_common/AVX2Concept.hpp | 8 ++++++-- .../cpu_kernels/avx_common/AVX512Concept.hpp | 8 ++++++-- .../cpu_kernels/avx_common/AVXConceptType.hpp | 12 +++++++++--- .../avx_common/TwoQubitGateHelper.hpp | 6 +++--- .../gates/tests/Test_KernelMap.cpp | 2 +- .../measurements/MeasurementKernels.hpp | 2 +- .../lightning_qubit/utils/LinearAlgebra.hpp | 6 ++---- .../core/src/utils/TypeTraits.hpp | 8 ++++++-- .../core/src/utils/cuda_utils/DataBuffer.hpp | 4 ++-- .../lightning_gpu/lightning_gpu.py | 2 ++ .../lightning_gpu/lightning_gpu.toml | 1 + .../lightning_kokkos/_measurements.py | 1 - .../lightning_kokkos/_state_vector.py | 2 -- .../lightning_kokkos/lightning_kokkos.py | 2 ++ .../lightning_kokkos/lightning_kokkos.toml | 3 ++- .../lightning_qubit/_measurements.py | 1 - .../lightning_qubit/_state_vector.py | 1 - tests/lightning_qubit/test_jacobian_method.py | 1 - tests/test_adjoint_jacobian.py | 8 ++++++-- tests/test_native_mcm.py | 1 - 28 files changed, 85 insertions(+), 45 deletions(-) diff --git a/mpitests/test_adjoint_jacobian.py b/mpitests/test_adjoint_jacobian.py index 6f3b5c7f5b..dc96acab5c 100644 --- a/mpitests/test_adjoint_jacobian.py +++ b/mpitests/test_adjoint_jacobian.py @@ -1384,7 +1384,9 @@ def test_qubit_unitary(dev, n_targets): np.random.seed(1337) par = 2 * np.pi * np.random.rand(n_wires) - U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand(2**n_targets, 2**n_targets) + U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand( + 2**n_targets, 2**n_targets + ) U, _ = np.linalg.qr(U) init_state = np.random.rand(2**n_wires) + 1j * np.random.rand(2**n_wires) init_state /= np.sqrt(np.dot(np.conj(init_state), init_state)) @@ -1432,7 +1434,9 @@ def test_diff_qubit_unitary(dev, n_targets): np.random.seed(1337) par = 2 * np.pi * np.random.rand(n_wires) - U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand(2**n_targets, 2**n_targets) + U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand( + 2**n_targets, 2**n_targets + ) U, _ = np.linalg.qr(U) init_state = np.random.rand(2**n_wires) + 1j * np.random.rand(2**n_wires) init_state /= np.sqrt(np.dot(np.conj(init_state), init_state)) diff --git a/pennylane_lightning/core/_serialize.py b/pennylane_lightning/core/_serialize.py index 9cd80c9550..1eedbbda69 100644 --- a/pennylane_lightning/core/_serialize.py +++ b/pennylane_lightning/core/_serialize.py @@ -367,7 +367,9 @@ def serialize_observables(self, tape: QuantumTape, wires_map: dict = None) -> Li obs_indices.append(i) return serialized_obs, obs_indices - def serialize_ops(self, tape: QuantumTape, wires_map: dict = None) -> Tuple[ + def serialize_ops( + self, tape: QuantumTape, wires_map: dict = None + ) -> Tuple[ List[List[str]], List[np.ndarray], List[List[int]], diff --git a/pennylane_lightning/core/_state_vector_base.py b/pennylane_lightning/core/_state_vector_base.py index b2ba3a0669..3e08a5ab40 100644 --- a/pennylane_lightning/core/_state_vector_base.py +++ b/pennylane_lightning/core/_state_vector_base.py @@ -38,7 +38,6 @@ class LightningBaseStateVector(ABC): """ def __init__(self, num_wires: int, dtype: Union[np.complex128, np.complex64]): - if dtype not in [np.complex64, np.complex128]: raise TypeError(f"Unsupported complex type: {dtype}") diff --git a/pennylane_lightning/core/src/algorithms/JacobianData.hpp b/pennylane_lightning/core/src/algorithms/JacobianData.hpp index 9186eb3fc2..fba007789e 100644 --- a/pennylane_lightning/core/src/algorithms/JacobianData.hpp +++ b/pennylane_lightning/core/src/algorithms/JacobianData.hpp @@ -76,8 +76,8 @@ template class OpsData { std::vector> ops_controlled_values) : num_par_ops_{0}, ops_name_{std::move(ops_name)}, ops_params_{ops_params}, ops_wires_{std::move(ops_wires)}, - ops_inverses_{std::move(ops_inverses)}, ops_matrices_{std::move( - ops_matrices)}, + ops_inverses_{std::move(ops_inverses)}, + ops_matrices_{std::move(ops_matrices)}, ops_controlled_wires_{std::move(ops_controlled_wires)}, ops_controlled_values_{std::move(ops_controlled_values)} { for (const auto &p : ops_params) { @@ -105,8 +105,8 @@ template class OpsData { std::vector> ops_matrices) : num_par_ops_{0}, ops_name_{std::move(ops_name)}, ops_params_{ops_params}, ops_wires_{std::move(ops_wires)}, - ops_inverses_{std::move(ops_inverses)}, ops_matrices_{std::move( - ops_matrices)}, + ops_inverses_{std::move(ops_inverses)}, + ops_matrices_{std::move(ops_matrices)}, ops_controlled_wires_(ops_name.size()), ops_controlled_values_(ops_name.size()) { for (const auto &p : ops_params) { @@ -130,8 +130,8 @@ template class OpsData { std::vector> ops_wires, std::vector ops_inverses) : num_par_ops_{0}, ops_name_{ops_name}, ops_params_{ops_params}, - ops_wires_{std::move(ops_wires)}, ops_inverses_{std::move( - ops_inverses)}, + ops_wires_{std::move(ops_wires)}, + ops_inverses_{std::move(ops_inverses)}, ops_matrices_(ops_name.size()), ops_controlled_wires_(ops_name.size()), ops_controlled_values_(ops_name.size()) { diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp index 3586147b43..8130faf439 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp @@ -1161,6 +1161,19 @@ void applyGlobalPhase(Kokkos::View *> arr_, KOKKOS_LAMBDA(const std::size_t k) { arr_(k) *= phase; }); } +template +void applyPCPhase(Kokkos::View *> arr_, + const std::size_t num_qubits, + [[maybe_unused]] const std::vector &wires, + const bool inverse = false, + const std::vector ¶ms = {}) { + const Kokkos::complex phase = Kokkos::exp( + Kokkos::complex{0, (inverse) ? params[0] : -params[0]}); + Kokkos::parallel_for( + Kokkos::RangePolicy(0, exp2(num_qubits)), + KOKKOS_LAMBDA(const std::size_t k) { arr_(k) *= phase; }); +} + template void applyNamedOperation(const GateOperation gateop, Kokkos::View *> arr_, @@ -1277,6 +1290,9 @@ void applyNamedOperation(const GateOperation gateop, applyGlobalPhase(arr_, num_qubits, wires, inverse, params); return; + case GateOperation::PCPhase: + applyPCPhase(arr_, num_qubits, wires, inverse, params); + return; case GateOperation::MultiRZ: applyMultiRZ(arr_, num_qubits, wires, inverse, params); return; diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp index bde761ccc3..78521ebe8b 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp @@ -262,8 +262,8 @@ class StateVectorLQubit : public StateVectorBase { protected: explicit StateVectorLQubit(std::size_t num_qubits, Threading threading, CPUMemoryModel memory_model) - : BaseType(num_qubits), threading_{threading}, memory_model_{ - memory_model} { + : BaseType(num_qubits), threading_{threading}, + memory_model_{memory_model} { setKernels(num_qubits, threading, memory_model); } diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/RegisterKernel.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/RegisterKernel.hpp index 294d5b35ed..4974541f25 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/RegisterKernel.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/RegisterKernel.hpp @@ -232,8 +232,9 @@ constexpr auto constructControlledMatrixOpsFunctorTupleIter() { * @tparam GateImplementation Gate implementation class. */ template -constexpr auto gate_op_functor_tuple = constructGateOpsFunctorTupleIter< - PrecisionT, ParamT, GateImplementation, 0>(); +constexpr auto gate_op_functor_tuple = + constructGateOpsFunctorTupleIter(); /** * @brief Tuple of controlled gate operation and function pointer pairs. diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp index 6cd5336d71..2c2f4d9cf3 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp @@ -1884,7 +1884,6 @@ class GateImplementationsLM : public PauliGenerator { const std::array, 2> shifts = { (inverse) ? std::conj(first) : first, (inverse) ? std::conj(second) : second}; - std::size_t wires_parity{0U}; for (std::size_t wire : wires) { wires_parity |= diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX2Concept.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX2Concept.hpp index 0f130a7422..1a29403dfe 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX2Concept.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX2Concept.hpp @@ -30,8 +30,12 @@ namespace Internal { template struct AVX2Intrinsic { static_assert(std::is_same_v || std::is_same_v); }; -template <> struct AVX2Intrinsic { using Type = __m256; }; -template <> struct AVX2Intrinsic { using Type = __m256d; }; +template <> struct AVX2Intrinsic { + using Type = __m256; +}; +template <> struct AVX2Intrinsic { + using Type = __m256d; +}; } // namespace Internal ///@endcond diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX512Concept.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX512Concept.hpp index fbd8b2e5de..279a2adfac 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX512Concept.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVX512Concept.hpp @@ -31,8 +31,12 @@ namespace Internal { template struct AVX512Intrinsic { static_assert(std::is_same_v || std::is_same_v); }; -template <> struct AVX512Intrinsic { using Type = __m512; }; -template <> struct AVX512Intrinsic { using Type = __m512d; }; +template <> struct AVX512Intrinsic { + using Type = __m512; +}; +template <> struct AVX512Intrinsic { + using Type = __m512d; +}; } // namespace Internal ///@endcond diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVXConceptType.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVXConceptType.hpp index 3eb859534f..8e39c1c985 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVXConceptType.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/AVXConceptType.hpp @@ -31,12 +31,18 @@ namespace Pennylane::LightningQubit::Gates::AVXCommon { template struct AVXConcept; #ifdef PL_USE_AVX2 -template <> struct AVXConcept { using Type = AVX2Concept; }; -template <> struct AVXConcept { using Type = AVX2Concept; }; +template <> struct AVXConcept { + using Type = AVX2Concept; +}; +template <> struct AVXConcept { + using Type = AVX2Concept; +}; #endif #ifdef PL_USE_AVX512F -template <> struct AVXConcept { using Type = AVX512Concept; }; +template <> struct AVXConcept { + using Type = AVX512Concept; +}; template <> struct AVXConcept { using Type = AVX512Concept; }; diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp index db75f9c933..fdc3d873a9 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp @@ -136,7 +136,7 @@ concept TwoQubitGateWithParam = template concept TwoQubitGateWithoutParam = SymmetricTwoQubitGateWithoutParam || - AsymmetricTwoQubitGateWithoutParam; + AsymmetricTwoQubitGateWithoutParam; namespace Internal { // InternalInternal for two qubit gates with param begin @@ -326,7 +326,7 @@ constexpr auto InternalExternalFunctions() -> decltype(auto) { * @brief A helper class for two-qubit gate without parameters. */ template -requires TwoQubitGateWithoutParam + requires TwoQubitGateWithoutParam class TwoQubitGateWithoutParamHelper { public: using Precision = typename AVXImpl::Precision; @@ -451,7 +451,7 @@ class TwoQubitGateWithoutParamHelper { * @brief A helper class for two-qubit gate without parameters. */ template -requires TwoQubitGateWithParam + requires TwoQubitGateWithParam class TwoQubitGateWithParamHelper { public: using Precision = typename AVXImpl::Precision; diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_KernelMap.cpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_KernelMap.cpp index d4ee304f62..d5567e3415 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_KernelMap.cpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_KernelMap.cpp @@ -195,7 +195,7 @@ TEST_CASE("Test KernelMap is consistent in extreme usecase", "[KernelMap]") { #ifdef _OPENMP #pragma omp parallel default(none) \ shared(instance, records, rd, num_qubits, threadings, memory_models) \ - firstprivate(num_iter) + firstprivate(num_iter) #endif { std::mt19937 re; diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/measurements/MeasurementKernels.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/measurements/MeasurementKernels.hpp index 3fc5e7d4e9..b401ee4234 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/measurements/MeasurementKernels.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/measurements/MeasurementKernels.hpp @@ -469,7 +469,7 @@ auto probs_bitshift(const std::complex *arr, std::vector probabilities(n_probs, 0); auto *probs = probabilities.data(); #if defined PL_LQ_KERNEL_OMP && defined _OPENMP -#pragma omp parallel for reduction(+ : probs[:n_probs]) +#pragma omp parallel for reduction(+ : probs[ : n_probs]) #endif for (std::size_t k = 0; k < exp2(num_qubits - n_wires); k++) { std::size_t i0; diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/utils/LinearAlgebra.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/utils/LinearAlgebra.hpp index a4d2664037..ca1724c190 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/utils/LinearAlgebra.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/utils/LinearAlgebra.hpp @@ -93,8 +93,7 @@ omp_innerProd(const std::complex *v1, const std::complex *v2, } #pragma omp parallel for num_threads(nthreads) default(none) \ - shared(v1, v2, data_size) reduction(sm \ - : result) + shared(v1, v2, data_size) reduction(sm : result) #endif for (std::size_t i = 0; i < data_size; i++) { result = ConstSum(result, ConstMult(*(v1 + i), *(v2 + i))); @@ -168,8 +167,7 @@ omp_innerProdC(const std::complex *v1, const std::complex *v2, #if defined(_OPENMP) #pragma omp parallel for num_threads(nthreads) default(none) \ - shared(v1, v2, data_size) reduction(sm \ - : result) + shared(v1, v2, data_size) reduction(sm : result) #endif for (std::size_t i = 0; i < data_size; i++) { result = ConstSum(result, ConstMultConj(*(v1 + i), *(v2 + i))); diff --git a/pennylane_lightning/core/src/utils/TypeTraits.hpp b/pennylane_lightning/core/src/utils/TypeTraits.hpp index 152184dd8a..d07011b838 100644 --- a/pennylane_lightning/core/src/utils/TypeTraits.hpp +++ b/pennylane_lightning/core/src/utils/TypeTraits.hpp @@ -20,7 +20,9 @@ #include namespace Pennylane::Util { -template struct remove_complex { using type = T; }; +template struct remove_complex { + using type = T; +}; template struct remove_complex> { using type = T; }; @@ -54,6 +56,8 @@ template struct FuncReturn { template struct FuncReturn { using Type = R; }; -template struct FuncReturn { using Type = R; }; +template struct FuncReturn { + using Type = R; +}; } // namespace Pennylane::Util diff --git a/pennylane_lightning/core/src/utils/cuda_utils/DataBuffer.hpp b/pennylane_lightning/core/src/utils/cuda_utils/DataBuffer.hpp index a81802d814..d1df1cc7cf 100644 --- a/pennylane_lightning/core/src/utils/cuda_utils/DataBuffer.hpp +++ b/pennylane_lightning/core/src/utils/cuda_utils/DataBuffer.hpp @@ -48,8 +48,8 @@ template class DataBuffer { DataBuffer(std::size_t length, int device_id = 0, cudaStream_t stream_id = 0, bool alloc_memory = true) - : length_{length}, dev_tag_{device_id, stream_id}, gpu_buffer_{ - nullptr} { + : length_{length}, dev_tag_{device_id, stream_id}, + gpu_buffer_{nullptr} { if (alloc_memory && (length > 0)) { dev_tag_.refresh(); PL_CUDA_IS_SUCCESS( diff --git a/pennylane_lightning/lightning_gpu/lightning_gpu.py b/pennylane_lightning/lightning_gpu/lightning_gpu.py index 08d79c1473..4d7d50c804 100644 --- a/pennylane_lightning/lightning_gpu/lightning_gpu.py +++ b/pennylane_lightning/lightning_gpu/lightning_gpu.py @@ -130,6 +130,8 @@ def _mebibytesToBytes(mebibytes): "MultiRZ", "GlobalPhase", "C(GlobalPhase)", + "PCPhase", + "C(PCPhase)", "Hadamard", "S", "Adjoint(S)", diff --git a/pennylane_lightning/lightning_gpu/lightning_gpu.toml b/pennylane_lightning/lightning_gpu/lightning_gpu.toml index 003b248fa4..35f224ecf4 100644 --- a/pennylane_lightning/lightning_gpu/lightning_gpu.toml +++ b/pennylane_lightning/lightning_gpu/lightning_gpu.toml @@ -60,6 +60,7 @@ MultiControlledX = {} BlockEncode = {properties = [ "controllable" ]} GlobalPhase = {properties = [ "controllable" ]} +PCPhase = {properties = [ "controllable" ]} ControlledQubitUnitary = {} ECR = {} SX = {} diff --git a/pennylane_lightning/lightning_kokkos/_measurements.py b/pennylane_lightning/lightning_kokkos/_measurements.py index 6e706614ba..b438af350c 100644 --- a/pennylane_lightning/lightning_kokkos/_measurements.py +++ b/pennylane_lightning/lightning_kokkos/_measurements.py @@ -46,7 +46,6 @@ def __init__( self, kokkos_state, ) -> None: - super().__init__(kokkos_state) self._measurement_lightning = self._measurement_dtype()(kokkos_state.state_vector) diff --git a/pennylane_lightning/lightning_kokkos/_state_vector.py b/pennylane_lightning/lightning_kokkos/_state_vector.py index 5e76249de0..dda40ffadb 100644 --- a/pennylane_lightning/lightning_kokkos/_state_vector.py +++ b/pennylane_lightning/lightning_kokkos/_state_vector.py @@ -64,7 +64,6 @@ def __init__( kokkos_args=None, sync=True, ): # pylint: disable=too-many-arguments - super().__init__(num_wires, dtype) self._device_name = "lightning.kokkos" @@ -280,7 +279,6 @@ def _apply_lightning( elif isinstance(operation, qml.ops.Controlled) and isinstance( operation.base, qml.GlobalPhase ): # apply n-controlled gate - # Kokkos do not support the controlled gates except for GlobalPhase self._apply_lightning_controlled(operation) else: # apply gate as a matrix diff --git a/pennylane_lightning/lightning_kokkos/lightning_kokkos.py b/pennylane_lightning/lightning_kokkos/lightning_kokkos.py index 4089b3aca7..3690417265 100644 --- a/pennylane_lightning/lightning_kokkos/lightning_kokkos.py +++ b/pennylane_lightning/lightning_kokkos/lightning_kokkos.py @@ -78,6 +78,8 @@ "MultiRZ", "GlobalPhase", "C(GlobalPhase)", + "PCPhase", + "C(PCPhase)", "Hadamard", "S", "Adjoint(S)", diff --git a/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml b/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml index 0ede05a262..f74fbeee04 100644 --- a/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml +++ b/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml @@ -58,7 +58,8 @@ ControlledQubitUnitary = {} # Gates which should be translated to QubitUnitary [operators.gates.matrix] -BlockEncode = {} +BlockEncode = {properties = [ "controllable" ]} +PCPhase = {properties = [ "controllable" ]} DiagonalQubitUnitary = {} ECR = {} ISWAP = {} diff --git a/pennylane_lightning/lightning_qubit/_measurements.py b/pennylane_lightning/lightning_qubit/_measurements.py index f762fcb7e6..c1b97a1184 100644 --- a/pennylane_lightning/lightning_qubit/_measurements.py +++ b/pennylane_lightning/lightning_qubit/_measurements.py @@ -58,7 +58,6 @@ def __init__( kernel_name: str = None, num_burnin: int = None, ) -> None: - super().__init__(qubit_state) self._mcmc = mcmc diff --git a/pennylane_lightning/lightning_qubit/_state_vector.py b/pennylane_lightning/lightning_qubit/_state_vector.py index 0a8b0b7d6d..b4b6ef5ff1 100644 --- a/pennylane_lightning/lightning_qubit/_state_vector.py +++ b/pennylane_lightning/lightning_qubit/_state_vector.py @@ -51,7 +51,6 @@ class LightningStateVector(LightningBaseStateVector): # pylint: disable=too-few """ def __init__(self, num_wires, dtype=np.complex128): - super().__init__(num_wires, dtype) self._device_name = "lightning.qubit" diff --git a/tests/lightning_qubit/test_jacobian_method.py b/tests/lightning_qubit/test_jacobian_method.py index 745feee502..c636cbc77f 100644 --- a/tests/lightning_qubit/test_jacobian_method.py +++ b/tests/lightning_qubit/test_jacobian_method.py @@ -51,7 +51,6 @@ def calculate_reference(tape, execute_and_derivatives=False): @staticmethod def process_and_execute(statevector, tape, execute_and_derivatives=False): - wires = statevector.num_wires device = LightningDevice(wires) if execute_and_derivatives: diff --git a/tests/test_adjoint_jacobian.py b/tests/test_adjoint_jacobian.py index 83713b1c69..1eb06a0d91 100644 --- a/tests/test_adjoint_jacobian.py +++ b/tests/test_adjoint_jacobian.py @@ -1550,7 +1550,9 @@ def test_qubit_unitary(n_targets): init_state = np.random.rand(2**n_wires) + 1j * np.random.rand(2**n_wires) init_state /= np.linalg.norm(init_state) init_state = np.array(init_state, requires_grad=False) - U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand(2**n_targets, 2**n_targets) + U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand( + 2**n_targets, 2**n_targets + ) U, _ = np.linalg.qr(U) U = np.array(U, requires_grad=False) @@ -1592,7 +1594,9 @@ def test_diff_qubit_unitary(n_targets): init_state = np.random.rand(2**n_wires) + 1j * np.random.rand(2**n_wires) init_state /= np.linalg.norm(init_state) init_state = np.array(init_state, requires_grad=False) - U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand(2**n_targets, 2**n_targets) + U = np.random.rand(2**n_targets, 2**n_targets) + 1j * np.random.rand( + 2**n_targets, 2**n_targets + ) U, _ = np.linalg.qr(U) U = np.array(U, requires_grad=False) diff --git a/tests/test_native_mcm.py b/tests/test_native_mcm.py index df5ba6cb43..07281fb48a 100644 --- a/tests/test_native_mcm.py +++ b/tests/test_native_mcm.py @@ -90,7 +90,6 @@ def func(x, y): ): func(*params) if device_name == "lightning.kokkos": - with pytest.raises( qml.DeviceError, match=r"Measurement shadow\(wires=\[0\]\) not accepted with finite shots on "