Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
wide_circuit_optimization.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 Created on Fri Jun 26 14:42:56 2020
4 Copyright 2020 Peter Rakyta, Ph.D.
5 
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 
18 @author: Peter Rakyta, Ph.D.
19 """
20 
22 
23 import squander.decomposition.qgd_Wide_Circuit_Optimization as Wide_Circuit_Optimization
24 from squander import utils
25 import time
26 
27 
28 if __name__ == '__main__':
29 
30 
31  config = {
32  'strategy': "TreeSearch",
33  'test_subcircuits': True,
34  'test_final_circuit': True,
35  'max_partition_size': 3
36  }
37 
38  filename = "examples/partitioning/qasm_samples/heisenberg-16-20.qasm"
39 
40  start_time = time.time()
41 
42  # load the circuit from a file
43  circ, parameters = utils.qasm_to_squander_circuit(filename)
44 
45  # instantiate the object for optimizing wide circuits
46  wide_circuit_optimizer = Wide_Circuit_Optimization.qgd_Wide_Circuit_Optimization( config )
47 
48  # run circuti optimization
49  wide_circuit_optimizer.OptimizeWideCircuit( circ, parameters )
50 
51  print("--- %s seconds elapsed during optimization ---" % (time.time() - start_time))
52 
53