Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ForwardDiff = "0.10"
Ipopt = "1.7"
JLD2 = "0.5"
MathOptInterface = "1.36"
NamedTrajectories = "0.2"
NamedTrajectories = "0.3"
PiccoloQuantumObjects = "0.3"
Reexport = "1.2"
TestItemRunner = "1.1"
Expand Down
11 changes: 5 additions & 6 deletions src/integrators/_integrators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function modify_integrator_suffix(
end
end

function PiccoloQuantumObjects.add_suffix(
function NamedTrajectories.add_suffix(
integrator::AbstractIntegrator,
suffix::String,
traj::NamedTrajectory,
Expand All @@ -113,7 +113,7 @@ function PiccoloQuantumObjects.add_suffix(
return modify_integrator_suffix(integrator, add_suffix, suffix, traj, mod_traj)
end

function PiccoloQuantumObjects.add_suffix(
function NamedTrajectories.add_suffix(
integrators::AbstractVector{<:AbstractIntegrator},
suffix::String,
traj::NamedTrajectory,
Expand All @@ -125,7 +125,7 @@ function PiccoloQuantumObjects.add_suffix(
]
end

function PiccoloQuantumObjects.remove_suffix(
function NamedTrajectories.remove_suffix(
integrator::AbstractIntegrator,
suffix::String,
traj::NamedTrajectory,
Expand All @@ -134,7 +134,7 @@ function PiccoloQuantumObjects.remove_suffix(
return modify_integrator_suffix(integrator, remove_suffix, suffix, traj, mod_traj)
end

function PiccoloQuantumObjects.remove_suffix(
function NamedTrajectories.remove_suffix(
integrators::AbstractVector{<:AbstractIntegrator},
suffix::String,
traj::NamedTrajectory,
Expand All @@ -147,7 +147,6 @@ end
# Get suffix utilities
# --------------------

Base.endswith(symb::Symbol, suffix::AbstractString) = endswith(String(symb), suffix)
Base.endswith(integrator::UnitaryPadeIntegrator, suffix::String) = endswith(integrator.unitary_symb, suffix)
Base.endswith(integrator::DerivativeIntegrator, suffix::String) = endswith(integrator.variable, suffix)

Expand All @@ -168,7 +167,7 @@ function Base.endswith(integrator::AbstractIntegrator, traj::NamedTrajectory, su
return endswith(name, suffix)
end

function PiccoloQuantumObjects.get_suffix(
function NamedTrajectories.get_suffix(
integrators::AbstractVector{<:AbstractIntegrator},
sys::AbstractQuantumSystem,
traj::NamedTrajectory,
Expand Down
18 changes: 10 additions & 8 deletions src/losses/unitary_infidelity_loss.jl

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This file exposes where we have multiple definitions of the same function. Where did we land on where these should live?

@andgoldschmidt andgoldschmidt Mar 10, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the current vision is that we want to export less. So, the losses that live in PQO are good to be exported, but QC losses are about to get refactored due to DirectTrajOpt (so I would rather they don't get exported). Is this the conflict you're referencing?

Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ end
# ============================================================================= #

@testitem "Unitary fidelity" begin

X = [0 1; 1 0]
X = [0 1; 1 0]
Y = [0 -im; im 0]
Expand Down Expand Up @@ -515,18 +516,19 @@ end
end

@testitem "Free phase fidelity" begin
using PiccoloQuantumObjects
import PiccoloQuantumObjects

n_levels = 3
phase_data = [1.9, 2.7]
phase_operators = [PAULIS[:Z], PAULIS[:Z]]
subspace = get_subspace_indices([1:2, 1:2], [n_levels, n_levels])
phase_operators = [PiccoloQuantumObjects.PAULIS[:Z], PiccoloQuantumObjects.PAULIS[:Z]]
subspace = PiccoloQuantumObjects.get_subspace_indices([1:2, 1:2], [n_levels, n_levels])

R = free_phase(phase_data, phase_operators)
R = PiccoloQuantumObjects.free_phase(phase_data, phase_operators)
@test R'R ≈ [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]
@test size(R) == (2^2, 2^2)

U_goal = EmbeddedOperator(GATES[:CZ], subspace, [n_levels, n_levels]).operator
U_final = EmbeddedOperator(R'GATES[:CZ], subspace, [n_levels, n_levels]).operator
U_goal = PiccoloQuantumObjects.EmbeddedOperator(PiccoloQuantumObjects.GATES[:CZ], subspace, [n_levels, n_levels]).operator
U_final = PiccoloQuantumObjects.EmbeddedOperator(R'PiccoloQuantumObjects.GATES[:CZ], subspace, [n_levels, n_levels]).operator
# Value is ~0.3 without phases
@test unitary_fidelity(U_final, U_goal, subspace=subspace) < 0.5
@test unitary_free_phase_fidelity(
Expand All @@ -539,8 +541,8 @@ end

# Forgot subspace
@test_throws DimensionMismatch iso_vec_unitary_free_phase_fidelity(
operator_to_iso_vec(U_final),
operator_to_iso_vec(U_goal),
PiccoloQuantumObjects.operator_to_iso_vec(U_final),
PiccoloQuantumObjects.operator_to_iso_vec(U_goal),
phase_data,
phase_operators,
)
Expand Down
2 changes: 1 addition & 1 deletion src/problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function get_constraints(prob::QuantumControlProblem)
]
end

function PiccoloQuantumObjects.get_suffix(
function NamedTrajectories.get_suffix(
prob::QuantumControlProblem,
subproblem_traj::NamedTrajectory,
suffix::String;
Expand Down