API
Types
Sisyphus.Hamiltonian
— TypeHamiltonian(const_op::op,
ops::Vector{op}),
drives::Function) where {op<:AbstractOperator}
Structure to represent a time-dependent Hamiltonian.
NOTE: Drives are required to be real-valued functions and should be of the form drives(p::Vector{T}, t::T) where {T<:Real}
, where p
is a vector of real values parametrizing the control knobs and t
is the time.
Sisyphus.Transform
— TypeAbstract base class for transformations between states.
Sisyphus.StateTransform
— TypeStateTransform(input::Ket{B,T}, output::Ket{B,T}) where {B, T}
Represents a state to state transformation between two pure states.
Sisyphus.UnitaryTransform
— TypeUnitaryTransform(inputs::Vector{Ket{B, T}}, U::Matrix) where {B, T}
Represents a unitary transformation between two sets of states. The tranformation can be initialized with a vector of kets and a unitary matrix representing the desired transformation.
Sisyphus.CostFunction
— TypeCostFunction(distance, constraints)
Defines a cost function used for optimization.
Arguments
distance
denotes a distance measure between quantum states, it should be a real valued function for e.g. d(x,y) = 1 - real(x'*y)
where x
and y
are two complex valued vectors.
constraints
(optional) denotes the constraints on the shapes of pulses, it should be a real valued function
NOTE: During the optimization we minimize the total cost given by the sum of average distance (considering all states in the transform) evaluated for a given set of parameters and the constraints. i.e. d(x,y) + constraints(params)
.
Sisyphus.QOCProblem
— TypeQOCProblem(hamiltonian::Hamiltonian{T},
transform::Transform,
tspan::Tuple{T,T}},
cost::CostFunction) where {T<:Real}
Defines a quantum optimal control problem to be solved.
Sisyphus.AdjointSolver
— TypeAdjointSolver
Solver to evaluate gradients by solving the coupled equations, defined for compatibility with CommonSolve interface.
Sisyphus.Solution
— TypeSolution(params)
Contains the optimized parameters after solving the QOCProblem. It also contains traces of distance and constraints specified in the CostFunction. Optionally, it contains the full trace of parameters.
Functions
Sisyphus.schroedinger_dynamic
— Functionschroedinger_dynamic(tspan, psi, h, params; kwargs)
Wraps schroedinger_dynamic
from QuantumOptics by accepting our custom Hamiltonian
structure and the parameters.
Sisyphus.master_dynamic
— Functionmaster_dynamic(tspan, psi, h, params, J, rates; kwargs)
Wraps master_dynamic
from QuantumOptics by accepting our custom Hamiltonian
structure and the parameters.
Sisyphus.vectorize
— Functionvectorize(k::Ket)
Returns a ket representing the vectorized form of the density matrix of ket k
.
vectorize(trans::StateTransform)
Returns a vectorized form of the state to state transformation.
vectorize(trans::UnitaryTransform)
Returns a vectorized form of the unitary transformation.
vectorize(H, J, rates)
Vectorizes the Hamiltonian and jump operators so that they can be submitted to the Schroedinger time evolution solver. Uses the vectorization identity $\text{vec}(ABC) = (C^T \otimes A)\text{vec}(B)$.
Utilities
Sisyphus.heaviside
— Functionheaviside(t::T) where {T <: Real}
Heaviside step function
\[H(t) = \begin{cases} 1, & t > 0 \\ 0, & t \leq 0 \end{cases}.\]
Sisyphus.interval
— Functioninterval(t::T, a::T, b::T) where {T <: Real}
Interval function
\[ I(t; a, b) = H(t - a) - H(t - b).\]
Sisyphus.piecewise_const_interp
— Functionpiecewise_const_interp(p, t; t0, t1)
Piecewise constant interpolation of equidistant samples p
.
Sisyphus.linear_interp
— Functionlinear_interp(p, t; t0, t1)
Linear interpolation of equidistant samples p
.
Sisyphus.cubic_spline_interp
— Functioncubic_spline_interp(p, t; t0, t1)
Cubic spline interpolation of equidistant samples p
with natural boundary conditions.
GPU
Sisyphus.CuKet
— MethodCuKet(k::Ket)
Returns a Ket with the data allocated on GPU memory.
CUDA.cu
— Functioncu(A; unified=false)
Opinionated GPU array adaptor, which may alter the element type T
of arrays:
- For
T<:AbstractFloat
, it makes aCuArray{Float32}
for performance reasons. (Except thatFloat16
andBFloat16
element types are not changed.) - For
T<:Complex{<:AbstractFloat}
it makes aCuArray{ComplexF32}
. - For other
isbitstype(T)
, it makes aCuArray{T}
.
By contrast, CuArray(A)
never changes the element type.
Uses Adapt.jl to act inside some wrapper structs.
Examples
julia> cu(ones(3)')
1×3 adjoint(::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}) with eltype Float32:
1.0 1.0 1.0
julia> cu(zeros(1, 3); unified=true)
1×3 CuArray{Float32, 2, CUDA.Mem.UnifiedBuffer}:
0.0 0.0 0.0
julia> cu(1:3)
1:3
julia> CuArray(ones(3)') # ignores Adjoint, preserves Float64
1×3 CuArray{Float64, 2, CUDA.Mem.DeviceBuffer}:
1.0 1.0 1.0
julia> adapt(CuArray, ones(3)') # this restores Adjoint wrapper
1×3 adjoint(::CuArray{Float64, 1, CUDA.Mem.DeviceBuffer}) with eltype Float64:
1.0 1.0 1.0
julia> CuArray(1:3)
3-element CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}:
1
2
3
cu(h::Hamiltonian)
Converts the Hamiltonian with the operators allocated on GPU memory.
cu(trans::UnitaryTransform)
Returns a unitary transformation with the kets allocated on GPU memory.
cu(trans::StateTransform)
Returns a state to state transformation with the kets allocated on GPU memory.
cu(prob)
Turns a quantum optimal control problem into a form suitable for running on GPU.
Single precision
Base.convert
— Methodconvert(::Type{Float32}, prob::QOCProblem)
Returns a QOCProblem with all data in single precision.