Skip to content

Commit

Permalink
Merge branch 'qelectron' into bug/fix-for-circuits-api-error
Browse files Browse the repository at this point in the history
  • Loading branch information
mpvgithub committed Sep 11, 2023
2 parents fb3ff01 + 04b05c1 commit 3c2b920
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions covalent/_shared_files/qinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class QNodeSpecs(BaseModel):
A container for the specifications of a QNode generated by `qml.specs`.
"""

gate_sizes: Dict[str, int]
gate_sizes: Dict[int, int]
gate_types: Dict[str, int]
num_operations: int
num_observables: int
Expand All @@ -55,7 +55,7 @@ class QElectronInfo(BaseModel):
"""

name: str
description: str = None
description: Optional[str] = None
device_name: str # name of the original device, e.g. "default.qubit"
device_import_path: str # used to inherit type converters and other methods
device_shots: Union[
Expand Down
4 changes: 4 additions & 0 deletions covalent/_workflow/qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@
import pennylane as qml

from .._results_manager.qresult import QNodeFutureResult
from .._shared_files import logger
from .._shared_files.qinfo import QElectronInfo, QNodeSpecs
from .._shared_files.qresult_utils import re_execute
from .._shared_files.utils import get_original_shots
from ..executor.qbase import BaseQExecutor
from .qdevice import QEDevice

app_log = logger.app_log
log_stack_info = logger.log_stack_info

_GRADIENT_ACCESS_MAXES = {
"parameter-shift": 2,
}
Expand Down
6 changes: 3 additions & 3 deletions covalent/executor/qbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ class BaseQExecutor(ABC, BaseModel):
"""

shots: Union[None, int, Sequence[int], Sequence[Union[int, Sequence[int]]]] = SHOTS_DEFAULT
shots_converter: type = None
shots_converter: Optional[type] = None
persist_data: bool = True

# Executors need to contain certain information about original QNode, in order
# to produce correct results. These attributes below contain that information.
# They are set inside the `QServer` and will be `None` client-side.
qelectron_info: QElectronInfo = None
qnode_specs: QNodeSpecs = None
qelectron_info: Optional[QElectronInfo] = None
qnode_specs: Optional[QNodeSpecs] = None

@property
def override_shots(self) -> Union[int, None]:
Expand Down
9 changes: 5 additions & 4 deletions covalent/quantum/qserver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@
import datetime
import importlib
from functools import lru_cache
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional, Union

import orjson
from pydantic import BaseModel

from ..._shared_files.qinfo import QNodeSpecs
from ...executor.qbase import BaseQExecutor

BATCH_ID_SEPARATOR = "@"
MAX_DIFFERENT_EXECUTORS = 10


class CircuitInfo(BaseModel):
electron_node_id: str = None
electron_node_id: int = None
dispatch_id: str = None
circuit_name: str = None
circuit_description: str = None
circuit_description: Optional[str] = None
circuit_diagram: str = None
qnode_specs: Dict[str, Any] = None
qnode_specs: Union[Dict[str, Any], QNodeSpecs] = None
qexecutor: BaseQExecutor = None
save_time: datetime.datetime
circuit_id: str = None
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ networkx>=2.8.6
orjson==3.8.10
pennylane==0.31.1
psutil>=5.9.0
pydantic>=2.1.1
pydantic==2.1.1
pydantic-settings>=2.0.3
python-socketio>=5.7.1
requests>=2.24.0
rich>=12.0.0,<=13.3.5
Expand Down

0 comments on commit 3c2b920

Please sign in to comment.