TreeScanningGateRemovalPass

class TreeScanningGateRemovalPass(start_from_left=True, success_threshold=1e-08, cost=<bqskit.ir.opt.cost.functions.residuals.hilbertschmidt.HilbertSchmidtResidualsGenerator object>, instantiate_options={}, tree_depth=1, collection_filter=None)[source]

Bases: ScanningGateRemovalPass

The TreeScanningGateRemovalPass class.

Starting from one side of the circuit, run the following:

Split the circuit operations into chunks of size tree_depth At every iteration: a. Look at the next chunk of operations b. Generate 2 ^ tree_depth circuits. Each circuit corresponds to every combination of whether or not to include one of the operations in the chunk. c. Instantiate in parallel all 2^`tree_depth` circuits d. Choose the circuit that has the least number of operations and move on to the next chunk of operations.

This optimization is less greedy than the current ScanningGateRemovalPass removal, which leads to much better quality circuits than ScanningGate. In very rare occasions, ScanningGate may be able to outperform TreeScan (since it is still greedy), but in general we can expect TreeScan to almost always outperform ScanningGate.

__init__(start_from_left=True, success_threshold=1e-08, cost=<bqskit.ir.opt.cost.functions.residuals.hilbertschmidt.HilbertSchmidtResidualsGenerator object>, instantiate_options={}, tree_depth=1, collection_filter=None)[source]

Construct a TreeScanningGateRemovalPass.

Parameters:
  • start_from_left (bool) – Determines where the scan starts attempting to remove gates from. If True, scan goes left to right, otherwise right to left. (Default: True)

  • success_threshold (float) – The distance threshold that determines successful termintation. Measured in cost described by the hilbert schmidt cost function. (Default: 1e-8)

  • cost (CostFunction | None) – The cost function that determines successful removal of a gate. (Default: HilbertSchmidtResidualsGenerator())

  • (dict[str (instantiate_options) – Any]): Options passed directly to circuit.instantiate when instantiating circuit templates. (Default: {})

  • tree_depth (int) – The depth of the tree of potential solutions to instantiate. Note that 2^(tree_depth) - 1 circuits will be instantiated in parallel. Note that the default behavior will be equivalent to normal ScanningGateRemoval (Default: 1)

  • collection_filter (Callable[[Operation], bool] | None) – A predicate that determines which operations should be attempted to be removed. Called with each operation in the circuit. If this returns true, this pass will attempt to remove that operation. Defaults to all operations.

Attributes

name

The name of the pass.

Methods

execute(*args, **kwargs)

Map a function over iterable arguments in parallel.

get_connectivity(_, data)

Retrieve the current connectivity of the circuit.

get_model(_, data)

Retrieve the machine model from the data dictionary.

get_placement(_, data)

Retrieve the logical to physical qubit map from the data dictionary.

get_target(_, data)

Retrieve the target from the data dictionary.

get_tree_circs(orig_num_cycles, ...)

Generate all circuits to be instantiated in the tree scan.

in_parallel(data)

Return true if pass is being executed in a parallel.

run(circuit, data)

Perform the pass's operation, see BasePass for more.