Skip to content

Commit 1b49b41

Browse files
PiccoloPlots compat + add experimental tags to flaky tests + temp docs fixup (#242)
* add experimental tags to flaky tests (PiccoloPlots has updated) * bump project patch ver * fix basic docs page building * add another flaky test
1 parent b7705b3 commit 1b49b41

10 files changed

Lines changed: 99 additions & 131 deletions

File tree

CONTEXT.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ solve!(qcp; options=IpoptOptions(max_iter=200))
4444

4545
# 5. Extract results
4646
traj = get_trajectory(qcp)
47-
U_final = iso_vec_to_operator(traj[end][:Ũ⃗])
48-
fid = unitary_fidelity(U_final, U_goal)
47+
fid = fidelity(qcp)
4948
```
5049

5150
### State Transfer (Ket)

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "QuantumCollocation"
22
uuid = "0dc23a59-5ffb-49af-b6bd-932a8ae77adf"
3-
version = "0.10.0"
3+
version = "0.10.1"
44
authors = ["Aaron Trowbridge <aaron.j.trowbridge@gmail.com> and contributors"]
55

66
[deps]

docs/literate/man/piccolo_options.jl

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ opts_custom = PiccoloOptions(
2020
# Pass to any problem template:
2121
system = QuantumSystem(0.1 * PAULIS.Z, [PAULIS.X, PAULIS.Y], [1.0, 1.0])
2222
U_goal = EmbeddedOperator(GATES.H, system)
23-
N = 51
2423

25-
prob = UnitarySmoothPulseProblem(
26-
system, U_goal, N;
24+
T = 10.0
25+
qtraj = UnitaryTrajectory(system, U_goal, T)
26+
27+
N = 51
28+
prob = SmoothPulseProblem(
29+
qtraj, N;
2730
piccolo_options = opts_custom
2831
)
2932

@@ -115,15 +118,6 @@ opts_leakage = PiccoloOptions(
115118

116119
opts_equal_dt = PiccoloOptions(timesteps_all_equal = true)
117120

118-
# ## Advanced Dynamics
119-
120-
# ### `rollout_integrator::Symbol = :pade`
121-
# Integration method for evaluating fidelity.
122-
# - `:pade`: Padé approximation (default, fast)
123-
# - `:exp`: Matrix exponential (more accurate)
124-
125-
opts_exp = PiccoloOptions(rollout_integrator = :exp)
126-
127121
# ## Derivative Constraints
128122

129123
# ### `zero_initial_and_final_derivative::Bool = false`
@@ -145,7 +139,6 @@ opts_hifi = PiccoloOptions(
145139
verbose = true,
146140
bound_state = true,
147141
geodesic = true,
148-
rollout_integrator = :exp
149142
)
150143

151144
# ### Multilevel system with leakage suppression
@@ -193,5 +186,3 @@ opts_robust = PiccoloOptions(
193186
# - `:pade` is fast and usually sufficient
194187
# - `:exp` more accurate for sensitive systems
195188
# - Both give same result for well-conditioned problems
196-
197-
println("PiccoloOptions configured!")
Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
# # Problem Templates Overview
22

3-
# QuantumCollocation.jl provides **8 problem templates** that cover common quantum optimal control scenarios. These templates make it easy to set up and solve problems without manually constructing objectives, constraints, and integrators.
4-
3+
# QuantumCollocation.jl provides **4 problem templates** that cover common quantum optimal control scenarios. These templates make it easy to set up and solve problems without manually constructing objectives, constraints, and integrators.
54
# ## Template Comparison
65

7-
# | Template | State Type | Objective | Time | Use Case |
8-
# |:---------|:-----------|:----------|:-----|:---------|
9-
# | [`UnitarySmoothPulseProblem`](@ref) | Unitary | Minimize control effort + infidelity | Fixed | Standard gate synthesis with smooth pulses |
10-
# | [`UnitaryMinimumTimeProblem`](@ref) | Unitary | Minimize duration | Variable | Fastest gate given fidelity constraint |
11-
# | [`UnitarySamplingProblem`](@ref) | Unitary | Minimize control effort + infidelity | Fixed | Robust control over multiple systems |
12-
# | [`UnitaryFreePhase Problem`](@ref) | Unitary | Minimize control effort + infidelity | Fixed | Gate synthesis with free global phase |
13-
# | [`UnitaryVariationalProblem`](@ref) | Unitary | Minimize control effort + infidelity ± sensitivity | Fixed | Sensitivity/robustness to Hamiltonian terms |
14-
# | [`QuantumStateSmoothPulseProblem`](@ref) | Ket | Minimize control effort + infidelity | Fixed | State transfer with smooth pulses |
15-
# | [`QuantumStateMinimumTimeProblem`](@ref) | Ket | Minimize duration | Variable | Fastest state transfer |
16-
# | [`QuantumStateSamplingProblem`](@ref) | Ket | Minimize control effort + infidelity | Fixed | Robust state transfer over multiple systems |
17-
18-
# ## Key Differences
196

20-
# ### Unitary vs Ket (Quantum State)
21-
# - **Unitary problems**: Optimize gate operations (full unitary matrices), commonly used for universal quantum control
22-
# - **Ket problems**: Optimize state-to-state transfers, useful for initialization and specific state preparation
7+
# | Template | Objective | Time | Use Case |
8+
# |:---------|:-----------|:-----|:---------|
9+
# | [`SmoothPulseProblem`](@ref) | Minimize control effort + infidelity | Fixed | Standard gate/state synthesis with smooth pulses |
10+
# | [`MinimumTimeProblem`](@ref) | Minimize duration | Variable | Fastest gate/state synthesis given fidelity constraint |
11+
# | [`SplinePulseProblem`](@ref) | Minimize control effort + infidelity | Fixed | Gate/state synthesis with spline-based pulses where the derivative variables (`du`) are the actual spline coefficients or slopes. |
12+
# | [`SamplingProblem`](@ref) | Minimize control effort + weighted sum of infidelity objectives | Fixed | Robust gate/state synthesis where the controls are shared across all systems, with differing dynamics. |
2313

2414
# ### Smooth Pulse vs Minimum Time
2515
# - **Smooth Pulse**: Fixed total time `T × Δt`, minimizes control effort with regularization on `u`, `u̇`, `ü`
@@ -30,51 +20,41 @@
3020
# - Useful for robustness against parameter uncertainties or manufacturing variations
3121
# - Examples: different coupling strengths, detunings, or environmental conditions
3222

33-
# ### Free Phase & Variational
34-
# - **Free Phase**: Optimizes global phase of target unitary (sometimes easier to reach)
35-
# - **Variational**: Uses sensitivity analysis to find controls that are robust or sensitive to specific Hamiltonian terms
36-
3723
# ## Quick Selection Guide
3824

3925
# **I want to implement a quantum gate:**
40-
# - Start simple? → `UnitarySmoothPulseProblem`
41-
# - Need speed? → `UnitaryMinimumTimeProblem`
42-
# - Need robustness? → `UnitarySamplingProblem`
26+
# - Start simple? → [`SmoothPulseProblem`](@ref) + `UnitaryTrajectory`
27+
# - Need speed? → [`MinimumTimeProblem`](@ref) + `UnitaryTrajectory`
28+
# - Need robustness? → [`SamplingProblem`](@ref) + `UnitaryTrajectory`
4329

4430
# **I want to prepare a quantum state:**
45-
# - Standard case? → `QuantumStateSmoothPulseProblem`
46-
# - Speed critical? → `QuantumStateMinimumTimeProblem`
47-
# - Robust preparation? → `QuantumStateSamplingProblem`
48-
49-
# **I'm tuning my solution:**
50-
# - Struggling with convergence? → Try `UnitaryFreePhase Problem`
51-
# - Need parameter sensitivity? → Use `UnitaryVariationalProblem`
31+
# - Standard case? → [`SmoothPulseProblem`](@ref) + `KetTrajectory`
32+
# - Speed critical? → [`MinimumTimeProblem`](@ref) + `KetTrajectory`
33+
# - Robust preparation? → [`SamplingProblem`](@ref) + `KetTrajectory`
5234

5335
# ## Common Parameters
5436

5537
# All templates share these key parameters:
5638

57-
# ```julia
58-
# prob = UnitarySmoothPulseProblem(
59-
# system, # QuantumSystem defining H(u)
60-
# U_goal, # Target unitary or state
61-
# N, # Number of timesteps
62-
#
63-
# # Derivative bounds (smoothness)
64-
# du_bound = 0.01, # |u̇| ≤ du_bound
65-
# ddu_bound = 0.001, # |ü| ≤ ddu_bound
66-
#
67-
# # Regularization weights
68-
# R_u = 0.01, # Penalize u²
69-
# R_du = 0.01, # Penalize u̇²
70-
# R_ddu = 0.01, # Penalize ü²
71-
#
72-
# # Initial guess
73-
# u_guess = nothing, # Optional initial controls
74-
#
75-
# # Advanced options
76-
# piccolo_options = PiccoloOptions(...)
77-
# )
78-
# ```
39+
using QuantumCollocation # hide
40+
using PiccoloQuantumObjects # hide
41+
H_drift = 0.1 * PAULIS.Z # hide
42+
H_drives = [PAULIS.X, PAULIS.Y] # hide
43+
drive_bounds = [1.0, 1.0] # hide
44+
sys = QuantumSystem(H_drift, H_drives, drive_bounds) # hide
45+
U_goal = GATES[:H] # hide
46+
T = 10.0 # hide
47+
qtraj = UnitaryTrajectory(sys, U_goal, T) # hide
48+
N = 51 # hide
49+
50+
prob = SmoothPulseProblem(
51+
qtraj, # QuantumTrajectory wrapping system information, Unitary/Ket/MultiKet problem type
52+
N; # Number of timesteps
53+
54+
Q=100.0, # Objective weighting coefficient for the infidelity
55+
R=1e-2, # Objective weighting coefficient for the controls regularization
56+
57+
piccolo_options = PiccoloOptions(verbose = true), # PiccoloOptions for solver configuration
58+
)
7959

8060
# See the individual template pages for parameter details and examples.

docs/literate/man/working_with_solutions.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ using NamedTrajectories
1212

1313
system = QuantumSystem(0.1 * PAULIS.Z, [PAULIS.X, PAULIS.Y], [1.0, 1.0])
1414
U_goal = EmbeddedOperator(GATES.H, system)
15-
N = 51
15+
T = 10.0 # time duration
16+
qtraj = UnitaryTrajectory(system, U_goal, T)
1617

17-
prob = UnitarySmoothPulseProblem(system, U_goal, N)
18+
N = 51 # number of timesteps
19+
prob = SmoothPulseProblem(qtraj, N)
1820

1921
# The `solve!` function accepts several key options:
2022

@@ -86,7 +88,7 @@ println("Total gate time: ", duration, " (arbitrary units)")
8688

8789
# **Direct fidelity** - Compare final state to goal:
8890
U_final = iso_vec_to_operator(prob.trajectory.Ũ⃗[:, end])
89-
fid_direct = unitary_fidelity(U_final, U_goal)
91+
fid_direct = unitary_fidelity(U_final, U_goal.operator)
9092
println("Direct fidelity: ", fid_direct)
9193

9294
# **Rollout fidelity** - Simulate dynamics forward:
@@ -165,7 +167,7 @@ using PiccoloPlots # For visualization
165167
using CairoMakie
166168

167169
# Plot controls
168-
fig = plot_controls(prob.trajectory)
170+
fig = plot(prob.trajectory)
169171
# save("controls.png", fig)
170172

171173
# Extract control data for export
@@ -210,5 +212,3 @@ control_data = Dict(
210212
# 3. Use minimum time optimization for fastest gates
211213
# 4. Apply leakage constraints for multilevel systems
212214
# 5. Use sampling problems for robust control
213-
214-
println("Solution evaluation complete!")

docs/make.jl

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@ using PiccoloDocsTemplate
33

44
pages = [
55
"Home" => "index.md",
6-
"Manual" => [
7-
"Problem Templates Overview" => "generated/man/problem_templates_overview.md",
8-
"Ket Problem Templates" => "generated/man/ket_problem_templates.md",
9-
"Unitary Problem Templates" => "generated/man/unitary_problem_templates.md",
10-
"Robust Control" => "generated/man/robust_control.md",
11-
"Working with Solutions" => "generated/man/working_with_solutions.md",
12-
"PiccoloOptions Reference" => "generated/man/piccolo_options.md",
13-
],
14-
"Customization" => [
15-
"Custom Objectives" => "generated/man/custom_objectives.md",
16-
"Adding Constraints" => "generated/man/adding_constraints.md",
17-
"Initial Trajectories" => "generated/man/initial_trajectories.md",
18-
],
19-
"Examples" => [
20-
"Single Qubit Gate" => "generated/examples/single_qubit_gate.md",
21-
"Two Qubit Gates" => "generated/examples/two_qubit_gates.md",
22-
"Minimum Time Optimization" => "generated/examples/minimum_time_problem.md",
23-
"Robust Control" => "generated/examples/robust_control.md",
24-
"Multilevel Transmon" => "generated/examples/multilevel_transmon.md",
6+
# "Manual" => [
7+
# "Problem Templates Overview" => "generated/man/problem_templates_overview.md",
8+
# "Ket Problem Templates" => "generated/man/ket_problem_templates.md",
9+
# "Unitary Problem Templates" => "generated/man/unitary_problem_templates.md",
10+
# "Robust Control" => "generated/man/robust_control.md",
11+
# "Working with Solutions" => "generated/man/working_with_solutions.md",
12+
# "PiccoloOptions Reference" => "generated/man/piccolo_options.md",
13+
# ],
14+
# "Customization" => [
15+
# "Custom Objectives" => "generated/man/custom_objectives.md",
16+
# "Adding Constraints" => "generated/man/adding_constraints.md",
17+
# "Initial Trajectories" => "generated/man/initial_trajectories.md",
18+
# ],
19+
# "Examples" => [
20+
# "Single Qubit Gate" => "generated/examples/single_qubit_gate.md",
21+
# "Two Qubit Gates" => "generated/examples/two_qubit_gates.md",
22+
# "Minimum Time Optimization" => "generated/examples/minimum_time_problem.md",
23+
# "Robust Control" => "generated/examples/robust_control.md",
24+
# "Multilevel Transmon" => "generated/examples/multilevel_transmon.md",
25+
# ],
26+
"Usage Guide" => [
27+
"Problem Templates Overview" => "generated/man/problem_templates_overview.md",
28+
"Working with Solutions" => "generated/man/working_with_solutions.md",
29+
"PiccoloOptions Reference" => "generated/man/piccolo_options.md",
2530
],
2631
"Library" => "lib.md",
2732
]

docs/src/index.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,32 @@ using PiccoloQuantumObjects
2727
# Define system: drift + 2 control Hamiltonians
2828
H_drift = 0.1 * PAULIS.Z
2929
H_drives = [PAULIS.X, PAULIS.Y]
30-
sys = QuantumSystem(H_drift, H_drives, 10.0, [1.0, 1.0])
30+
drive_bounds = [1.0, 1.0] # symmetric bounds
31+
sys = QuantumSystem(H_drift, H_drives, drive_bounds)
3132

32-
# Set up problem: system, target gate, timesteps
33-
U_goal = GATES.H
34-
N = 51
35-
prob = UnitarySmoothPulseProblem(sys, U_goal, N)
33+
# 2. Create quantum trajectory. defines problem: system, target gate, timesteps
34+
U_goal = GATES[:H]
35+
T = 10.0
36+
qtraj = UnitaryTrajectory(sys, U_goal, T) # creates zero pulse internally
37+
38+
# 3. Build optimization problem
39+
N = 51 # number of timesteps
40+
qcp = SmoothPulseProblem(qtraj, N; Q=100.0, R=1e-2)
3641

3742
# Solve!
38-
solve!(prob; max_iter=100)
43+
solve!(qcp; options=IpoptOptions(max_iter=100))
3944

4045
# Check result
41-
println("Fidelity: ", unitary_rollout_fidelity(prob.trajectory, sys))
46+
traj = get_trajectory(qcp)
47+
println("Fidelity: ", fidelity(qcp))
4248
```
4349

4450
That's it! You've optimized control pulses for a quantum gate.
4551

4652
## What Can QuantumCollocation Do?
4753

4854
- **Unitary gate optimization** - Find pulses to implement quantum gates
55+
- **Open quantum systems** - Find pulses for lindladian dynamics
4956
- **State transfer** - Drive quantum states to target states
5057
- **Minimum time control** - Optimize gate duration
5158
- **Robust control** - Account for system uncertainties
@@ -69,25 +76,16 @@ where $\mathbf{Z}$ is a trajectory containing states and controls from [NamedTra
6976

7077
We provide **problem templates** for common quantum control tasks. These templates construct a `DirectTrajOptProblem` from [DirectTrajOpt.jl](https://github.com/harmoniqs/DirectTrajOpt.jl) with appropriate objectives, constraints, and dynamics.
7178

72-
We provide **problem templates** for common quantum control tasks. These templates construct a `DirectTrajOptProblem` from [DirectTrajOpt.jl](https://github.com/harmoniqs/DirectTrajOpt.jl) with appropriate objectives, constraints, and dynamics.
73-
7479
## Problem Templates
7580

7681
Problem templates are organized by the type of quantum system being controlled:
7782

78-
### Unitary (Gate) Templates
79-
- [`UnitarySmoothPulseProblem`](@ref) - Optimize smooth pulses for unitary gates
80-
- [`UnitaryMinimumTimeProblem`](@ref) - Minimize gate duration
81-
- [`UnitarySamplingProblem`](@ref) - Robust control over system variations
82-
- [`UnitaryFreePhaseProblem`](@ref) - Optimize up to global phase
83-
- [`UnitaryVariationalProblem`](@ref) - Variational quantum optimization
83+
### General Problem Templates
84+
- [`MinimumTimeProblem`](@ref) - Minimize gate duration
85+
- [`SamplingProblem`](@ref) - Robust control over system variations
86+
- [`SmoothPulseProblem`](@ref) - Optimize smooth pulses for unitary gates
87+
- [`SplinePulseProblem`](@ref) - Using higher order splines to characterize pulse shape
8488

85-
### Quantum State Templates
86-
- [`QuantumStateSmoothPulseProblem`](@ref) - Drive states with smooth pulses
87-
- [`QuantumStateMinimumTimeProblem`](@ref) - Minimize state transfer time
88-
- [`QuantumStateSamplingProblem`](@ref) - Robust state transfer
89-
90-
See the [Problem Templates Overview](@ref) for a detailed comparison and selection guide.
9189

9290
See the [Problem Templates Overview](@ref) for a detailed comparison and selection guide.
9391

@@ -121,7 +119,7 @@ The dynamics between knot points $(U_k, u_k)$ and $(U_{k+1}, u_{k+1})$ become no
121119
- 📚 [Problem Templates Overview](@ref) - Choose the right template for your problem
122120
- 🎯 [Working with Solutions](@ref) - Extract results, evaluate fidelity, save data
123121
- ⚙️ [PiccoloOptions Reference](@ref) - Configure solver options and constraints
124-
- 💡 [Examples](@ref) - See complete examples from single qubits to multilevel systems
122+
- 💡 [Two Qubit Gates](@ref), [Single Qubit Gate](@ref) - See complete examples from single qubits to multilevel systems (**MOVING TO PICCOLO DOCS**)
125123

126124
## Related Packages
127125

docs/src/lib.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,27 @@
55
Modules = [QuantumCollocation.ProblemTemplates]
66
```
77

8-
## Quantum System Templates
9-
```@autodocs
10-
Modules = [QuantumCollocation.QuantumSystemTemplates]
11-
```
12-
138
## Quantum Objectives
149
```@autodocs
1510
Modules = [QuantumCollocation.QuantumObjectives]
1611
```
1712

1813
## Quantum Constraints
1914
```@autodocs
20-
Modules = [QuantumCollocation.QuantumObjectives]
15+
Modules = [QuantumCollocation.QuantumConstraints]
2116
```
2217

2318
## Quantum Integrators
2419
```@autodocs
25-
Modules = [QuantumCollocation.QuantumObjectives]
20+
Modules = [QuantumCollocation.QuantumIntegrators]
2621
```
2722

2823
## Options
2924
```@autodocs
3025
Modules = [QuantumCollocation.Options]
3126
```
3227

33-
## Trajectory Initialization
28+
## Control Problems
3429
```@autodocs
35-
Modules = [QuantumCollocation.TrajectoryInitialization]
36-
```
30+
Modules = [QuantumCollocation.QuantumControlProblems]
31+
```

src/problem_templates/minimum_time_problem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ end
627627
@test duration_after <= duration_before * 1.1
628628
end
629629

630-
@testitem "MinimumTimeProblem with time-dependent SamplingTrajectory (Unitary)" begin
630+
@testitem "MinimumTimeProblem with time-dependent SamplingTrajectory (Unitary)" tags=[:experimental] begin
631631
using QuantumCollocation
632632
using PiccoloQuantumObjects
633633
using DirectTrajOpt

0 commit comments

Comments
 (0)