This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Advanced Compiler Features
Marc Davis edited this page Feb 28, 2020
·
9 revisions
The SearchCompiler
class takes a few optional initializer options.
mycompiler = sc.SearchCompiler.init(threshold, error_func, heuristic, gateset, solver, beams)
-
threshold
- a float which specifies the stopping condition for the synthesis. The first circuit for which theerror_func
returns a value less than thethreshold
will be returned as the solution. The default value is1e-10
. -
error_func
- a function which takes two matrices and returns a float. It's value is used in guiding the search and deciding when to return a solution. The default value issc.utils.matrix_distance_squared
. -
heuristic
- a function which takes the value oferror_func
and the current search depth and returns a float. This value is used to guide the search. The default issc.heuristics.astar
. Heuristics for greedy search and breadth first search are also provided. It is recommended to switch to breadth first search if you are using a gateset with gates other than CNOT and single qubit gates. -
gateset
- asc.gatesets.Gateset
object which describes the gateset used for synthesis. The default value issc.gatesets.QubitCNOTLinear()
, which is the recommended gateset for using CNOTs and single qubit gates with the linear topology. -
solver
- asc.solver.Solver
object which performs numerical optimization. The default value issc.solver.COBYLA_Solver
, which makes a call tosp.optimize.fmin_cobyla
for numerical optimization. -
beams
- an integer which defines the number of nodes to expand at a time during each step. A negative value will result in a number of beams calculated to fully utilize the CPU threads visible to Python. The default value is-1
.
The compile
function of the SearchCompiler
class also can take two extra parameters:
mycompiler.compile(U, depth, statefile)
-
U
- the only required option, which is the unitary to be synthesized -
depth
- an integer which serves as a depth limit. If a circuit is not found within this limit that satisfies thethreshold
condition, then the circuit with the lowest value oferror_func
will be returned. The default value ofNone
will result in no depth limit being used, and the search will continue indefinitely until a circuit that meets thethreshold
requirement is found. -
statefile
- a string that describes a file path that will be used to store the intermediate state of the compilation. If the compilation is interrupted, it can be resumed by making the same call again, and the state will be restored from the statefile. Without a statefile, compilataion will have to start from the beginning if compilation is interrupted.