Skip to content

Commit

Permalink
Changed layout trials to one forward and back
Browse files Browse the repository at this point in the history
  • Loading branch information
henryzou50 committed Feb 27, 2024
1 parent a413fb4 commit dd90f01
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
9 changes: 4 additions & 5 deletions workspace_experiments/experiment_setup/pass_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def build_rp(rp_str, cm, seed=42, look=0, beam=0, num_iter=1, crit=1):

return rp

def build_lp(lp_str, cm, rp, seed=42):
def build_lp(lp_str, cm, rp, seed=42, max_iter=1):
""" Build a layout pass based on the layout pass string lp_str.
Args:
Expand All @@ -51,15 +51,14 @@ def build_lp(lp_str, cm, rp, seed=42):
"""

lp = None
print(f"Using seed {seed} for layout pass.")

print(f"Using seed {seed} and max iterations {max_iter} for layout pass.")

if lp_str == "sabre_layout":
print(f" Building Sabre layout pass")
lp = SabreLayout(cm, rp, seed=seed)
lp = SabreLayout(cm, rp, seed=seed, max_iterations=max_iter)
elif lp_str == "fast_layout":
print(f" Building Fast layout pass")
lp = SabreLayout(cm, Sabre(cm, seed=seed), seed=seed)
lp = SabreLayout(cm, Sabre(cm, seed=seed), seed=seed, max_iterations=max_iter)
elif lp_str == "trivial_layout":
print(f" Building Trivial layout pass")
lp = TrivialLayout()
Expand Down
49 changes: 47 additions & 2 deletions workspace_experiments/experiment_setup/test_pass_managers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"source": [
"from IPython.display import display\n",
"from circuits.circuit_files import get_circuits_from_directory\n",
"from sabre_mods.sabre_swap_v0_20_ import SabreSwap"
"from sabre_mods.sabre_swap_v0_20_ import SabreSwap\n",
"from pass_managers import build_lp, build_rp, build_pm\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Setup circuit and coupling map"
"# Setup circuit and coupling map"
]
},
{
Expand Down Expand Up @@ -84,6 +85,50 @@
"# Regular Transpilation"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using seed 42 for routing pass.\n",
" Building Sabre v0.20 routing pass\n",
"Using seed 42 and max iterations 1 for layout pass.\n",
" Building Sabre layout pass\n"
]
}
],
"source": [
"rp_str = \"sabre_v0_20_\"\n",
"lp_str = \"sabre_layout\"\n",
"\n",
"rp = build_rp(rp_str, cm)\n",
"lp = build_lp(lp_str, cm, rp)\n",
"pm = build_pm(rp, lp, cm)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running SabreSwap_v0_20\n",
"Running SabreSwap_v0_20\n",
"Running SabreSwap_v0_20\n"
]
}
],
"source": [
"qc_tr = pm.run(qc)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit dd90f01

Please sign in to comment.