Move matrix-free HVP carriers out of Piccolo (→ Piccolissimo #214)#254
Merged
Conversation
…ective The per-ket infidelity ℓ = |1 − |⟨g|ψ⟩|²| has a constant rank-2 Hessian Aᵀ·(−2·sign(1−F)·I)·A with A = [gᵣᵀ gᵢᵀ; −gᵢᵀ gᵣᵀ] (F = ‖A·ψ̃‖² = |⟨g|ψ⟩|² in block-iso layout). Declaring it via the DTO KnotHVP carrier seam (:neg2_sign link rule, consumed by Piccolissimo #188/#190) bypasses the nested-ForwardDiff per-knot rank probe and the per-iterate FD refactorization — O(m²) per state term, measured 91 min at i=5 scale (d=12376, K=64) vs ~2 min at i=4. Gate (rqpnn validate_ket_knot_hvp.jl): F-form and Hessian identities at 1.1e-16 vs ForwardDiff on both sides of the F=1 sign flip; carrier present on all per-ket terms via SplinePulseProblem(coherent=false); end-to-end GPU solve healthy. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ket anchor terms The unweighted coherent overlap abandons expensive minority kets (measured at i=4 Stage-2: hard kets 0.9997→0.0018 while 30 easy kets aligned — the same collapse behind the historical i=3 0.765 ceiling). Kets with weight above the minimum now get dedicated per-ket infidelity anchors scaled by the excess weight; phase-free terms the majority gradient cannot cancel. Uniform weights ⇒ behavior unchanged. Both term types carry the CLRH carrier (fast analytic path). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
F = |Σ wᵢ⟨gᵢ|ψᵢ⟩ / Σw|². The unweighted sum abandons an expensive minority (i=4 Stage-2 measured: hard kets 0.9997→0.002 at N=14 and →0.03 at N=20 while easy kets aligned; the mechanism behind the historical i=3 0.765 ceiling) and external per-ket anchors wedge when already satisfied. Weights reshape the optimum itself; the CLRH factor scales per-ket blocks by wᵢ/Σw so the carrier (Hessian + analytic gradient) carries through exactly. Uniform weights reproduce the original objective bit-for-bit. _ensemble_ket_objective now passes the ensemble weights through (replaces the anchor-term approach). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ccolissimo Strips all matrix-free per-knot HVP carriers from the public package: the ket carrier added in this PR plus the pre-existing coherent-ket and unitary low-rank factors (_coherent_ket_lowrank_factor, _unitary_lowrank_factor), every knot_hvp= attachment, the weighted-coherent kwarg, and the 4 carrier testitems. Piccolo objectives are now carrier-free (knot_hvp === nothing) — only the objective/loss physics remain. The construction lives in Piccolissimo's FidelityCarriers module next to its consumer in altissimo_backend.jl (harmoniqs/Piccolissimo.jl#214); solver runs build carrier-bearing objectives from there. Public users get the dense/FD fallback, unchanged correctness. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
lgtm! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move matrix-free HVP carrier construction out of public Piccolo → Piccolissimo
Public Piccolo should carry only objective/loss definitions, not the solver-specific matrix-free per-knot HVP construction. That construction (and its consumer) belongs in Piccolissimo's
altissimo_backend.jl. This PR removes all matrix-free carrier code from Piccolo; the construction moves to harmoniqs/Piccolissimo.jl#214 (FidelityCarriersmodule), which this pairs with.Removed from
src/control/objectives.jl_ket_infidelity_knot_hvp(added earlier in this PR's history) — ket-infidelity rank-2 factor._coherent_ket_lowrank_factorand_unitary_lowrank_factor(pre-existing onmain) — coherent-ket and unitary rank-2 factors.knot_hvp = …attachment onKetInfidelityObjective,CoherentKetInfidelityObjective,UnitaryInfidelityObjective.weightskwarg onCoherentKetInfidelityObjective(weighted variant now lives in Piccolissimo).knot_hvpmatrix-free testitems.Result
Piccolo objectives are carrier-free —
knot_hvp(obj, traj) === nothing— carrying only the loss physics, exactly as before the carrier work. Correctness is unchanged: outside the Altissimo backend a carrier-free objective takes the dense/ForwardDiff HVP.No speed regression for default solver runs. When a carrier-free ket / coherent-ket / full-op unitary objective goes through the Altissimo backend (harmoniqs/Piccolissimo.jl#214), the backend now auto-attaches the analytic rank-2 carrier: it rebuilds and self-validates the factor from the trajectory goals — bit-identical to the old declared carrier — so ALL THREE objective types that declared carriers on
main(ket, coherent-ket, full-op unitary) keep the pre-refactor wall time at any problem size and skip the expensive nested-ForwardDiff rank probe.EmbeddedOperatorunitaries stay on the fallback — exact parity withmain, which also never gave them a carrier. Verified end-to-end: i=2 default run (carrier-free objective + auto-attach) reproduces the pre-refactor solve bit-identically — fid 0.99930377 to all printed digits, outer trajectory identical, wall 887.6 s vs banked 909.5 s. Campaign runs needing the weighted-coherent objective build it explicitly from Piccolissimo'sFidelityCarriersconstructors. The backend consumption seam (knot_hvp(obj, template)) is untouched.Verified (rqpnn
validate_carrier_refactor.jl): Piccolo coherent objective carrier-free; Piccolissimo constructors attachConstantLowRankHVP; ket + weighted-coherent F-form and Hessian identities vs ForwardDiff at 4.4e-16 / 1.1e-16.🤖 Generated with Claude Code