Skip to content

Commit

Permalink
Add skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikandreasseitz committed Oct 17, 2023
1 parent c3f71ee commit 75c856a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,29 @@ visualization = [
# "latex2svg @ git+https://github.com/Moonbase59/latex2svg.git#egg=latex2svg",
# "scour",
]
jax = ["jax",
"flax",
"optax",
"jaxopt",
"einops",
"scipy<1.11",
"numpy"]

all = [
"pulser>=0.12.0",
"amazon-braket-sdk",
"graphviz",
# FIXME: will be needed once we support latex labels
# "latex2svg @ git+https://github.com/Moonbase59/latex2svg.git#egg=latex2svg",
# "scour",
"jax",
"flax",
"optax",
"jaxopt",
"einops",
"scipy<1.11",
"numpy"

]

[tool.hatch.envs.default]
Expand Down
3 changes: 2 additions & 1 deletion qadence/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from qadence.circuit import QuantumCircuit
from qadence.measurements import Measurements
from qadence.parameters import stringify
from qadence.types import BackendName, DiffMode, Endianness
from qadence.types import BackendName, DiffMode, Endianness, Engine


@dataclass
Expand Down Expand Up @@ -96,6 +96,7 @@ class Backend(ABC):
is_remote: bool
with_measurements: bool
native_endianness: Endianness
engine: Engine

# FIXME: should this also go into the configuration?
with_noise: bool
Expand Down
2 changes: 2 additions & 0 deletions qadence/backends/braket/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from qadence.circuit import QuantumCircuit
from qadence.measurements import Measurements
from qadence.overlap import overlap_exact
from qadence.types import Engine
from qadence.utils import Endianness

from .config import Configuration
Expand Down Expand Up @@ -45,6 +46,7 @@ class Backend(BackendInterface):
with_noise: bool = False
native_endianness: Endianness = Endianness.BIG
config: Configuration = Configuration()
engine: Engine = Engine.NONE

# braket specifics
# TODO: include it in the configuration?
Expand Down
Empty file added qadence/backends/jax_wrapper.py
Empty file.
2 changes: 2 additions & 0 deletions qadence/backends/pulser/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from qadence.measurements import Measurements
from qadence.overlap import overlap_exact
from qadence.register import Register
from qadence.types import Engine
from qadence.utils import Endianness

from .channels import GLOBAL_CHANNEL, LOCAL_CHANNEL
Expand Down Expand Up @@ -121,6 +122,7 @@ class Backend(BackendInterface):
with_noise: bool = False
native_endianness: Endianness = Endianness.BIG
config: Configuration = Configuration()
engine: Engine = Engine.NONE

def circuit(self, circ: QuantumCircuit) -> Sequence:
native = make_sequence(circ, self.config)
Expand Down
2 changes: 2 additions & 0 deletions qadence/backends/pyqtorch/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
scale_primitive_blocks_only,
transpile,
)
from qadence.types import Engine
from qadence.utils import Endianness, int_to_basis

from .config import Configuration
Expand All @@ -44,6 +45,7 @@ class Backend(BackendInterface):
with_noise: bool = False
native_endianness: Endianness = Endianness.BIG
config: Configuration = Configuration()
engine: Engine = Engine.TORCH

def circuit(self, circuit: QuantumCircuit) -> ConvertedCircuit:
transpilations = [
Expand Down
6 changes: 6 additions & 0 deletions qadence/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,9 @@ class OpName(StrEnum):
"""The entanglement operation."""
WAIT = "wait"
"""The wait operation."""


class Engine(StrEnum):
TORCH = "torch"
JAX = "jax"
NONE = "none"

0 comments on commit 75c856a

Please sign in to comment.