QuantumCollocation.jl is a Julia package for solving quantum optimal control problems using direct collocation methods. It transforms continuous-time quantum control into finite-dimensional nonlinear programs (NLPs) solved efficiently with Ipopt.
using Pkg
Pkg.add("QuantumCollocation")Or from the Julia REPL, press ] to enter package mode:
pkg> add QuantumCollocation
Here's a complete example optimizing a Hadamard gate on a qubit:
using QuantumCollocation
using PiccoloQuantumObjects
# Define system: drift + 2 control Hamiltonians
H_drift = 0.1 * PAULIS.Z
H_drives = [PAULIS.X, PAULIS.Y]
drive_bounds = [1.0, 1.0] # symmetric bounds
sys = QuantumSystem(H_drift, H_drives, drive_bounds)
# 2. Create quantum trajectory. defines problem: system, target gate, timesteps
U_goal = GATES[:H]
T = 10.0
qtraj = UnitaryTrajectory(sys, U_goal, T) # creates zero pulse internally
# 3. Build optimization problem
N = 51 # number of timesteps
qcp = SmoothPulseProblem(qtraj, N; Q=100.0, R=1e-2)
# Solve!
solve!(qcp; options=IpoptOptions(max_iter=100))
# Check result
traj = get_trajectory(qcp)
println("Fidelity: ", fidelity(qcp))That's it! You've optimized control pulses for a quantum gate.
- Unitary gate optimization - Find pulses to implement quantum gates
- Open quantum systems - Find pulses for lindladian dynamics
- State transfer - Drive quantum states to target states
- Minimum time control - Optimize gate duration
- Robust control - Account for system uncertainties
- Multilevel systems - Handle transmons, bosonic codes, etc.
- Leakage suppression - Constrain populations in unwanted levels
- Custom constraints - Add your own physics constraints
QuantumCollocation.jl sets up and solves quantum control problems as nonlinear programs (NLPs). A generic quantum control problem looks like:
where
We provide problem templates for common quantum control tasks. These templates construct a DirectTrajOptProblem from DirectTrajOpt.jl with appropriate objectives, constraints, and dynamics.
Problem templates are organized by the type of quantum system being controlled:
MinimumTimeProblem- Minimize gate durationSamplingProblem- Robust control over system variationsSmoothPulseProblem- Optimize smooth pulses for unitary gatesSplinePulseProblem- Using higher order splines to characterize pulse shape
See the Problem Templates Overview for a detailed comparison and selection guide.
QuantumCollocation uses direct collocation - discretizing continuous-time dynamics into constraints at discrete time points (knot points). For example, a smooth pulse problem for a unitary gate:
The dynamics between knot points
- Efficient gradients - Sparse Jacobians and Hessians via automatic differentiation
- Flexible constraints - Add custom physics, leakage suppression, robustness
- Multiple integrators - Exponential, Pade, time-dependent dynamics
- Extensible - Easy to add new objectives, constraints, and problem templates
- 📚 Problem Templates Overview - Choose the right template for your problem
- 🎯 Working with Solutions - Extract results, evaluate fidelity, save data
- ⚙️ PiccoloOptions Reference - Configure solver options and constraints
- 💡 Two Qubit Gates, Single Qubit Gate - See complete examples from single qubits to multilevel systems (MOVING TO PICCOLO DOCS)
QuantumCollocation.jl is part of the Piccolo ecosystem:
- NamedTrajectories.jl - Trajectory data structures
- DirectTrajOpt.jl - Direct trajectory optimization framework
- PiccoloQuantumObjects.jl - Quantum operators and systems
- PiccoloPlots.jl - Visualization tools
Problem templates give the user the ability to add other constraints and objective functions to this problem and solve it efficiently using Ipopt.jl and MathOptInterface.jl under the hood (support for additional backends coming soon!).