-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseparate_synth.py
50 lines (44 loc) · 1.34 KB
/
separate_synth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import argparse
from os import listdir
from util import load_circuit_structure
from old_codebase import synthesize
if __name__ == '__main__':
"""
>>> python separate_synth.py \
block_files/qft_5_mesh_3_3_blocksize_3 \
2
shortest_path
Synthesizes block_2 of already partitioned
`qft_5_mesh_3_3_blocksize_3_shortest-path` project.
"""
parser = argparse.ArgumentParser(
description="Run synthesis on blocks in the `block_files` directory"
)
parser.add_argument("partition_dir", type=str,
help="path to block files to synthesize")
parser.add_argument("block_number", type = int,
help="specific block to synthesize")
parser.add_argument("--alltoall",action="store_true",
help="synthesize to all to all")
args = parser.parse_args()
files = sorted(list(listdir(args.partition_dir)))
files.remove("structure.pickle")
target_name = args.partition_dir.split("/")[-1]
if not args.alltoall:
target_name += "_kernel"
else:
target_name += "_alltoall"
block_name = files[args.block_number].split(".qasm")[0]
qudit_group = load_circuit_structure(args.partition_dir)[args.block_number]
options = {
"target_name" : target_name,
"synthesis_dir" : f"synthesis_files/{target_name}",
"partition_dir" : f"{args.partition_dir}",
"num_synth_procs" : 1,
"checkpoint_as_qasm" : True,
}
synthesize(
block_name,
qudit_group,
options,
)