Skip to content

Commit 2682c2e

Browse files
Liu KeyuLiu Keyu
authored andcommitted
Fix bugs
1 parent f4874e6 commit 2682c2e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/mqt/predictor/rl/actions.py

Lines changed: 1 addition & 0 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+
### Requires a initial layout, but "optimize" mode overwrites it
498499
TrivialLayout(coupling_map=CouplingMap(device.build_coupling_map())),
499500
FullAncillaAllocation(coupling_map=CouplingMap(device.build_coupling_map())),
500501
EnlargeWithAncilla(),

src/mqt/predictor/rl/predictorenv.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ def _apply_qiskit_action(self, action: Action, action_index: int) -> QuantumCirc
341341
def metric_fn(circ: QuantumCircuit) -> float:
342342
return float(circ.count_ops().get("swap", 0))
343343

344-
# for stochastic actions, pass the layout/routing trials parameter
345344
max_iteration = self.max_iter
346345
if "Sabre" in action.name and "AIRouting" not in action.name:
347346
# Internal trials for Sabre
@@ -359,6 +358,10 @@ def metric_fn(circ: QuantumCircuit) -> float:
359358
max_iteration=max_iteration,
360359
metric_fn=metric_fn,
361360
)
361+
else:
362+
msg = f"Unknown stochastic action: {action.name}"
363+
raise ValueError(msg)
364+
362365
else:
363366
if action.name in ["QiskitO3", "Opt2qBlocks"] and isinstance(action, DeviceDependentAction):
364367
passes = action.transpile_pass(
@@ -378,8 +381,8 @@ def metric_fn(circ: QuantumCircuit) -> float:
378381
pm = PassManager(transpile_pass)
379382
altered_qc = pm.run(self.state)
380383
pm_property_set = dict(pm.property_set) if hasattr(pm, "property_set") else {}
384+
381385
if action_index in (self.actions_mapping_indices + self.actions_final_optimization_indices):
382-
pm_property_set = dict(pm.property_set)
383386
altered_qc = self._handle_qiskit_layout_postprocessing(action, pm_property_set, altered_qc)
384387

385388
return altered_qc

0 commit comments

Comments
 (0)