GlobalFoldPass

class GlobalFoldPass(scale_factor)[source]

Bases: TransformationPass

Global unitary folding with fractional scale-factor support.

For a target scale factor s on a circuit of d unitary gates:

k         = (s - 1) // 2
remainder = s - (1 + 2k)
n         = round(remainder · d / 2)

The returned DAG is U · (U† · U)^k · L† · L where L is the sub-circuit of the last n unitary gates of U. Non-unitary instructions are ignored when counting d and selecting the tail.

Parameters:

scale_factor (float) – Real number ≥ 1. 1.0 is a pass-through.

Raises:

ValueError – If scale_factor < 1.

Methods Summary

effective_scale(dag)

Scale factor actually realised on dag.

run(dag)

Fold dag in place and return the mutated DAG.

Methods Documentation

effective_scale(dag)[source]

Scale factor actually realised on dag.

Return type:

float

run(dag)[source]

Fold dag in place and return the mutated DAG.

Return type:

DAGCircuit