Skip to content

Commit

Permalink
* Revert examples to use StackNetworkConfig instead of NetworkConfig …
Browse files Browse the repository at this point in the history
…from netsquid-netbuilder
  • Loading branch information
mkvanhooft committed Mar 5, 2024
1 parent 5f3ca39 commit 913608e
Show file tree
Hide file tree
Showing 48 changed files with 237 additions and 328 deletions.
18 changes: 8 additions & 10 deletions examples/advanced/bqc/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ qdevice_cfg: &qdevice_cfg
two_qubit_gate_time: 1.e+5
measurement_time: 1.e+4

processing_nodes:
stacks:
- name: client
qdevice_typ: generic
qdevice_cfg:
Expand All @@ -19,24 +19,22 @@ processing_nodes:
<<: *qdevice_cfg

link_cfg: &link_cfg
length_A: 50
length_B: 50
p_loss_length_A: 0.2
p_loss_length_B: 0.2
length: 100
p_loss_length: 0.2
dark_count_probability: 0
detector_efficiency: 1
visibility: 1

links:
- node1: client
node2: server
typ: heralded-double-click
- stack1: client
stack2: server
typ: heralded
cfg:
<<: *link_cfg

clinks:
- node1: client
node2: server
- stack1: client
stack2: server
typ: default
cfg:
delay: 0.5
10 changes: 5 additions & 5 deletions examples/advanced/bqc/config_nv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ qdevice_cfg: &qdevice_cfg
two_qubit_gate_time: 1.e+1
measurement_time: 1.e+1

processing_nodes:
stacks:
- name: client
qdevice_typ: nv
qdevice_cfg:
Expand All @@ -24,15 +24,15 @@ link_cfg: &link_cfg
t_cycle: 1e1

links:
- node1: client
node2: server
- stack1: client
stack2: server
typ: depolarise
cfg:
<<: *link_cfg

clinks:
- node1: client
node2: server
- stack1: client
stack2: server
typ: default
cfg:
delay: 0.5
8 changes: 4 additions & 4 deletions examples/advanced/bqc/example_bqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from typing import Any, Dict, Generator

from netqasm.lang.ir import BreakpointAction
from netsquid_netbuilder.base_configs import NetworkConfig

from pydynaa import EventExpression
from squidasm.run.stack.config import StackNetworkConfig
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.csocket import ClassicalSocket
Expand Down Expand Up @@ -159,7 +159,7 @@ def run(


def computation_round(
cfg: NetworkConfig,
cfg: StackNetworkConfig,
num_times: int = 1,
alpha: float = 0.0,
beta: float = 0.0,
Expand Down Expand Up @@ -190,7 +190,7 @@ def computation_round(


def trap_round(
cfg: NetworkConfig,
cfg: StackNetworkConfig,
num_times: int = 1,
alpha: float = 0.0,
beta: float = 0.0,
Expand Down Expand Up @@ -235,7 +235,7 @@ def trap_round(
# ns.set_qstate_formalism(ns.qubits.qformalism.QFormalism.DM)

cfg_file = os.path.join(os.path.dirname(__file__), "config.yaml")
cfg = NetworkConfig.from_file(cfg_file)
cfg = StackNetworkConfig.from_file(cfg_file)

computation_round(cfg, num_times, alpha=PI_OVER_2, beta=PI_OVER_2)
trap_round(cfg, num_times, dummy=1)
13 changes: 6 additions & 7 deletions examples/advanced/bqc/example_bqc_nv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
from netqasm.sdk.connection import BaseNetQASMConnection
from netqasm.sdk.futures import Future, RegFuture
from netqasm.sdk.qubit import Qubit
from netsquid_netbuilder.base_configs import NetworkConfig
from netsquid_netbuilder.modules.qdevices.nv import NVQDeviceConfig

from pydynaa import EventExpression
from squidasm.run.stack.config import NVQDeviceConfig, StackNetworkConfig
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.csocket import ClassicalSocket
Expand Down Expand Up @@ -156,7 +155,7 @@ def run(


def computation_round(
cfg: NetworkConfig,
cfg: StackNetworkConfig,
num_times: int = 1,
alpha: float = 0.0,
beta: float = 0.0,
Expand Down Expand Up @@ -187,7 +186,7 @@ def computation_round(


def trap_round(
cfg: NetworkConfig,
cfg: StackNetworkConfig,
num_times: int = 1,
alpha: float = 0.0,
beta: float = 0.0,
Expand Down Expand Up @@ -233,9 +232,9 @@ def trap_round(
ns.set_qstate_formalism(ns.qubits.qformalism.QFormalism.DM)

cfg_file = os.path.join(os.path.dirname(__file__), "config_nv.yaml")
cfg = NetworkConfig.from_file(cfg_file)
cfg.processing_nodes[0].qdevice_cfg = NVQDeviceConfig.perfect_config()
cfg.processing_nodes[1].qdevice_cfg = NVQDeviceConfig.perfect_config()
cfg = StackNetworkConfig.from_file(cfg_file)
cfg.stacks[0].qdevice_cfg = NVQDeviceConfig.perfect_config()
cfg.stacks[1].qdevice_cfg = NVQDeviceConfig.perfect_config()

# computation_round(cfg, num_times, alpha=PI_OVER_2, beta=PI_OVER_2)
trap_round(cfg=cfg, num_times=num_times, dummy=2)
10 changes: 5 additions & 5 deletions examples/advanced/fidelity_constraint/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ qdevice_cfg: &qdevice_cfg
two_qubit_gate_time: 1.e+5
measurement_time: 1.e+4

processing_nodes:
stacks:
- name: client
qdevice_typ: generic
qdevice_cfg:
Expand All @@ -24,15 +24,15 @@ link_cfg: &link_cfg
t_cycle: 1e3

links:
- node1: client
node2: server
- stack1: client
stack2: server
typ: depolarise
cfg:
<<: *link_cfg

clinks:
- node1: client
node2: server
- stack1: client
stack2: server
typ: default
cfg:
delay: 0.5
10 changes: 5 additions & 5 deletions examples/advanced/fidelity_constraint/config_nv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ qdevice_cfg: &qdevice_cfg
two_qubit_gate_time: 1.e+1
measurement_time: 1.e+1

processing_nodes:
stacks:
- name: client
qdevice_typ: nv
qdevice_cfg:
Expand All @@ -24,15 +24,15 @@ link_cfg: &link_cfg
t_cycle: 1e3

links:
- node1: client
node2: server
- stack1: client
stack2: server
typ: depolarise
cfg:
<<: *link_cfg

clinks:
- node1: client
node2: server
- stack1: client
stack2: server
typ: default
cfg:
delay: 0.5
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
from netqasm.sdk.connection import BaseNetQASMConnection
from netqasm.sdk.futures import Future, RegFuture
from netqasm.sdk.qubit import Qubit
from netsquid_netbuilder.base_configs import NetworkConfig
from netsquid_netbuilder.modules.qdevices.nv import NVQDeviceConfig

from pydynaa import EventExpression
from squidasm.run.stack.config import NVQDeviceConfig, StackNetworkConfig
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.csocket import ClassicalSocket
Expand Down Expand Up @@ -162,7 +161,7 @@ def run(


def computation_round(
cfg: NetworkConfig,
cfg: StackNetworkConfig,
num_times: int = 1,
alpha: float = 0.0,
beta: float = 0.0,
Expand Down Expand Up @@ -193,7 +192,7 @@ def computation_round(


def trap_round(
cfg: NetworkConfig,
cfg: StackNetworkConfig,
num_times: int = 1,
alpha: float = 0.0,
beta: float = 0.0,
Expand Down Expand Up @@ -239,9 +238,9 @@ def trap_round(
ns.set_qstate_formalism(ns.qubits.qformalism.QFormalism.DM)

cfg_file = os.path.join(os.path.dirname(__file__), "config_nv.yaml")
cfg = NetworkConfig.from_file(cfg_file)
cfg.processing_nodes[0].qdevice_cfg = NVQDeviceConfig.perfect_config()
cfg.processing_nodes[1].qdevice_cfg = NVQDeviceConfig.perfect_config()
cfg = StackNetworkConfig.from_file(cfg_file)
cfg.stacks[0].qdevice_cfg = NVQDeviceConfig.perfect_config()
cfg.stacks[1].qdevice_cfg = NVQDeviceConfig.perfect_config()

computation_round(cfg, num_times, alpha=PI_OVER_2, beta=PI_OVER_2)
# trap_round(cfg=cfg, num_times=num_times, dummy=2)
6 changes: 3 additions & 3 deletions examples/advanced/fidelity_constraint/example_fidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from typing import Any, Dict, Generator

import netsquid as ns
from netsquid_netbuilder.base_configs import NetworkConfig

from pydynaa import EventExpression
from squidasm.run.stack.config import StackNetworkConfig
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.program import Program, ProgramContext, ProgramMeta
Expand Down Expand Up @@ -98,7 +98,7 @@ def run(


def run_app(
cfg: NetworkConfig,
cfg: StackNetworkConfig,
num_times: int = 1,
alpha: float = 0.0,
beta: float = 0.0,
Expand Down Expand Up @@ -128,6 +128,6 @@ def run_app(
ns.set_qstate_formalism(ns.qubits.qformalism.QFormalism.DM)

cfg_file = os.path.join(os.path.dirname(__file__), "config.yaml")
cfg = NetworkConfig.from_file(cfg_file)
cfg = StackNetworkConfig.from_file(cfg_file)

run_app(cfg, num_times, alpha=PI_OVER_2, beta=PI_OVER_2)
10 changes: 5 additions & 5 deletions examples/advanced/link_layer/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ qdevice: &qdevice
prob_error_1: 0.005
num_qubits: 2

processing_nodes:
stacks:
- name: client
qdevice_typ: nv
qdevice_cfg:
Expand All @@ -36,8 +36,8 @@ processing_nodes:
<<: *qdevice

links:
- node1: client
node2: server
- stack1: client
stack2: server
typ: perfect
cfg:
length_A: 0.01
Expand All @@ -47,8 +47,8 @@ links:
alpha: 0.9

clinks:
- node1: client
node2: server
- stack1: client
stack2: server
typ: default
cfg:
delay: 0.5
5 changes: 2 additions & 3 deletions examples/advanced/link_layer/example_link_layer_ck.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
from typing import Any, Dict, Generator

from netsquid_netbuilder.base_configs import NetworkConfig

from pydynaa import EventExpression
from squidasm.run.stack.config import StackNetworkConfig
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.program import Program, ProgramContext, ProgramMeta
Expand Down Expand Up @@ -105,7 +104,7 @@ def post_create(conn, q, pair):
LogManager.set_log_level("WARNING")

num_times = 1
cfg = NetworkConfig.from_file(
cfg = StackNetworkConfig.from_file(
os.path.join(os.getcwd(), os.path.dirname(__file__), "config.yaml")
)

Expand Down
5 changes: 2 additions & 3 deletions examples/advanced/link_layer/example_link_layer_md.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
from typing import Any, Dict, Generator

from netsquid_netbuilder.base_configs import NetworkConfig

from pydynaa import EventExpression
from squidasm.run.stack.config import StackNetworkConfig
from squidasm.run.stack.run import run
from squidasm.sim.stack.common import LogManager
from squidasm.sim.stack.program import Program, ProgramContext, ProgramMeta
Expand Down Expand Up @@ -77,7 +76,7 @@ def run(
LogManager.set_log_level("WARNING")

num_times = 1
cfg = NetworkConfig.from_file(
cfg = StackNetworkConfig.from_file(
os.path.join(os.getcwd(), os.path.dirname(__file__), "config.yaml")
)

Expand Down
Loading

0 comments on commit 913608e

Please sign in to comment.