quri_parts.circuit.transpile.rz2hst module¶
- driver_pygridsynth(up_to_phase=True)¶
Build the default gridsynth driver, backed by the pure-Python
pygridsynthpackage.The returned callable maps
(theta, epsilon)to a gate-sequence string overH,S,T,XapproximatingRZ(theta)up to a global phase, to withinepsilon(the global phase is recovered separately byRZ2HSTTranspiler.__call__()).- Parameters:
up_to_phase (bool)
- Return type:
Callable[[float, float], tuple[str, float]]
- driver_cli(up_to_phase=True)¶
Build a gridsynth driver that shells out to the external
gridsynthcommand-line tool (an alternative todriver_pygridsynth()).The executable is taken from the
GRIDSYNTH_PATHenvironment variable when set, otherwise thegridsynthcommand onPATHis used. It is invoked with-pso the decomposition is only up to a global phase (the phase is recovered separately byRZ2HSTTranspiler.__call__()).- Parameters:
up_to_phase (bool)
- Return type:
Callable[[float, float], tuple[str, float]]
- class RZ2HSTTranspiler(epsilon=1e-05, gridsynth=None)¶
Bases:
CircuitTranspilerProtocolA transpiler that replaces each RZ gate with a gridsynth-generated sequence of H, S, T, and X gates.
Non-RZ gates are kept unchanged. The decomposition precision is controlled by
epsilonand passed to the gridsynth function.- Parameters:
epsilon (float) – Precision of the decomposition. Defaults to 1.0e-5.
gridsynth (Optional[GridsynthDriver]) – An optional
GridsynthDriverwith signature(theta: float, epsilon: float) -> tuple[str, float]returning a gate-sequence string (e.g."HSTX") overH,S,T,Xand the global phase in radians (nanif not provided). When None (the default),driver_pygridsynth()is used;driver_cli()is an alternative backed by the externalgridsynthcommand.