LocalFoldPass

class LocalFoldPass(scale_factor, selection='random', exclude=None, rng=None)[source]

Bases: TransformationPass

Per-gate folding with fractional scale-factor support.

Each unitary gate G is replaced by G · (G† · G)^k. Fractional scale factors fold a selected subset of gates one extra time.

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

  • selection (Literal['random', 'from_left', 'from_right']) – Which gates receive the extra fold.

  • exclude (set[str] | None) – Optional op names or arity shorthands to skip.

  • rng (Random | None) – Optional random source for selection="random".

Raises:

ValueError – If scale_factor < 1 or selection is unknown.

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