Skip to main content

unipolator

Python package Python Version

Unitary Interpolation, allows for the fast repeated exponentiation of parametric Hamiltonians [1]. Construct propagators (and their derivatives) of time dependent quantum systems of the form $H(t) = H_0 + \sum_{i=1} c_i(t) H_i$ (for example in optimal control problems) or quantum circuits with parametric gates. We utilize a grid based interpolation scheme to calculate propagators from cached matrix decompositions. The computation of a propagator for a time step is as fast as a single Trotter step, but with the ability to achieve machine precision.

Update: Now supports numpy $\geq$ 2.0.

To reproduce the plots from the publication (see the .ipynb scripts in the test/ folder) use python $\leq$ 3.10, as tikzplotlib currently does not support python 3.11.

Install and Import

Install via

pip install unipolator

and then simply import into a project via

from unipolator import *

Initialize the Unitary Interpolation Object:

Describe a system with a double complex array of Hamiltonians H_s, with H_s[i,...] = H_i ∆t, so that for $n$ control Hamiltonians H_s is a $(n+1) \times d \times d$ array for a $d$ dimensional Hilbert space. Define the bounds of the interpolation (hyper-) volume via $n$ dimensional double arrays c_mins and c_maxs and define the number of bins for every dimension via the $n$ dimensional int64 array c_bins, to initialize the unitary interpolation cache

ui = UI(H_s, c_mins, c_maxs, c_bins)  

Equivalently if we wish to propagate only wavevectors $\ket{\psi(t)} = U(t) \ket{\psi(0)}$ we initialize the unitary interpolation cache via

ui_vector = UI_vector(H_s, c_mins, c_maxs, c_bins, m)  

where m is the number of wavevectors that are calculated in parallel. The package contains further methods listed at the bottom of this document.

Automatic Binning

The method UI_bins automatically calculates the optimal binning for a target infidelity (default I_tar=1e-10). Use via

bins = UI_bins(H_s, c_mins, c_maxs, I_tar=1e-10)

By calling

ui = UI_auto(H_s, c_mins, c_maxs, I_tar=1e-10)

or

ui_vector = UI_vector_auto(H_s, c_mins, c_maxs, I_tar=1e-10, m)

this method is called automatically during the initialization of the unitary interpolation cache.

Calculate:

We can now use ui to calculate matrix exponentials, their derivatives, pulse sequences, and their gradients via the following methods:

  1. expmH calculates the unitary $U = \exp(-i H(c) \Delta t)$ for a given set of coefficients c (double array of length $n$), pass U_ui to the method to store the result (this avoids allocating new memory for every call, and allows reusing the same arrays)

    ui.expmH( c, U_ui)  
    

    Similarly we pass two $d \times m$ arrays V_in and V_out, with the $m$ input wavevectors and for the propagated wavevectors, via

    ui_vector.expmH( c, V_in, V_out)
    
  2. dexpmH also outputs the derivatives of the unitaris (wavevectors) with respect to the control paracters c. This requires the additional passing of a $n \times d \times d$ array dU to store the derivatives in

    ui.dexpmH( c, U, dU)
    

    During the initalization we can also select which dervatives we wish to compute, via the additional argument which_diffs which requires an int64 array with the indexes of the control parameters for which we wish to compute the derivatives.

    In the wavevector case, we replace the output variable dU with an additional $n \times m \times n$ arrays dV_out, so that

    ui_vector.dexpmH( c, V_in, V_out, dV_out)
    
  3. expmH_pulse calculates the propagator of a piecewise constant pulse for a given set of coefficients c_s, now a 2d array of shape $N \times n$, where $N$ is the number of timesteps

    ui.expmH_pulse(cs, U)
    
  4. grape calculates the infidelity of such a pulse with respect to a arget unitary U_target (using the indexes target_indexes of U_target), as well as the gradients of the control parameters along the pulse by using the GRAPE trick. We pass an array dI_dj of shape $n \times N$ to store the gradients at every time step for every control parameter

    ui.grape(cs, U_target, target_indexes, U, dU, dI_dj)
    

Other Methods:

The package also contains classes for eigenvalue based exponentiations, Krylov based exponentiations and (symmetric-) Trotterisations, namely

  • Hamiltonian_System(H_s),

  • Hamiltonian_System_vector(H_s, m), where m is the number of wavevectors that are calculated in parallel,

  • Trotter_System=(H_s, m_times), where m_times is the number of doublings $2^\mathrm{m}$ Trotter steps,

  • Symmetric_Trotter_System=(H_s, m_times),

  • Trotter_System_vector(H_s, n_times) where n_times is the number of performed Trotter steps ,

  • Symmetric_Trotter_System_vector(H_s, n_times).

  • In the test Subdirectory we provide additional functions to generate Random Hamiltonians, construct infidelities and more.

Author:

Michael Schilling

References:

[1] Schilling, Michael, et al. Exponentiation of Parametric Hamiltonians via Unitary Interpolation arxiv.org/abs/2402.01498

Metadata

Release files for unipolator 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unipolator 0.3.7
File Size Uploaded Provenance
unipolator-0.3.7.tar.gz 2.0 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for unipolator 0.3.7
File Interpreter ABI Platform
unipolator-0.3.7-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details

Total release size: 3.5 MB

Release files / unipolator-0.3.7.tar.gz

Download URL unipolator-0.3.7.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
ec19ff2cb21516003f5b7b874f4c9935fc047e5d61b805fe8d890f34d2398343
BLAKE2b-256 checksum
How to use checksums
0de6462d9ec7d30a2fdd36b8a72ed9ceda9228c458ea900cc1391dd91f976935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.4

Release files / unipolator-0.3.7-cp39-cp39-win_amd64.whl

Download URL unipolator-0.3.7-cp39-cp39-win_amd64.whl
Size 1.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
c5a76aab49a89c5c04be73af6cb06bbf20acf3e99d9c41ace5c9a79cd141cfc0
BLAKE2b-256 checksum
How to use checksums
8a197803fdb08b99e5acd43c0401b5178d44a2b8c3571eb993ad151606cd90a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.4

Security for unipolator 0.3.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page