Skip to content

Commit

Permalink
core peeloff (#173)
Browse files Browse the repository at this point in the history
* moving otimes to isomorphisms

* manifest update

* integrator signature refactor -- removes sys dependence

* problem template fixes (tests passing)

* moved isomorphisms to core

* big rip

* big rip 2: quantum objects

* traj init for unitary

* state sampling problem template

* refactored system to integrator interface

* density operators

* traj init for unitary

* state sampling problem template

* bug fix: a_guess option

* bug fix: free phase obj

* phase rollout fidelity

* free phase initialization

* Tests for free phases

* free phase incr

* bug fix: mintime and robprob fidelity subspace

* bug fix: drop drive_sigma arg, fix subspace nothing

* problem template fixes (tests passing)

* big rip

* refactored system to integrator interface

* density operators

* rebase fixes (broken)

* rebase complete (fixes free phase loss)

* docs uopdates

* renaming OperatorType -> AbstractPiccoloOperator

* adding quantum system templates + cleaning

* update system type from AbstractQuantumSystem to OpenQuantumSystem and clean up function parameters

* refactor trajectory initialization to use density_to_iso_vec for initial and goal states

* refactor rollout_fidelity to have sys as arg

* passing tests (except for direct sum prob)

* refactor add_suffix and remove_suffix functions to eliminate sys parameter and streamline integrator modifications

* bump version to 0.5.0 and update dependencies for compatibility

* remove operatortype

* add back in zero initial and final

* revert removing list of state names

* refactor callbacks and problem templates to use rollout fidelity and system return values

* update Project.toml dependencies and refactor drive length references in quantum state sampling problems

* fix callbacks except for new tol

* remove fidelity test from callback test suite - see PR comment #173

* add qualified path for get_datavec

---------

Co-authored-by: Andy Goldschmidt <agoldschmidt11@gmail.com>
Co-authored-by: Jack Champagne <jackchampagne.r@gmail.com>
Co-authored-by: Jack Champagne <jchampag@andrew.cmu.edu>
  • Loading branch information
4 people authored Jan 15, 2025
1 parent b20cb25 commit cafef27
Show file tree
Hide file tree
Showing 65 changed files with 701 additions and 9,297 deletions.
23 changes: 15 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumCollocation"
uuid = "0dc23a59-5ffb-49af-b6bd-932a8ae77adf"
authors = ["Aaron Trowbridge <aaron.j.trowbridge@gmail.com> and contributors"]
version = "0.3.2"
version = "0.5.0"

[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Expand All @@ -11,13 +11,15 @@ Einsum = "b7d42ee7-0b51-5a75-98ca-779d3107e4c0"
ExponentialAction = "e24c0720-ea99-47e8-929e-571b494574d3"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
NamedTrajectories = "538bc3a1-5ab9-4fc3-b776-35ca1e893e08"
PiccoloQuantumObjects = "5a402ddf-f93c-42eb-975e-5582dcda653d"
PkgTemplates = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
QuantumCollocationCore = "2b384925-53cb-4042-a8d2-6faa627467e1"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand All @@ -27,24 +29,29 @@ TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
TrajectoryIndexingUtils = "6dad8b7f-dd9a-4c28-9b70-85b9a079bfc8"

[compat]
BenchmarkTools = "1.5"
BenchmarkTools = "1.6"
CairoMakie = "0.12"
Distributions = "0.25"
Einsum = "0.4"
ExponentialAction = "0.2"
ForwardDiff = "0.10"
Interpolations = "0.15"
Ipopt = "1.6"
JLD2 = "0.5"
MathOptInterface = "1.31"
NamedTrajectories = "0.2.4"
LinearAlgebra = "1.10, 1.11"
MathOptInterface = "1.35"
NamedTrajectories = "0.2"
PiccoloQuantumObjects = "0.1"
PkgTemplates = "0.7"
ProgressMeter = "1.10"
QuantumCollocationCore = "0.1"
Random = "1.10, 1.11"
Reexport = "1.2"
Symbolics = "6.14"
SparseArrays = "1.10, 1.11"
Symbolics = "6.22"
TestItemRunner = "1.0"
TestItems = "1.0"
TrajectoryIndexingUtils = "0.1"
julia = "1.10"
julia = "1.10, 1.11"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
NamedTrajectories = "538bc3a1-5ab9-4fc3-b776-35ca1e893e08"
QuantumCollocation = "0dc23a59-5ffb-49af-b6bd-932a8ae77adf"
QuantumCollocationCore = "2b384925-53cb-4042-a8d2-6faa627467e1"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"

[compat]
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/examples/multilevel_transmon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ solve!(prob; max_iter=50)

# Let's look at the fidelity in the subspace

println("Fidelity: ", unitary_fidelity(prob; subspace=op.subspace_indices))
println("Fidelity: ", unitary_rollout_fidelity(prob; subspace=op.subspace_indices))

# and plot the result using the `plot_unitary_populations` function.

Expand All @@ -96,7 +96,7 @@ solve!(prob_leakage; max_iter=50)

# Let's look at the fidelity in the subspace

println("Fidelity: ", unitary_fidelity(prob_leakage; subspace=op.subspace_indices))
println("Fidelity: ", unitary_rollout_fidelity(prob_leakage; subspace=op.subspace_indices))

# and plot the result using the `plot_unitary_populations` function.

Expand Down
8 changes: 4 additions & 4 deletions docs/literate/examples/two_qubit_gates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ prob = UnitarySmoothPulseProblem(
solve!(prob; max_iter=100)

## Let's take a look at the final fidelity
unitary_fidelity(prob)
unitary_rollout_fidelity(prob)

# Looks good!

Expand All @@ -124,7 +124,7 @@ min_time_prob = UnitaryMinimumTimeProblem(prob; final_fidelity=.99)

solve!(min_time_prob; max_iter=300)

unitary_fidelity(min_time_prob)
unitary_rollout_fidelity(min_time_prob)

# And let's plot this solution
plot_unitary_populations(min_time_prob)
Expand Down Expand Up @@ -176,7 +176,7 @@ prob = UnitarySmoothPulseProblem(
solve!(prob; max_iter=1_000)

## Let's take a look at the final fidelity
unitary_fidelity(prob)
unitary_rollout_fidelity(prob)

# Again, looks good!

Expand All @@ -190,7 +190,7 @@ min_time_prob = UnitaryMinimumTimeProblem(prob; final_fidelity=.999)

solve!(min_time_prob; max_iter=300)

unitary_fidelity(min_time_prob)
unitary_rollout_fidelity(min_time_prob)

# And let's plot this solution

Expand Down
4 changes: 2 additions & 2 deletions docs/literate/quickstart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ solve!(prob; max_iter=30)

# The above output comes from the Ipopt.jl solver. To see the final fidelity we can use the `unitary_fidelity` function exported by QuantumCollocation.jl.

println("Final fidelity: ", unitary_fidelity(prob))
println("Final fidelity: ", unitary_rollout_fidelity(prob))

# We can also easily plot the solutions using the `plot` function exported by NamedTrajectories.jl.

Expand Down Expand Up @@ -86,7 +86,7 @@ solve!(prob_min_time; max_iter=30)

# We can see that the final fidelity is indeed greater than the minimum fidelity we set.

println("Final fidelity: ", unitary_fidelity(prob_min_time))
println("Final fidelity: ", unitary_rollout_fidelity(prob_min_time))

# and that the duration of the pulse has decreased.

Expand Down
2 changes: 0 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ push!(LOAD_PATH, joinpath(@__DIR__, "..", "src"))

# DocMeta.setdocmeta!(QuantumCollocation, :DocTestSetup, :(using QuantumCollocation); recursive=true)

println("")

pages = [
"Home" => "index.md",
"Quickstart Guide" => "generated/quickstart.md",
Expand Down
4 changes: 2 additions & 2 deletions docs/src/generated/examples/multilevel_transmon.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ solve!(prob; max_iter=50)
Let's look at the fidelity in the subspace

````@example multilevel_transmon
println("Fidelity: ", unitary_fidelity(prob; subspace=op.subspace_indices))
println("Fidelity: ", unitary_rollout_fidelity(prob; subspace=op.subspace_indices))
````

and plot the result using the `plot_unitary_populations` function.
Expand Down Expand Up @@ -114,7 +114,7 @@ solve!(prob_leakage; max_iter=50)
Let's look at the fidelity in the subspace

````@example multilevel_transmon
println("Fidelity: ", unitary_fidelity(prob_leakage; subspace=op.subspace_indices))
println("Fidelity: ", unitary_rollout_fidelity(prob_leakage; subspace=op.subspace_indices))
````

and plot the result using the `plot_unitary_populations` function.
Expand Down
8 changes: 4 additions & 4 deletions docs/src/generated/examples/two_qubit_gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ prob = UnitarySmoothPulseProblem(
solve!(prob; max_iter=100)
# Let's take a look at the final fidelity
unitary_fidelity(prob)
unitary_rollout_fidelity(prob)
````

Looks good!
Expand All @@ -138,7 +138,7 @@ min_time_prob = UnitaryMinimumTimeProblem(prob; final_fidelity=.99)
solve!(min_time_prob; max_iter=300)
unitary_fidelity(min_time_prob)
unitary_rollout_fidelity(min_time_prob)
````

And let's plot this solution
Expand Down Expand Up @@ -194,7 +194,7 @@ prob = UnitarySmoothPulseProblem(
solve!(prob; max_iter=1_000)
# Let's take a look at the final fidelity
unitary_fidelity(prob)
unitary_rollout_fidelity(prob)
````

Again, looks good!
Expand All @@ -212,7 +212,7 @@ min_time_prob = UnitaryMinimumTimeProblem(prob; final_fidelity=.999)
solve!(min_time_prob; max_iter=300)
unitary_fidelity(min_time_prob)
unitary_rollout_fidelity(min_time_prob)
````

And let's plot this solution
Expand Down
4 changes: 2 additions & 2 deletions docs/src/generated/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ solve!(prob; max_iter=30)
The above output comes from the Ipopt.jl solver. To see the final fidelity we can use the `unitary_fidelity` function exported by QuantumCollocation.jl.

````@example quickstart
println("Final fidelity: ", unitary_fidelity(prob))
println("Final fidelity: ", unitary_rollout_fidelity(prob))
````

We can also easily plot the solutions using the `plot` function exported by NamedTrajectories.jl.
Expand Down Expand Up @@ -99,7 +99,7 @@ solve!(prob_min_time; max_iter=30)
We can see that the final fidelity is indeed greater than the minimum fidelity we set.

````@example quickstart
println("Final fidelity: ", unitary_fidelity(prob_min_time))
println("Final fidelity: ", unitary_rollout_fidelity(prob_min_time))
````

and that the duration of the pulse has decreased.
Expand Down
40 changes: 0 additions & 40 deletions docs/src/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,6 @@ Modules = [QuantumCollocation.ProblemTemplates]
Modules = [QuantumCollocation.DirectSums]
```

## Quantum Object Utils
```@autodocs
Modules = [QuantumCollocation.QuantumObjectUtils]
```

## Quantum Systems
```@autodocs
Modules = [QuantumCollocation.QuantumSystems]
```

## Integrators
```@autodocs
Modules = [QuantumCollocation.Integrators]
```

## Objectives
```@autodocs
Modules = [QuantumCollocation.Objectives]
```

## Losses
```@autodocs
Modules = [QuantumCollocation.Losses]
```

## Embedded Operators
```@autodocs
Modules = [QuantumCollocation.EmbeddedOperators]
```

## Isomorphisms
```@autodocs
Modules = [QuantumCollocation.Isomorphisms]
```

## Options
```@autodocs
Modules = [QuantumCollocation.Options]
Expand All @@ -70,11 +35,6 @@ Modules = [QuantumCollocation.Rollouts]
Modules = [QuantumCollocation.SaveLoadUtils]
```

## Structure Utils
```@autodocs
Modules = [QuantumCollocation.StructureUtils]
```

## Trajectory Initialization
```@autodocs
Modules = [QuantumCollocation.TrajectoryInitialization]
Expand Down
58 changes: 4 additions & 54 deletions src/QuantumCollocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,8 @@ module QuantumCollocation

using Reexport


include("options.jl")
@reexport using .Options

include("isomorphisms.jl")
@reexport using .Isomorphisms

include("quantum_object_utils.jl")
@reexport using .QuantumObjectUtils

include("structure_utils.jl")
@reexport using .StructureUtils

include("quantum_systems.jl")
@reexport using .QuantumSystems

include("quantum_system_templates/_quantum_system_templates.jl")
@reexport using .QuantumSystemTemplates

include("embedded_operators.jl")
@reexport using .EmbeddedOperators

include("quantum_system_utils.jl")
@reexport using .QuantumSystemUtils

include("losses/_losses.jl")
@reexport using .Losses

include("constraints/_constraints.jl")
@reexport using .Constraints

include("objectives/_objectives.jl")
@reexport using .Objectives

include("integrators/_integrators.jl")
@reexport using .Integrators

include("dynamics.jl")
@reexport using .Dynamics

include("evaluators.jl")
@reexport using .Evaluators

include("problems.jl")
@reexport using .Problems
@reexport using QuantumCollocationCore
@reexport using PiccoloQuantumObjects

include("direct_sums.jl")
@reexport using .DirectSums
Expand All @@ -63,17 +20,10 @@ include("trajectory_interpolations.jl")
include("problem_templates/_problem_templates.jl")
@reexport using .ProblemTemplates

include("save_load_utils.jl")
@reexport using .SaveLoadUtils

include("problem_solvers.jl")
@reexport using .ProblemSolvers

include("plotting.jl")
@reexport using .Plotting
include("quantum_system_templates/_quantum_system_templates.jl")
@reexport using .QuantumSystemTemplates

include("callbacks.jl")
@reexport using .Callbacks


end
Loading

4 comments on commit cafef27

@jack-champagne
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/123065

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.0 -m "<description of version>" cafef2793ad09358e5828e86a5f82c9c3e8810e9
git push origin v0.5.0

Also, note the warning: Version 0.5.0 skips over 0.4.0
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@jack-champagne
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

Breaking changes

  • Backend optimizer code and utilities split off into seperate package (see QuantumCollocationCore.jl, and PiccoloQuantumObjects.jl)

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/123065

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.0 -m "<description of version>" cafef2793ad09358e5828e86a5f82c9c3e8810e9
git push origin v0.5.0

Also, note the warning: Version 0.5.0 skips over 0.4.0
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

Please sign in to comment.