quri_parts.circuit.transpile.rz2hst module

driver_pygridsynth(up_to_phase=True)

Build the default gridsynth driver, backed by the pure-Python pygridsynth package.

The returned callable maps (theta, epsilon) to a gate-sequence string over H, S, T, X approximating RZ(theta) up to a global phase, to within epsilon (the global phase is recovered separately by RZ2HSTTranspiler.__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 gridsynth command-line tool (an alternative to driver_pygridsynth()).

The executable is taken from the GRIDSYNTH_PATH environment variable when set, otherwise the gridsynth command on PATH is used. It is invoked with -p so the decomposition is only up to a global phase (the phase is recovered separately by RZ2HSTTranspiler.__call__()).

Parameters:

up_to_phase (bool)

Return type:

Callable[[float, float], tuple[str, float]]

class RZ2HSTTranspiler(epsilon=1e-05, gridsynth=None)

Bases: CircuitTranspilerProtocol

A 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 epsilon and passed to the gridsynth function.

Parameters:
  • epsilon (float) – Precision of the decomposition. Defaults to 1.0e-5.

  • gridsynth (Optional[GridsynthDriver]) – An optional GridsynthDriver with signature (theta: float, epsilon: float) -> tuple[str, float] returning a gate-sequence string (e.g. "HSTX") over H, S, T, X and the global phase in radians (nan if not provided). When None (the default), driver_pygridsynth() is used; driver_cli() is an alternative backed by the external gridsynth command.