Rollouts and fidelity
using PiccoloQuantumObjects
using NamedTrajectories
using SparseArrays # for visualization
using LinearAlgebraRollouts are simulations of a quantum system. In a rollout, controls are integrated forward in time using the dynamics implied by a provided quantum systems. The defualt is to use zero-order hold integration to simulate the evolution–-that is, the controls are held constant between time steps. For quantum states, the Schrödinger equation is used:
\[\psi(t + \Delta t) = \exp\left(-i H(\mathbf{a}(t)) \Delta t\right) \psi(t)\]
The visited states are collected into a matrix of size (2n, T), for the isomorphic Hilbert space dimension 2n and timesteps T.
All of the returned rollout are assumed to be real valued. It is helpful to use the appropriate isomorphisms to convert between real and complex quantum objects, and eachcol to iterate over the rollout columns.
There are rollouts for each kind of quantum object: quantum states, unitary operators, and density operators.
A fidelity function is also provided for each kind of quantum objectand a rollout fidelity function compares the final state of a rollout to a goal state.
Fidelity functions
The fidelity functions are used to measure how close two quantum states or operators are to each other.
fidelitycalculates the fidelity between two quantum states.unitary_fidelitycalculates the fidelity between two unitary operators.
State fidelity.
ψ = GATES.X * [1.0, 0.0]
ψ_goal = [0.0, 1.0]
fidelity(ψ, ψ_goal)1.0Unitary fidelity of orthogonal operations.
U = GATES.Y
U_goal = GATES.X
unitary_fidelity(U, U_goal)0.0Quantum State Rollouts
The rollout function simulates the evolution of a real valued quantum state under given controls and quantum system.
PiccoloQuantumObjects.Rollouts.rollout — Function
rollout(qtraj, args...; kwargs...)Roll out a quantum trajectory with new pulse or ODE parameters. Extended in quantum_trajectories module for specific trajectory types.
The rollout is a matrix of size (2n, T).
T = 10
ψ_init = ComplexF64[1.0, 0.0]
controls = rand(2, T)
Δt = fill(0.1, T)
system = QuantumSystem(PAULIS[:Z], [PAULIS[:X], PAULIS[:Y]], [(-1.0, 1.0), (-1.0, 1.0)])
ψ̃_rollout = rollout(ψ_init, controls, Δt, system)
ψ̃_rollout |> sizeQuantum State Rollout Fidelity
States must be cast to complex for the rollout to know the difference between real and isomorphic states.
ψ_goal = ComplexF64[0.0, 1.0]
rollout_fidelity(ψ_init, ψ_goal, controls, Δt, system)Don't forget to convert the quantum state to the appropriate isomorphism before calculating the fidelity.
fidelity(iso_to_ket(ψ̃_rollout[:, end]), ψ_goal)The initial state and goal are often inferred from the properly configured trajectory of a control problem.
components = (ψ̃ = zeros(Float64, size(ψ̃_rollout)), a = controls, Δt = Δt)
traj = NamedTrajectory(
components;
timestep=:Δt,
controls=:a,
initial=(ψ̃ = ket_to_iso(ψ_init),),
goal=(ψ̃ = ket_to_iso(ψ_goal),),
)
rollout_fidelity(traj, system)fidelity(iso_to_ket(traj.ψ̃[:, end]), ψ_goal)Unitary Rollouts
Missing docstring for unitary_rollout_fidelity. Check Documenter's build log for details.
Ũ⃗_rollout = unitary_rollout(controls, Δt, system)
Ũ⃗_rollout |> sizeConvert to unitary operators, and have a look at the initial unitary.
iso_vec_to_operator.(eachcol(Ũ⃗_rollout[:, 1])) |> firstOpen Quantum System Rollouts
Missing docstring for open_rollout_fidelity. Check Documenter's build log for details.
Open rollouts require open quantum systems.
open_system = OpenQuantumSystem(system)
ρ_init = ψ_init * ψ_init'
ρ̃⃗_rollout = open_rollout(ρ_init, controls, Δt, open_system)
ρ̃⃗_rollout |> sizeThis page was generated using Literate.jl.