ComparatorRzDecomposer¶
- class guppyft.decompose.ComparatorRzDecomposer(*, epsilon: float, max_attempts: int)[source]¶
Decomposes Rz gates using \(2\lceil(\log_2(1/\epsilon))\rceil\) ancilla qubits via comparators and repeat-until-success. Introduces Toffoli gates. Can be used to decompose angles at runtime. See https://arxiv.org/pdf/2404.05618.
Warning
Using this decomposition together with encoding can produce runtimes that are too long to run on Helios, leading to timeout errors.
In a noiseless setting, the probability of success per attempt is greater than 0.5. The shot will be discarded if all max_attempts fail. Hence, the probability of a shot with \(g\) Rz gates completing is greater than \((1 - 0.5^L)^g\), where \(L\) is max_attempts.
- max_attempts¶
Maximum number of attempts for repeat-until-success for each Rz gate that is decomposed.
- Type:
- __eq__(other)¶
Return self==value.
- __repr__()¶
Return repr(self).
- n_ancillas() int[source]¶
Number of ancilla qubits required for the target precision (\(\epsilon\)).
- run(hugr: Hugr[Any], *, inplace: bool = True) PassResult[source]¶
Run the pass to transform a HUGR, returning a PassResult.
See
implement_pass_run()for a helper function to implement this method.
- with_scope(scope: LocalScope | GlobalScope) ComposablePass[source]¶
Set the scope configuration for the pass.
As of hugr 0.14.*, this configuration is only guidance, and may be ignored by the pass.
In the future, passes will be required to respect the scope configuration.