Skip to content

Commit

Permalink
Adds Catalyst specification files. (#566)
Browse files Browse the repository at this point in the history
* Adds Catalyst specification files.

* Adds path config files.

* Add file as a field to the device class.

* Changelog.

* Just use parent

* Apply suggestions from code review

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>

* Rename files.

* Remove version.

* Add lightning_gpu.toml

* Lightning gpu.

* Move logic to devices

* Update .github/CHANGELOG.md

Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>

* All gates in supported gates are now in the toml file.

* Accounting for overlap.

* Adds options to lightning_qubit.

* Add mid circuit measurement to lightning kokkos.

* Update MANIFEST.in

Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>

* Apply suggestions from code review

Co-authored-by: Ali Asadi <quthreads@gmail.com>

* Move all matrix gates to decomp

* Keep multicontrolledX as matrix gate as that is the current behaviour in Catalyst.

* Add toml files with new fields.

* New toml

* Update toml files.

* Update dev version.

* Update toml according to maintainers preference.

* Move adjoint to native gates.

* Move files.

* Remove adjoint gates from toml.

* Move ControlledQubitUnitary and MultiControlledX to decomp.

* Move ControlledQubitUnitary to matrix gate set.

---------

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Ali Asadi <quthreads@gmail.com>
Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>
  • Loading branch information
6 people authored Dec 12, 2023
1 parent 8770a96 commit 998362a
Show file tree
Hide file tree
Showing 9 changed files with 388 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

### Improvements

* Add configuration files to improve compatibility with Catalyst.
[(#566)](https://github.com/PennyLaneAI/pennylane-lightning/pull/566)

* Refactor shot-noise related methods of MeasurementsBase class in the C++ layer and eigenvalues are not limited to `1` and `-1`. Add `getObs()` method to Observables class. Refactor `applyInPlaceShots` to allow users to get eigenvalues of Observables object. Deprecated `_preprocess_state` method in `MeasurementsBase` class for safer use of the `LightningQubitRaw` backend.
[(#570)](https://github.com/PennyLaneAI/pennylane-lightning/pull/570)

Expand Down Expand Up @@ -76,7 +79,7 @@

This release contains contributions from (in alphabetical order):

Isaac De Vlugt, Amintor Dusko, Vincent Michaud-Rioux, Lee James O'Riordan, Shuli Shu
Isaac De Vlugt, Amintor Dusko, Vincent Michaud-Rioux, Erick Ochoa Lopez, Lee James O'Riordan, Shuli Shu

---

Expand Down
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
include requirements.txt
include CHANGELOG.rst
include CHANGELOG.rst
include lightning_qubit.toml
include lightning_gpu.toml
include lightning_kokkos.toml
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.34.0-dev17"
__version__ = "0.34.0-dev18"
2 changes: 2 additions & 0 deletions pennylane_lightning/lightning_gpu/lightning_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

from warnings import warn
from pathlib import Path
import numpy as np

from pennylane_lightning.core.lightning_base import (
Expand Down Expand Up @@ -230,6 +231,7 @@ class LightningGPU(LightningBase): # pylint: disable=too-many-instance-attribut
operations = allowed_operations
observables = allowed_observables
_backend_info = backend_info
config = Path(__file__).parent / "lightning_gpu.toml"

def __init__(
self,
Expand Down
122 changes: 122 additions & 0 deletions pennylane_lightning/lightning_gpu/lightning_gpu.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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",
]

# 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",
]

# 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",
]

# Gates which should be translated to QubitUnitary
matrix = [
"ControlledQubitUnitary",
"ECR",
"SX",
"ISWAP",
"PSWAP",
"SISWAP",
"SQISW",
"CPhase",
"OrbitalRotation",
"QubitCarry",
"QubitSum",
"DiagonalQubitUnitary",
]

[measurement_processes]
exactshots = [
"Expval",
"Var",
"Probs",
"State",
]
finiteshots = [
"Expval",
"Var",
"Probs",
"Sample",
"Counts",
]

[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

# 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
2 changes: 2 additions & 0 deletions pennylane_lightning/lightning_kokkos/lightning_kokkos.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

from warnings import warn
from pathlib import Path
import numpy as np

from pennylane_lightning.core.lightning_base import (
Expand Down Expand Up @@ -185,6 +186,7 @@ class LightningKokkos(LightningBase):
operations = allowed_operations
observables = allowed_observables
_backend_info = backend_info
config = Path(__file__).parent / "lightning_kokkos.toml"

def __init__(
self,
Expand Down
122 changes: 122 additions & 0 deletions pennylane_lightning/lightning_kokkos/lightning_kokkos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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",
]

# 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",
]

# 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",
]

# Gates which should be translated to QubitUnitary
matrix = [
"ControlledQubitUnitary",
"ECR",
"SX",
"ISWAP",
"PSWAP",
"SISWAP",
"SQISW",
"CPhase",
"OrbitalRotation",
"QubitCarry",
"QubitSum",
"DiagonalQubitUnitary",
]

[measurement_processes]
exactshots = [
"Expval",
"Var",
"Probs",
"State",
]
finiteshots = [
"Expval",
"Var",
"Probs",
"Sample",
"Counts",
]

[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
2 changes: 2 additions & 0 deletions pennylane_lightning/lightning_qubit/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

from warnings import warn
from pathlib import Path
import numpy as np

from pennylane_lightning.core.lightning_base import (
Expand Down Expand Up @@ -207,6 +208,7 @@ class LightningQubit(LightningBase):
operations = allowed_operations
observables = allowed_observables
_backend_info = backend_info
config = Path(__file__).parent / "lightning_qubit.toml"

def __init__( # pylint: disable=too-many-arguments
self,
Expand Down
Loading

0 comments on commit 998362a

Please sign in to comment.