Skip to content

Commit 605a264

Browse files
Liu KeyuLiu Keyu
authored andcommitted
Fix bugs
1 parent 1c49a5b commit 605a264

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

src/mqt/predictor/rl/actions.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ def get_openqasm_gates() -> list[str]:
495495
PassType.MAPPING,
496496
stochastic=True,
497497
transpile_pass=lambda device: [
498+
TrivialLayout(coupling_map=CouplingMap(device.build_coupling_map())),
498499
SafeAIRouting(coupling_map=device.build_coupling_map(), optimization_level=3, layout_mode="optimize"),
499500
],
500501
)
@@ -649,22 +650,22 @@ def get_openqasm_gates() -> list[str]:
649650
)
650651
)
651652

652-
# register_action(
653-
# DeviceDependentAction(
654-
# "BQSKitSynthesis",
655-
# CompilationOrigin.BQSKIT,
656-
# PassType.SYNTHESIS,
657-
# transpile_pass=lambda device: lambda bqskit_circuit: bqskit_compile(
658-
# bqskit_circuit,
659-
# model=MachineModel(bqskit_circuit.num_qudits, gate_set=get_bqskit_native_gates(device)),
660-
# optimization_level=1 if os.getenv("GITHUB_ACTIONS") == "true" else 2,
661-
# synthesis_epsilon=1e-1 if os.getenv("GITHUB_ACTIONS") == "true" else 1e-8,
662-
# max_synthesis_size=2 if os.getenv("GITHUB_ACTIONS") == "true" else 3,
663-
# seed=10,
664-
# num_workers=1 if os.getenv("GITHUB_ACTIONS") == "true" else -1,
665-
# ),
666-
# )
667-
# )
653+
register_action(
654+
DeviceDependentAction(
655+
"BQSKitSynthesis",
656+
CompilationOrigin.BQSKIT,
657+
PassType.SYNTHESIS,
658+
transpile_pass=lambda device: lambda bqskit_circuit: bqskit_compile(
659+
bqskit_circuit,
660+
model=MachineModel(bqskit_circuit.num_qudits, gate_set=get_bqskit_native_gates(device)),
661+
optimization_level=1 if os.getenv("GITHUB_ACTIONS") == "true" else 2,
662+
synthesis_epsilon=1e-1 if os.getenv("GITHUB_ACTIONS") == "true" else 1e-8,
663+
max_synthesis_size=2 if os.getenv("GITHUB_ACTIONS") == "true" else 3,
664+
seed=10,
665+
num_workers=1 if os.getenv("GITHUB_ACTIONS") == "true" else -1,
666+
),
667+
)
668+
)
668669

669670
register_action(
670671
DeviceIndependentAction(

src/mqt/predictor/rl/helper.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,16 @@ def best_of_n_passmanager(
7878
msg = f"Expected list of passes, got {type(all_passes)}"
7979
raise TypeError(msg)
8080

81-
if len(all_passes) == 1:
82-
layouted_qc = qc
83-
layout_props = {}
84-
routing_pass = all_passes
85-
else:
86-
layout_passes = all_passes[:-1]
87-
routing_pass = all_passes[-1:]
81+
layout_passes = all_passes[:-1]
82+
routing_pass = all_passes[-1:]
8883

89-
layout_pm = PassManager(layout_passes)
90-
try:
91-
layouted_qc = layout_pm.run(qc)
92-
layout_props = dict(layout_pm.property_set)
93-
except Exception:
94-
return qc, {}
84+
# Run layout once
85+
layout_pm = PassManager(layout_passes)
86+
try:
87+
layouted_qc = layout_pm.run(qc)
88+
layout_props = dict(layout_pm.property_set)
89+
except Exception:
90+
return qc, {}
9591

9692
# Run routing multiple times and optimize for the given metric
9793
for i in range(max_iteration[1]):

0 commit comments

Comments
 (0)