Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Advanced Compiler Features

Marc Davis edited this page Feb 28, 2020 · 9 revisions

Configuring Compiler Options Manually

The SearchCompiler class takes a few optional initializer options.

sc.SearchCompiler.init(threshold, error_func, heuristic, gateset, solver, beams)

Compiler Options

  • threshold - a float which specifies the stopping condition for the synthesis. The first circuit for which the error_func returns a value less than the threshold will be returned as the solution. The default value is 1e-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 is sc.utils.matrix_distance_squared.
  • heuristic - a function which takes the value of error_func and the current search depth and returns a float. This value is used to guide the search. The default is sc.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 - a sc.gatesets.Gateset object which describes the gateset used for synthesis. The default value is sc.gatesets.QubitCNOTLinear(), which is the recommended gateset for using CNOTs and single qubit gates with the linear topology.
  • solver - a sc.solver.Solver object which performs numerical optimization. The default value is sc.solver.COBYLA_Solver, which makes a call to sp.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.
Clone this wiki locally