qsp_pyqsp

oracq.algorithms.common.qsp_pyqsp

pyqsp-backed QSP phase synthesis: an optional PhaseSynthesizer component.

This module adapts pyqsp (https://github.com/ichuang/pyqsp, MIT-licensed, a pure numerical package) to the PhaseSynthesizer contract of oracq.algorithms.common.qsvt. It is imported only at the usage entry: nothing in the core imports it, and pyqsp is an optional dependency (extra pyqsp).

Convention mapping, verified pointwise against qsp_response on Chebyshev grids. pyqsp’s symmetric solver returns phases Θ = [θ_0, …, θ_d] for the Wx signal convention, building U = e^{iθ_0 Z} ∏ W_x(x) e^{iθ_k Z} with θ_0 the last-applied rotation and the target polynomial appearing as Im U_00. The two signal operators obey W_x(x) = S(−π/4) R(x) (i·S(−π/4)), so with

φ_j = θ_{d−j} − π/4 (j = 0 or j = d), φ_j = θ_{d−j} − π/2 (middle),

the oracq reflection-convention product realizes p(x) = i^{−d}·U_00(x). To pin Re p = f the adapter additionally negates the target when d ≡ 3 (mod 4) and adds γ = −π/2 (d ≡ 0), +π/2 (d ≡ 2), or 0 (odd d) to the first-applied phase φ_0, which multiplies p by e^{iγ}.

Scope: the adapter supports the free-completion mode only (Re p = f, the complementary part is pyqsp’s choice); a pinned imaginary completion is rejected with ValidationError. Input coefficients follow the library contract (ascending monomial coefficients) and are converted to the Chebyshev basis internally; like all coefficient-level pipelines, the conversion and the library-side grid validation are reliable only in the same moderate-degree domain as the bundled route. For high-degree work, construct the target natively in the Chebyshev basis and call chebyshev_phases_via_pyqsp directly.

class oracq.algorithms.common.qsp_pyqsp.PyqspSynthesizer[source]

Bases: object

PhaseSynthesizer backed by pyqsp’s symmetric-QSP Newton solver (free-completion mode).

Follows the PhaseSynthesizer contract of oracq.algorithms.common.qsvt: accepts ascending monomial coefficients (converted to the Chebyshev basis internally) and returns time-ordered phases in the reflection convention. A pinned imaginary completion (imag given) is not supported, since pyqsp chooses the complementary part itself.

oracq.algorithms.common.qsp_pyqsp.chebyshev_phases_via_pyqsp(cheb_coeffs)[source]

Synthesize oracq-convention phases for a real target in ascending Chebyshev coefficients.

The target must have definite parity (its degree’s parity) and satisfy |f| <= 1 on [-1, 1] with enough headroom for a complementary polynomial. The returned sequence Φ (time order, length d+1) realizes Re p = f under qsp_response; the imaginary completion is pyqsp’s choice.

Parameters:

cheb_coeffs – Ascending Chebyshev coefficients of the real target, constant term first.

Returns:

Phase sequence in time order in the reflection convention.

Return type:

tuple[float, …]