FoldingFn¶
- FoldingFn¶
Type for the folding callable — given a
DAGCircuitand a requestedscale_factor, return(folded_dag, effective_scale). The second value is the scale actually realised (it may differ from the request when the gate count is too small for the fractional part to round cleanly) and is forwarded to the extrapolator.Contract for implementers:
Callables consume their input
DAGCircuit— callers pass a DAG they no longer need, and the fold is free to mutate it.By convention
folding_fn(dag, 1.0)returns the DAG unmodified witheffective_scale=1.0— both built-in folds honor this.
alias of
Callable[[DAGCircuit,float],tuple[DAGCircuit,float]]