Skip to content

Commit

Permalink
Merge branch 'master' into add_MPSCutn_basis
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed May 9, 2024
2 parents a1c4ea8 + 279f7e8 commit 5be542b
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 314 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests_lgpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests_lgpumpi_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests_lkcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests_lkcuda_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests_lqcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.37.0-dev4"
__version__ = "0.37.0-dev6"
180 changes: 81 additions & 99 deletions pennylane_lightning/lightning_gpu/lightning_gpu.toml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 0 additions & 5 deletions pennylane_lightning/lightning_kokkos/lightning_kokkos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
Loading

0 comments on commit 5be542b

Please sign in to comment.