Skip to content

Commit

Permalink
* Various fixes to ensure backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mkvanhooft committed Feb 21, 2024
1 parent 46fa687 commit 8d121a2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
17 changes: 12 additions & 5 deletions squidasm/run/stack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class StackNetworkConfig(YamlLoadable):
"""List of all the links connecting the stacks in the network."""
@classmethod
def from_file(cls, path: str) -> StackNetworkConfig:
return cls._from_file(path) # type: ignore
return super().from_file(path) # type: ignore


def _convert_stack_network_config(
Expand All @@ -129,11 +129,18 @@ def _convert_stack_network_config(
# Convert link config types
links = []
for link_config in stack_network_config.links:
link_typ = link_config.typ
link_cfg = link_config.cfg
if link_typ == "heralded":
link_typ = "heralded-double-click"
if link_cfg is None and link_typ == "perfect":
link_cfg = netbuilder_links.PerfectLinkConfig()

link = netbuilder_configs.LinkConfig(
node1=link_config.stack1,
node2=link_config.stack2,
typ=link_config.typ,
cfg=link_config.cfg,
typ=link_typ,
cfg=link_cfg,
)
links.append(link)

Expand All @@ -152,8 +159,8 @@ def _convert_stack_network_config(
# Link all nodes with instant classical connections
for node1, node2 in itertools.combinations(processing_nodes, 2):
clink = netbuilder_configs.CLinkConfig(
node1=node1,
node2=node2,
node1=node1.name,
node2=node2.name,
typ="instant",
cfg=netbuilder_clinks.InstantCLinkConfig(),
)
Expand Down
5 changes: 5 additions & 0 deletions squidasm/sim/stack/csocket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import netsquid_driver.classical_socket_service as netsquid_classical_socket


class ClassicalSocket(netsquid_classical_socket.ClassicalSocket):
pass
2 changes: 1 addition & 1 deletion squidasm/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .util import get_qubit_state, get_reference_state
from .util import get_qubit_state, get_reference_state, create_two_node_network
19 changes: 6 additions & 13 deletions squidasm/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@
from netqasm.sdk.qubit import Qubit
from netsquid.qubits import operators
from netsquid.qubits import qubitapi as qapi
from netsquid_netbuilder.base_configs import (
CLinkConfig,
LinkConfig,
NetworkConfig,
ProcessingNodeConfig,
)
from netsquid_netbuilder.modules.clinks.default import DefaultCLinkConfig
from netsquid_netbuilder.modules.links.depolarise import DepolariseLinkConfig
from netsquid_netbuilder.modules.qdevices.generic import GenericQDeviceConfig


import squidasm.sim.stack.globals
from squidasm.run.stack.config import StackNetworkConfig, CLinkConfig, LinkConfig, StackConfig, DepolariseLinkConfig, GenericQDeviceConfig, DefaultCLinkConfig


def create_two_node_network(
Expand All @@ -25,7 +18,7 @@ def create_two_node_network(
qdevice_noise: float = 0,
clink_delay: float = 0.0,
link_delay: float = 0.0,
) -> NetworkConfig:
) -> StackNetworkConfig:
"""
Create a network configuration with two nodes, with simple noise models.
:param node_names: List of str with the names of the two nodes
Expand All @@ -42,7 +35,7 @@ def create_two_node_network(
qdevice_cfg.two_qubit_gate_depolar_prob = qdevice_noise
qdevice_cfg.single_qubit_gate_depolar_prob = qdevice_noise
processing_nodes = [
ProcessingNodeConfig(name=name, qdevice_typ="generic", qdevice_cfg=qdevice_cfg)
StackConfig(name=name, qdevice_typ="generic", qdevice_cfg=qdevice_cfg)
for name in node_names
]

Expand All @@ -58,8 +51,8 @@ def create_two_node_network(
typ="default",
cfg=DefaultCLinkConfig(delay=clink_delay),
)
return NetworkConfig(
processing_nodes=processing_nodes, links=[link], clinks=[clink]
return StackNetworkConfig(
stacks=processing_nodes, links=[link], clinks=[clink]
)


Expand Down

0 comments on commit 8d121a2

Please sign in to comment.