Skip to content

Commit 9674bb1

Browse files
author
Axel Dahlberg
committed
Reflect changes on how to run apps in netqasm
1 parent 4a19136 commit 9674bb1

File tree

11 files changed

+31
-389
lines changed

11 files changed

+31
-389
lines changed

examples/apps/run_apps.py

-15
This file was deleted.

examples/apps/teleport/README.md

-17
This file was deleted.

examples/apps/teleport/alice.yaml

-2
This file was deleted.

examples/apps/teleport/app_alice.py

-50
This file was deleted.

examples/apps/teleport/app_bob.py

-37
This file was deleted.

examples/apps/teleport/bob.yaml

Whitespace-only changes.

examples/apps/teleport/network.yaml

-30
This file was deleted.

simulaqron/run/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .run import run_applications

simulaqron/run/run.py

+12-17
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from netqasm.output import save_all_struct_loggers, reset_struct_loggers
1111
from netqasm.sdk.classical_communication import reset_socket_hub
1212
from netqasm.settings import Formalism
13-
from netqasm.sdk.app_config import AppConfig
13+
from netqasm.run.app_config import AppConfig
1414

1515
from simulaqron.network import Network
1616
from simulaqron.settings import simulaqron_settings, SimBackend
@@ -21,6 +21,13 @@
2121
# TODO similar code to squidasm.run.run, make base-class and subclasses?
2222

2323

24+
_SIMULAQRON_BACKENDS = {
25+
Formalism.STAB: SimBackend.STABILIZER,
26+
Formalism.KET: SimBackend.PROJECTQ,
27+
Formalism.DM: SimBackend.QUTIP,
28+
}
29+
30+
2431
def as_completed(futures, names=None, sleep_time=0):
2532
futures = list(futures)
2633
if names is not None:
@@ -49,20 +56,8 @@ def reset(save_loggers=False):
4956
reload(logging)
5057

5158

52-
def get_backend(formalism):
53-
if formalism == "STAB":
54-
backend = SimBackend.STABILIZER
55-
elif formalism == "KET":
56-
backend = SimBackend.PROJECTQ
57-
elif formalism == "DM":
58-
backend = SimBackend.QUTIP
59-
else:
60-
raise TypeError(f"Unknown formalism {formalism}")
61-
return backend
62-
63-
6459
def check_backend(backend):
65-
if backend in [SimBackend.PROJECTQ.value, SimBackend.QUTIP.value]:
60+
if backend in [SimBackend.PROJECTQ, SimBackend.QUTIP]:
6661
assert has_module.main(backend), f"To use {backend} as backend you need to install the package"
6762

6863

@@ -81,7 +76,7 @@ def run_applications(
8176
instr_log_dir=None,
8277
network_config=None,
8378
results_file=None,
84-
q_formalism=Formalism.KET,
79+
formalism=Formalism.KET,
8580
flavour=None,
8681
use_app_config=True, # whether to give app_config as argument to app's main()
8782
):
@@ -94,7 +89,7 @@ def run_applications(
9489
Values should be the functions
9590
"""
9691
app_names = [app_cfg.app_name for app_cfg in app_cfgs]
97-
backend = get_backend(formalism=q_formalism)
92+
backend = _SIMULAQRON_BACKENDS[formalism]
9893

9994
with Pool(len(app_names)) as executor:
10095
# Start the backend process
@@ -103,7 +98,7 @@ def run_applications(
10398
# Start the application processes
10499
app_futures = []
105100
for app_cfg in app_cfgs:
106-
inputs = app_cfgs.inputs
101+
inputs = app_cfg.inputs
107102
if use_app_config:
108103
inputs['app_config'] = app_cfg
109104
future = executor.submit(app_cfg.main_func, **inputs)

0 commit comments

Comments
 (0)