Skip to content

Parametrize PulseTuningProblem on the wrapped problem type - #19

Merged
jack-champagne merged 1 commit into
mainfrom
widen/qcp-type-param
Jul 28, 2026
Merged

jack-champagne merged 1 commit into
mainfrom
widen/qcp-type-param

Conversation

@jack-champagne

Copy link
Copy Markdown
Member

PulseTuningProblem.qcp is annotated with the concrete QuantumControlProblem. Piccolo's typed-templates work (Piccolo.jl#259) turns SamplingProblem from a function returning a QuantumControlProblem into its own wrapper type — SamplingProblem{P,QT} <: AbstractProblemWrapper, and AbstractProblemWrapper <: AbstractQuantumControlProblem. That annotation would reject it, so robust/sampling pulses could no longer be tuned.

Nothing in this repo references SamplingProblem, so no test catches either state today. The regression would be a silent capability loss on the robust-pulse → hardware-tuning path.

Approach

A TunableProblem alias resolved once at load:

const TunableProblem = if isdefined(Piccolo, :AbstractQuantumControlProblem)
    Piccolo.AbstractQuantumControlProblem
else
    Piccolo.QuantumControlProblem
end

…and the problem carried as a third type parameter bound by it (P<:TunableProblem, qcp::P).

Hardcoding either arm breaks one side: concrete QuantumControlProblem rejects the wrapper once it lands, and AbstractQuantumControlProblem is not a name that can be written until then. The alias means this needs no upgrade ordering — it compiles against Piccolo 1.15 through the typed templates, so it can land before, after, or independently of #259, and #259 carries no downstream Intonato break.

Field is now concrete

The old qcp::QuantumControlProblem was a UnionAll (Piccolo already parametrizes it on the trajectory), i.e. an abstract — boxed — field on the struct the tuning loop reads every iteration. Parametrizing makes it concrete:

qcp field type : QuantumControlProblem{KetTrajectory{LinearSplinePulse{…}, …}}
isconcretetype : true

Verification

  • Loads and constructs against current Piccolo (1.19); TunableProblem resolves to QuantumControlProblem, field concrete as above.
  • Forward arm verified by inspection of #259 rather than execution: AbstractQuantumControlProblem is defined and exported (src/control/problems.jl:52) and AbstractProblemWrapper <: AbstractQuantumControlProblem (:310), so SamplingProblem <: TunableProblem there. Worth re-confirming by dev-pinning once #259 lands.
  • No explicit PulseTuningProblem{S,M} instantiations exist outside the definition, so the added parameter breaks no call site.
  • Full suite left to CI.

`qcp` was annotated with the concrete `QuantumControlProblem`. Piccolo's
typed-templates work turns `SamplingProblem` from a function returning a
`QuantumControlProblem` into its own wrapper type
(`AbstractProblemWrapper <: AbstractQuantumControlProblem`), which that
annotation would reject — so robust/sampling pulses could no longer be
tuned.

Add a `TunableProblem` alias that resolves at load to
`AbstractQuantumControlProblem` when Piccolo defines it and
`QuantumControlProblem` otherwise, and carry the problem as a third type
parameter bound by it. Works unchanged on Piccolo 1.15 through the typed
templates, so it needs no upgrade ordering.

Also makes the field concrete: the old bare `QuantumControlProblem` was a
UnionAll, i.e. a boxed field on the tuning loop's hot struct.
@jack-champagne
jack-champagne merged commit b1007c1 into main Jul 28, 2026
7 checks passed
@jack-champagne
jack-champagne deleted the widen/qcp-type-param branch July 28, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant