From 229359ff9b0d12ca5471a8a731211d136bb7e342 Mon Sep 17 00:00:00 2001 From: Sergei Mironov Date: Thu, 9 May 2024 19:31:53 +0400 Subject: [PATCH 1/2] Update device toml specs to schema 2 (#642) * Update device toml specs * Auto update version * Auto update version * Fix missing Projector observable in the PL/kokkos device * Auto update version * Update formatting * Remove Projector from lightning_qubit.toml as this is not natively supported in this device * Remove non-native observables * Auto update version * trigger ci * Update pennylane_lightning/lightning_kokkos/lightning_kokkos.toml Co-authored-by: Vincent Michaud-Rioux * Update obs order in toml * trigger ci * Auto update version * Auto update version * trigger ci * Auto update version * Apply review suggestions: mark Rot/QubitUnitary as non-differentiable * Apply review suggestions: mark Rot/QubitUnitary as non-differentiable * Auto update version * Auto update version * Update pennylane_lightning/lightning_kokkos/lightning_kokkos.toml Co-authored-by: David Ittah * Auto update version * Address review suggestions: declare kokkos observables as differentiable * Update cuda quantum toml file * Auto update version from '0.36.0-dev30' to '0.36.0-dev36' * Update lightning_gpu toml file * Run Catalyst check; put a number of fixmes * Update pennylane_lightning/lightning_qubit/lightning_qubit.toml Co-authored-by: Romain Moyard * Update pennylane_lightning/lightning_gpu/lightning_gpu.toml Co-authored-by: Romain Moyard * Auto update version from '0.36.0-dev36' to '0.36.0-dev46' * Auto update version from '0.36.0-dev45' to '0.36.0-dev46' * Add a todo notice * Move CPhase close to ControlledPhaseShitf * Auto update version from '0.36.0-dev46' to '0.36.0-dev47' * Remove fixmes * Remove CPhase and mark GlobalPhase as non-controllable on kokkos * Auto update version from '0.36.0-dev47' to '0.36.0-dev48' * Auto update version from '0.36.0-dev48' to '0.36.0-dev49' --------- Co-authored-by: Dev version update bot Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com> Co-authored-by: Vincent Michaud-Rioux Co-authored-by: David Ittah Co-authored-by: ringo-but-quantum Co-authored-by: Romain Moyard --- pennylane_lightning/core/_version.py | 2 +- .../lightning_gpu/lightning_gpu.toml | 180 ++++++++--------- .../lightning_kokkos/lightning_kokkos.toml | 186 ++++++++---------- .../lightning_qubit/lightning_qubit.toml | 182 ++++++++--------- 4 files changed, 249 insertions(+), 301 deletions(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 82031f4caa..b46423dcc8 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.37.0-dev3" +__version__ = "0.37.0-dev4" diff --git a/pennylane_lightning/lightning_gpu/lightning_gpu.toml b/pennylane_lightning/lightning_gpu/lightning_gpu.toml index 537d3c7c4e..85511ca78a 100644 --- a/pennylane_lightning/lightning_gpu/lightning_gpu.toml +++ b/pennylane_lightning/lightning_gpu/lightning_gpu.toml @@ -1,121 +1,103 @@ -schema = 1 - -[device] -name = "lightning.gpu" - -[operators] -# Observables supported by the device -observables = [ - "PauliX", - "PauliY", - "PauliZ", - "Hadamard", - "Hermitian", - "Identity", - "SparseHamiltonian", - "Hamiltonian", - "Sum", - "SProd", - "Prod", - "Exp", -] +# TODO: verify the contents of this file against what the device reports. +schema = 2 # The union of all gate types listed in this section must match what # the device considers "supported" through PennyLane's device API. -[[operators.gates]] -native = [ - "Identity", - "PauliX", - "PauliY", - "PauliZ", - "Hadamard", - "S", - "T", - "PhaseShift", - "RX", - "RY", - "RZ", - "Rot", - "CNOT", - "CY", - "CZ", - "SWAP", - "CSWAP", - "Toffoli", - "IsingXX", - "IsingXY", - "IsingYY", - "IsingZZ", - "ControlledPhaseShift", - "CRX", - "CRY", - "CRZ", - "CRot", - "SingleExcitation", - "SingleExcitationPlus", - "SingleExcitationMinus", - "DoubleExcitation", - "DoubleExcitationPlus", - "DoubleExcitationMinus", - "MultiRZ", - "QubitUnitary", - "GlobalPhase", -] +[operators.gates.native] + +Identity = { properties = [ "differentiable" ] } +PauliX = { properties = [ "differentiable" ] } +PauliY = { properties = [ "differentiable" ] } +PauliZ = { properties = [ "differentiable" ] } +Hadamard = { properties = [ "differentiable" ] } +S = { properties = [ "differentiable" ] } +T = { properties = [ "differentiable" ] } +PhaseShift = { properties = [ "differentiable" ] } +RX = { properties = [ "differentiable" ] } +RY = { properties = [ "differentiable" ] } +RZ = { properties = [ "differentiable" ] } +Rot = { properties = [ "differentiable" ] } +CNOT = { properties = [ "differentiable" ] } +CY = { properties = [ "differentiable" ] } +CZ = { properties = [ "differentiable" ] } +SWAP = { properties = [ "differentiable" ] } +CSWAP = { properties = [ "differentiable" ] } +Toffoli = { properties = [ "differentiable" ] } +IsingXX = { properties = [ "differentiable" ] } +IsingXY = { properties = [ "differentiable" ] } +IsingYY = { properties = [ "differentiable" ] } +IsingZZ = { properties = [ "differentiable" ] } +ControlledPhaseShift = { properties = [ "differentiable" ] } +CRX = { properties = [ "differentiable" ] } +CRY = { properties = [ "differentiable" ] } +CRZ = { properties = [ "differentiable" ] } +CRot = { properties = [ "differentiable" ] } +SingleExcitation = { properties = [ "differentiable" ] } +SingleExcitationPlus = { properties = [ "differentiable" ] } +SingleExcitationMinus = { properties = [ "differentiable" ] } +DoubleExcitation = { properties = [ "differentiable" ] } +DoubleExcitationPlus = { properties = [ "differentiable" ] } +DoubleExcitationMinus = { properties = [ "differentiable" ] } +MultiRZ = { properties = [ "differentiable" ] } +QubitUnitary = { properties = [ "differentiable" ] } +GlobalPhase = { properties = [ "differentiable" ] } # Operators that should be decomposed according to the algorithm used # by PennyLane's device API. # Optional, since gates not listed in this list will typically be decomposed by # default, but can be useful to express a deviation from this device's regular # strategy in PennyLane. -decomp = [ - "BasisState", - "QFT", - "QubitStateVector", - "StatePrep", - "MultiControlledX", -] +[operators.gates.decomp] + +BasisState = {} +QFT = {} +QubitStateVector = {} +StatePrep = {} +MultiControlledX = {} # Gates which should be translated to QubitUnitary -matrix = [ - "ControlledQubitUnitary", - "ECR", - "SX", - "ISWAP", - "PSWAP", - "SISWAP", - "SQISW", - "CPhase", - "OrbitalRotation", - "QubitCarry", - "QubitSum", - "DiagonalQubitUnitary", - "BlockEncode", -] +[operators.gates.matrix] + + +ControlledQubitUnitary = {} +ECR = {} +SX = {} +ISWAP = {} +PSWAP = {} +SISWAP = {} +SQISW = {} +OrbitalRotation = {} +QubitCarry = {} +QubitSum = {} +DiagonalQubitUnitary = {} +BlockEncode = {} + +# Observables supported by the device +[operators.observables] + +Identity = {} +PauliX = {} +PauliY = {} +PauliZ = {} +Hadamard = {} +Hermitian = {} +Hamiltonian = {} +SparseHamiltonian = {} [measurement_processes] -exactshots = [ - "Expval", - "Var", - "Probs", - "State", -] -finiteshots = [ - "Expval", - "Var", - "Probs", - "Sample", - "Counts", -] + +Expval = {} +Var = {} +Probs = {} +State = { condition = [ "analytic" ] } +Sample = { condition = [ "finiteshots" ] } +Counts = { condition = [ "finiteshots" ] } [compilation] # If the device is compatible with qjit qjit_compatible = false # If the device requires run time generation of the quantum circuit. runtime_code_generation = false -# If the device supports adjoint -quantum_adjoint = false -# If the device supports quantum control instructions natively -quantum_control = false # If the device supports mid circuit measurements natively mid_circuit_measurement = false diff --git a/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml b/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml index e4cf01a526..7238194941 100644 --- a/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml +++ b/pennylane_lightning/lightning_kokkos/lightning_kokkos.toml @@ -1,125 +1,109 @@ -schema = 1 - -[device] -name = "lightning.kokkos" - -[operators] -# Observables supported by the device -observables = [ - "PauliX", - "PauliY", - "PauliZ", - "Hadamard", - "Hermitian", - "Identity", - "SparseHamiltonian", - "Hamiltonian", - "Sum", - "SProd", - "Prod", - "Exp", - "LinearCombination", -] +schema = 2 # The union of all gate types listed in this section must match what # the device considers "supported" through PennyLane's device API. -[[operators.gates]] -native = [ - "Identity", - "PauliX", - "PauliY", - "PauliZ", - "Hadamard", - "S", - "T", - "PhaseShift", - "RX", - "RY", - "RZ", - "Rot", - "CNOT", - "CY", - "CZ", - "SWAP", - "CSWAP", - "Toffoli", - "IsingXX", - "IsingXY", - "IsingYY", - "IsingZZ", - "ControlledPhaseShift", - "CRX", - "CRY", - "CRZ", - "CRot", - "SingleExcitation", - "SingleExcitationPlus", - "SingleExcitationMinus", - "DoubleExcitation", - "DoubleExcitationPlus", - "DoubleExcitationMinus", - "MultiRZ", - "QubitUnitary", - "GlobalPhase", -] +[operators.gates.native] + +CNOT = { properties = [ "invertible", "differentiable" ] } +ControlledPhaseShift = { properties = [ "invertible", "differentiable" ] } +ControlledQubitUnitary = { properties = [ "invertible", ] } +CRot = { properties = [ "invertible" ] } +CRX = { properties = [ "invertible", "differentiable" ] } +CRY = { properties = [ "invertible", "differentiable" ] } +CRZ = { properties = [ "invertible", "differentiable" ] } +CSWAP = { properties = [ "invertible", "differentiable" ] } +CY = { properties = [ "invertible", "differentiable" ] } +CZ = { properties = [ "invertible", "differentiable" ] } +DoubleExcitationMinus = { properties = [ "invertible", "differentiable" ] } +DoubleExcitationPlus = { properties = [ "invertible", "differentiable" ] } +DoubleExcitation = { properties = [ "invertible", "differentiable" ] } +GlobalPhase = { properties = [ "invertible", "differentiable" ] } +Hadamard = { properties = [ "invertible", "differentiable" ] } +Identity = { properties = [ "invertible", "differentiable" ] } +IsingXX = { properties = [ "invertible", "differentiable" ] } +IsingXY = { properties = [ "invertible", "differentiable" ] } +IsingYY = { properties = [ "invertible", "differentiable" ] } +IsingZZ = { properties = [ "invertible", "differentiable" ] } +MultiRZ = { properties = [ "invertible", "differentiable" ] } +PauliX = { properties = [ "invertible", "differentiable" ] } +PauliY = { properties = [ "invertible", "differentiable" ] } +PauliZ = { properties = [ "invertible", "differentiable" ] } +PhaseShift = { properties = [ "invertible", "differentiable" ] } +QubitUnitary = { properties = [ "invertible", ] } +Rot = { properties = [ "invertible", ] } +RX = { properties = [ "invertible", "differentiable" ] } +RY = { properties = [ "invertible", "differentiable" ] } +RZ = { properties = [ "invertible", "differentiable" ] } +SingleExcitationMinus = { properties = [ "invertible", "differentiable" ] } +SingleExcitationPlus = { properties = [ "invertible", "differentiable" ] } +SingleExcitation = { properties = [ "invertible", "differentiable" ] } +S = { properties = [ "invertible", "differentiable" ] } +SWAP = { properties = [ "invertible", "differentiable" ] } +Toffoli = { properties = [ "invertible", "differentiable" ] } +T = { properties = [ "invertible", "differentiable" ] } # Operators that should be decomposed according to the algorithm used # by PennyLane's device API. # Optional, since gates not listed in this list will typically be decomposed by # default, but can be useful to express a deviation from this device's regular # strategy in PennyLane. -decomp = [ - "BasisState", - "QubitStateVector", - "StatePrep", - "QFT", - "MultiControlledX", -] +[operators.gates.decomp] + +BasisState = {} +MultiControlledX = {} +QFT = {} +QubitStateVector = {} +StatePrep = {} # Gates which should be translated to QubitUnitary -matrix = [ - "ControlledQubitUnitary", - "ECR", - "SX", - "ISWAP", - "PSWAP", - "SISWAP", - "SQISW", - "CPhase", - "OrbitalRotation", - "QubitCarry", - "QubitSum", - "DiagonalQubitUnitary", - "BlockEncode", -] +[operators.gates.matrix] + +BlockEncode = {} +DiagonalQubitUnitary = {} +ECR = {} +ISWAP = {} +OrbitalRotation = {} +PSWAP = {} +QubitCarry = {} +QubitSum = {} +SISWAP = {} +SQISW = {} +SX = {} + +# Observables supported by the device +[operators.observables] + +Identity = { properties = [ "differentiable" ] } +PauliX = { properties = [ "differentiable" ] } +PauliY = { properties = [ "differentiable" ] } +PauliZ = { properties = [ "differentiable" ] } +Hadamard = { properties = [ "differentiable" ] } +Hermitian = { properties = [ "differentiable" ] } +Hamiltonian = { properties = [ "differentiable" ] } +SparseHamiltonian = { properties = [ "differentiable" ] } +Sum = { properties = [ "differentiable" ] } +SProd = { properties = [ "differentiable" ] } +Prod = { properties = [ "differentiable" ] } +Exp = { properties = [ "differentiable" ] } +LinearCombination = { properties = [ "differentiable" ] } [measurement_processes] -exactshots = [ - "Expval", - "Var", - "Probs", - "State", -] -finiteshots = [ - "Expval", - "Var", - "Probs", - "Sample", - "Counts", -] + +Expval = {} +Var = {} +Probs = {} +State = { condition = [ "analytic" ] } +Sample = { condition = [ "finiteshots" ] } +Counts = { condition = [ "finiteshots" ] } [compilation] + # If the device is compatible with qjit qjit_compatible = true # If the device requires run time generation of the quantum circuit. runtime_code_generation = false -# If the device supports adjoint -quantum_adjoint = true -# If the device supports quantum control instructions natively -quantum_control = false # If the device supports mid circuit measurements natively mid_circuit_measurement = true - # This field is currently unchecked but it is reserved for the purpose of # determining if the device supports dynamic qubit allocation/deallocation. dynamic_qubit_management = false diff --git a/pennylane_lightning/lightning_qubit/lightning_qubit.toml b/pennylane_lightning/lightning_qubit/lightning_qubit.toml index d9deb149e2..d4c8e5f325 100644 --- a/pennylane_lightning/lightning_qubit/lightning_qubit.toml +++ b/pennylane_lightning/lightning_qubit/lightning_qubit.toml @@ -1,129 +1,111 @@ -schema = 1 +schema = 2 -[device] -name = "lightning.qubit" +[operators.gates.native] -[operators] -# Observables supported by the device -observables = [ - "PauliX", - "PauliY", - "PauliZ", - "Hadamard", - "Hermitian", - "Identity", - "Projector", - "SparseHamiltonian", - "Hamiltonian", - "Sum", - "SProd", - "Prod", - "Exp", - "LinearCombination", -] +CNOT = { properties = [ "invertible", "differentiable" ] } +ControlledPhaseShift = { properties = [ "invertible", "differentiable" ] } +ControlledQubitUnitary = { properties = [ "invertible", ] } +CRot = { properties = [ "invertible" ] } +CRX = { properties = [ "invertible", "differentiable" ] } +CRY = { properties = [ "invertible", "differentiable" ] } +CRZ = { properties = [ "invertible", "differentiable" ] } +CSWAP = { properties = [ "invertible", "differentiable" ] } +CY = { properties = [ "invertible", "differentiable" ] } +CZ = { properties = [ "invertible", "differentiable" ] } +DoubleExcitationMinus = { properties = [ "invertible", "controllable", "differentiable" ] } +DoubleExcitationPlus = { properties = [ "invertible", "controllable", "differentiable" ] } +DoubleExcitation = { properties = [ "invertible", "controllable", "differentiable" ] } +GlobalPhase = { properties = [ "invertible", "controllable", "differentiable" ] } +Hadamard = { properties = [ "invertible", "controllable", "differentiable" ] } +Identity = { properties = [ "invertible", "differentiable" ] } +IsingXX = { properties = [ "invertible", "controllable", "differentiable" ] } +IsingXY = { properties = [ "invertible", "controllable", "differentiable" ] } +IsingYY = { properties = [ "invertible", "controllable", "differentiable" ] } +IsingZZ = { properties = [ "invertible", "controllable", "differentiable" ] } +MultiRZ = { properties = [ "invertible", "controllable", "differentiable" ] } +PauliX = { properties = [ "invertible", "controllable", "differentiable" ] } +PauliY = { properties = [ "invertible", "controllable", "differentiable" ] } +PauliZ = { properties = [ "invertible", "controllable", "differentiable" ] } +PhaseShift = { properties = [ "invertible", "controllable", "differentiable" ] } +QubitUnitary = { properties = [ "invertible", ] } +Rot = { properties = [ "invertible", "controllable", ] } +RX = { properties = [ "invertible", "controllable", "differentiable" ] } +RY = { properties = [ "invertible", "controllable", "differentiable" ] } +RZ = { properties = [ "invertible", "controllable", "differentiable" ] } +SingleExcitationMinus = { properties = [ "invertible", "controllable", "differentiable" ] } +SingleExcitationPlus = { properties = [ "invertible", "controllable", "differentiable" ] } +SingleExcitation = { properties = [ "invertible", "controllable", "differentiable" ] } +S = { properties = [ "invertible", "controllable", "differentiable" ] } +SWAP = { properties = [ "invertible", "controllable", "differentiable" ] } +Toffoli = { properties = [ "invertible", "differentiable" ] } +T = { properties = [ "invertible", "controllable", "differentiable" ] } -# The union of all gate types listed in this section must match what -# the device considers "supported" through PennyLane's device API. -[[operators.gates]] -native = [ - # Operators that shouldn't be decomposed. - "Identity", - "PauliX", - "PauliY", - "PauliZ", - "Hadamard", - "S", - "T", - "PhaseShift", - "RX", - "RY", - "RZ", - "Rot", - "CNOT", - "CY", - "CZ", - "SWAP", - "CSWAP", - "Toffoli", - "IsingXX", - "IsingXY", - "IsingYY", - "IsingZZ", - "ControlledPhaseShift", - "CRX", - "CRY", - "CRZ", - "CRot", - "SingleExcitation", - "SingleExcitationPlus", - "SingleExcitationMinus", - "DoubleExcitation", - "DoubleExcitationPlus", - "DoubleExcitationMinus", - "MultiRZ", - "QubitUnitary", - "GlobalPhase", -] +[operators.gates.decomp] # Operators that should be decomposed according to the algorithm used # by PennyLane's device API. # Optional, since gates not listed in this list will typically be decomposed by # default, but can be useful to express a deviation from this device's regular # strategy in PennyLane. -decomp = [ - "QFT", - "MultiControlledX", -] +MultiControlledX = {} +QFT = {} # Gates which should be translated to QubitUnitary -matrix = [ - "ControlledQubitUnitary", - "ECR", - "SX", - "ISWAP", - "PSWAP", - "SISWAP", - "SQISW", - "CPhase", - "OrbitalRotation", - "QubitCarry", - "QubitSum", - "DiagonalQubitUnitary", - "BlockEncode", -] +[operators.gates.matrix] + +BlockEncode = {} +DiagonalQubitUnitary = {} +ECR = {} +ISWAP = {} +OrbitalRotation = {} +PSWAP = {} +QubitCarry = {} +QubitSum = {} +SISWAP = {} +SQISW = {} +SX = {} + +# Observables supported by the device +[operators.observables] + +Identity = { properties = [ "differentiable" ] } +PauliX = { properties = [ "differentiable" ] } +PauliY = { properties = [ "differentiable" ] } +PauliZ = { properties = [ "differentiable" ] } +Hadamard = { properties = [ "differentiable" ] } +Hermitian = { properties = [ "differentiable" ] } +Hamiltonian = { properties = [ "differentiable" ] } +SparseHamiltonian = { properties = [ "differentiable" ] } +Projector = { properties = [ "differentiable" ] } +Sum = { properties = [ "differentiable" ] } +SProd = { properties = [ "differentiable" ] } +Prod = { properties = [ "differentiable" ] } +Exp = { properties = [ "differentiable" ] } +LinearCombination = { properties = [ "differentiable" ] } [measurement_processes] -exactshots = [ - "Expval", - "Var", - "Probs", - "State", -] -finiteshots = [ - "Expval", - "Var", - "Probs", - "Sample", - "Counts", -] + +Expval = {} +Var = {} +Probs = {} +State = { condition = [ "analytic" ] } +Sample = { condition = [ "finiteshots" ] } +Counts = { condition = [ "finiteshots" ] } [compilation] + # If the device is compatible with qjit qjit_compatible = true # If the device requires run time generation of the quantum circuit. runtime_code_generation = false -# If the device supports adjoint -quantum_adjoint = true -# If the device supports quantum control instructions natively -quantum_control = true # If the device supports mid circuit measurements natively mid_circuit_measurement = true - # This field is currently unchecked but it is reserved for the purpose of # determining if the device supports dynamic qubit allocation/deallocation. dynamic_qubit_management = false [options] + mcmc = "_mcmc" num_burnin = "_num_burnin" kernel_name = "_kernel_name" From 279f7e86c03e858745e25a1c057454325b94a23d Mon Sep 17 00:00:00 2001 From: Vincent Michaud-Rioux Date: Thu, 9 May 2024 14:16:07 -0400 Subject: [PATCH 2/2] Update MCM measurements as dynamic_one_shot handles post-selection (#720) * Update LQ mcms * Auto update version from '0.37.0-dev4' to '0.37.0-dev5' * Remove mid_meas = -1 from LK. * paths-ignore _version.py --------- Co-authored-by: ringo-but-quantum --- .github/CHANGELOG.md | 3 +++ .github/workflows/tests_lgpu_python.yml | 1 + .github/workflows/tests_lgpumpi_python.yml | 1 + .github/workflows/tests_lkcpu_python.yml | 3 ++- .github/workflows/tests_lkcuda_python.yml | 1 + .github/workflows/tests_lqcpu_python.yml | 1 + pennylane_lightning/core/_version.py | 2 +- pennylane_lightning/lightning_kokkos/lightning_kokkos.py | 5 ----- pennylane_lightning/lightning_qubit/_measurements.py | 7 ------- 9 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index a55ef60238..a522237ffe 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -4,6 +4,9 @@ ### Breaking changes +* `dynamic_one_shot` deals with post-selection during the post-processing phase, so Lightning-Qubit does not return `None`-valued measurements for mismatching samples anymore. + [(#720)](https://github.com/PennyLaneAI/pennylane-lightning/pull/720) + ### Improvements * The various OpenMP configurations of Lightning-Qubit are tested in parallel on different Github Actions runners. diff --git a/.github/workflows/tests_lgpu_python.yml b/.github/workflows/tests_lgpu_python.yml index ab49c7b141..5ab6975fd0 100644 --- a/.github/workflows/tests_lgpu_python.yml +++ b/.github/workflows/tests_lgpu_python.yml @@ -15,6 +15,7 @@ on: paths-ignore: - .github - '!.github/workflows/tests_lgpu_python.yml' + - pennylane_lightning/core/_version.py - pennylane_lightning/core/src/simulators/lightning_kokkos/** - pennylane_lightning/core/src/simulators/lightning_qubit/** - pennylane_lightning/lightning_kokkos/** diff --git a/.github/workflows/tests_lgpumpi_python.yml b/.github/workflows/tests_lgpumpi_python.yml index 7f9a5e431f..3b3cecdec9 100644 --- a/.github/workflows/tests_lgpumpi_python.yml +++ b/.github/workflows/tests_lgpumpi_python.yml @@ -18,6 +18,7 @@ on: paths-ignore: - .github - '!.github/workflows/tests_lgpumpi_python.yml' + - pennylane_lightning/core/_version.py - pennylane_lightning/core/src/simulators/lightning_kokkos/** - pennylane_lightning/core/src/simulators/lightning_qubit/** - pennylane_lightning/lightning_kokkos/** diff --git a/.github/workflows/tests_lkcpu_python.yml b/.github/workflows/tests_lkcpu_python.yml index 5d405753c7..340e4e5c93 100644 --- a/.github/workflows/tests_lkcpu_python.yml +++ b/.github/workflows/tests_lkcpu_python.yml @@ -14,9 +14,10 @@ on: paths-ignore: - .github - '!.github/workflows/tests_lkcpu_python.yml' + - pennylane_lightning/core/_version.py - pennylane_lightning/core/src/simulators/lightning_gpu/** - - pennylane_lightning/lightning_gpu/** - pennylane_lightning/core/src/simulators/lightning_qubit/** + - pennylane_lightning/lightning_gpu/** - pennylane_lightning/lightning_qubit/** push: branches: diff --git a/.github/workflows/tests_lkcuda_python.yml b/.github/workflows/tests_lkcuda_python.yml index a7daef4cf1..878a1051e5 100644 --- a/.github/workflows/tests_lkcuda_python.yml +++ b/.github/workflows/tests_lkcuda_python.yml @@ -14,6 +14,7 @@ on: paths-ignore: - .github - '!.github/workflows/tests_lkcuda_python.yml' + - pennylane_lightning/core/_version.py - pennylane_lightning/core/src/simulators/lightning_gpu/** - pennylane_lightning/core/src/simulators/lightning_qubit/** - pennylane_lightning/lightning_gpu/** diff --git a/.github/workflows/tests_lqcpu_python.yml b/.github/workflows/tests_lqcpu_python.yml index 89a3869b98..7124b3f0d5 100644 --- a/.github/workflows/tests_lqcpu_python.yml +++ b/.github/workflows/tests_lqcpu_python.yml @@ -14,6 +14,7 @@ on: paths-ignore: - .github - '!.github/workflows/tests_lqcpu_python.yml' + - pennylane_lightning/core/_version.py - pennylane_lightning/core/src/simulators/lightning_gpu/** - pennylane_lightning/lightning_gpu/** - pennylane_lightning/core/src/simulators/lightning_kokkos/** diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index b46423dcc8..b3b4b3174c 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.37.0-dev4" +__version__ = "0.37.0-dev5" diff --git a/pennylane_lightning/lightning_kokkos/lightning_kokkos.py b/pennylane_lightning/lightning_kokkos/lightning_kokkos.py index 4a9eede8ef..e17f317707 100644 --- a/pennylane_lightning/lightning_kokkos/lightning_kokkos.py +++ b/pennylane_lightning/lightning_kokkos/lightning_kokkos.py @@ -393,9 +393,6 @@ def _apply_lightning_midmeasure(self, operation: MidMeasureMP, mid_measurements: wires = self.wires.indices(operation.wires) wire = list(wires)[0] sample = qml.math.reshape(self.generate_samples(shots=1), (-1,))[wire] - if operation.postselect is not None and sample != operation.postselect: - mid_measurements[operation] = -1 - return mid_measurements[operation] = sample getattr(self.state_vector, "collapse")(wire, bool(sample)) if operation.reset and bool(sample): @@ -482,8 +479,6 @@ def apply(self, operations, rotations=None, mid_measurements=None, **kwargs): ) self.apply_lightning(operations, mid_measurements=mid_measurements) - if mid_measurements is not None and any(v == -1 for v in mid_measurements.values()): - self._apply_basis_state(np.zeros(self.num_wires), wires=self.wires) # pylint: disable=protected-access def expval(self, observable, shot_range=None, bin_size=None): diff --git a/pennylane_lightning/lightning_qubit/_measurements.py b/pennylane_lightning/lightning_qubit/_measurements.py index 52d3c154b4..31a9f18179 100644 --- a/pennylane_lightning/lightning_qubit/_measurements.py +++ b/pennylane_lightning/lightning_qubit/_measurements.py @@ -307,17 +307,10 @@ def measure_with_samples( """ # last N measurements are sampling MCMs in ``dynamic_one_shot`` execution mode mps = measurements[0 : -len(mid_measurements)] if mid_measurements else measurements - skip_measure = ( - any(v == -1 for v in mid_measurements.values()) if mid_measurements else False - ) - groups, indices = _group_measurements(mps) all_res = [] for group in groups: - if skip_measure: - all_res.extend([None] * len(group)) - continue if isinstance(group[0], (ExpectationMP, VarianceMP)) and isinstance( group[0].obs, SparseHamiltonian ):