Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Added flexibilty to the pass manager creator #39

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions qopt_best_practices/transpilation/preset_qaoa_passmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def qaoa_swap_strategy_pm(config: Dict[str, Any]):
swap_strategy = config.get("swap_strategy", None)
edge_coloring = config.get("edge_coloring", None)
basis_gates = config.get("basis_gates", ["sx", "x", "rz", "cx", "id"])
construct_qaoa = config.get("construct_qaoa", True)

if swap_strategy is None:
raise ValueError("No swap_strategy provided in config.")
Expand All @@ -32,19 +33,19 @@ def qaoa_swap_strategy_pm(config: Dict[str, Any]):
raise ValueError("No edge_coloring provided in config.")

# 2. define pass manager for cost layer
qaoa_pm = PassManager(
[
HighLevelSynthesis(basis_gates=["PauliEvolution"]),
FindCommutingPauliEvolutions(),
Commuting2qGateRouter(
swap_strategy,
edge_coloring,
),
SwapToFinalMapping(),
HighLevelSynthesis(basis_gates=basis_gates),
InverseCancellation(gates_to_cancel=[CXGate()]),
QAOAConstructionPass(num_layers),
]
)

return qaoa_pm
qaoa_passes = [
HighLevelSynthesis(basis_gates=["PauliEvolution"]),
FindCommutingPauliEvolutions(),
Commuting2qGateRouter(
swap_strategy,
edge_coloring,
),
SwapToFinalMapping(),
HighLevelSynthesis(basis_gates=basis_gates),
InverseCancellation(gates_to_cancel=[CXGate()]),
]

if construct_qaoa:
qaoa_passes.append(QAOAConstructionPass(num_layers))

return PassManager(qaoa_passes)
Loading