10
10
from netqasm .output import save_all_struct_loggers , reset_struct_loggers
11
11
from netqasm .sdk .classical_communication import reset_socket_hub
12
12
from netqasm .settings import Formalism
13
- from netqasm .sdk .app_config import AppConfig
13
+ from netqasm .run .app_config import AppConfig
14
14
15
15
from simulaqron .network import Network
16
16
from simulaqron .settings import simulaqron_settings , SimBackend
21
21
# TODO similar code to squidasm.run.run, make base-class and subclasses?
22
22
23
23
24
+ _SIMULAQRON_BACKENDS = {
25
+ Formalism .STAB : SimBackend .STABILIZER ,
26
+ Formalism .KET : SimBackend .PROJECTQ ,
27
+ Formalism .DM : SimBackend .QUTIP ,
28
+ }
29
+
30
+
24
31
def as_completed (futures , names = None , sleep_time = 0 ):
25
32
futures = list (futures )
26
33
if names is not None :
@@ -49,20 +56,8 @@ def reset(save_loggers=False):
49
56
reload (logging )
50
57
51
58
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
-
64
59
def check_backend (backend ):
65
- if backend in [SimBackend .PROJECTQ . value , SimBackend .QUTIP . value ]:
60
+ if backend in [SimBackend .PROJECTQ , SimBackend .QUTIP ]:
66
61
assert has_module .main (backend ), f"To use { backend } as backend you need to install the package"
67
62
68
63
@@ -81,7 +76,7 @@ def run_applications(
81
76
instr_log_dir = None ,
82
77
network_config = None ,
83
78
results_file = None ,
84
- q_formalism = Formalism .KET ,
79
+ formalism = Formalism .KET ,
85
80
flavour = None ,
86
81
use_app_config = True , # whether to give app_config as argument to app's main()
87
82
):
@@ -94,7 +89,7 @@ def run_applications(
94
89
Values should be the functions
95
90
"""
96
91
app_names = [app_cfg .app_name for app_cfg in app_cfgs ]
97
- backend = get_backend ( formalism = q_formalism )
92
+ backend = _SIMULAQRON_BACKENDS [ formalism ]
98
93
99
94
with Pool (len (app_names )) as executor :
100
95
# Start the backend process
@@ -103,7 +98,7 @@ def run_applications(
103
98
# Start the application processes
104
99
app_futures = []
105
100
for app_cfg in app_cfgs :
106
- inputs = app_cfgs .inputs
101
+ inputs = app_cfg .inputs
107
102
if use_app_config :
108
103
inputs ['app_config' ] = app_cfg
109
104
future = executor .submit (app_cfg .main_func , ** inputs )
0 commit comments