Repository navigation
Properties of gradient generators, propagation semantics, and how-to guides - #37
Merged
Merged
Conversation
A gradient generator G is block upper-triangular with the dynamical generator Ĥ in all L+1 diagonal blocks, so det(G - λ) = det(Ĥ - λ)^(L+1). Use this to compute `specrange`, `eigvals`, `tr`, and `det` of a `GradgenOperator` from `G.H` alone: an exact diagonalization has dimension N instead of N(L+1), and an Arnoldi estimate avoids the Ritz values of the non-normal matrix G, which can lie outside the spectral range. With `method=:auto`, the choice between `:diag` and `:arnoldi` now depends on the size of `G.H`. Two Arnoldi tests in test_specrad.jl only passed because of the (L+1)-fold eigenvalues of G; they now compare against the estimate for Ĥ with a seeded RNG. Fix `norm(::GradVector)` to be the Euclidean norm of the block vector, consistent with `dot`, as the Arnoldi iteration requires. It was the sum of the norms of the state and the gradient states. Add a "Properties of the gradient generator" section to the Background page (spectrum, Jordan structure, non-normality and its consequences for Rayleigh quotients and Ritz values, the adjoint, and the inner product and norm of gradient vectors), and a subsection that defines the "flat", "frozen", and "full dual" semantics of propagating gradient vectors with numerical methods, with a table for the propagators in QuantumPropagators. Throughout the page, references to numbered results now state what the result says. Cite the Chebychev and Newton propagators, Arnoldi and Lanczos iteration, internal numerical differentiation, the Hellmann-Feynman theorem, and standard texts for matrix analysis and ODE theory.
Add a "How-to Guides" page with three guides that illustrate practical consequences of the properties on the Background page: * Backward propagation: build the gradient generator from the adjoint dynamical generator, G[Ĥ†], not the adjoint of the gradient generator, and reset the gradient states before each step, as in GRAPE. * Chebychev propagation: the spectral range comes from Ĥ, and the gradient is the exact derivative of the Chebychev approximation, even for a deliberately inaccurate propagation. The optional `check_normalization` must not be used for gradient vectors. * Adaptive ODE solvers: an `internalnorm` that only includes the state gives the "frozen" semantics (the same time steps as for the bare state), the default norm the "flat" semantics, compared numerically over a range of tolerances. The docs environment gains OrdinaryDiffEq, DiffEqBase, LinearAlgebra, and Printf for the examples.
The interface tests called `check_state` only on gradient vectors created with `GradVector(Ψ₀, L)`, whose gradient states are zero. For such a vector, any norm equals the norm of the state, so `check_state` could not detect that `norm(::GradVector)` was inconsistent with `dot` (it summed the norms of the components). Fill the gradient states with random values before calling `check_state`; with the old `norm`, the check now fails.
Put the statement of every proposition, corollary, and theorem on the Background page into an admonition, so that it is clear where the statement ends and the proof or the discussion begins. Each statement starts with an inline anchor (Documenter >= 1.18), e.g., `Background-prop-charpoly`, which can be targeted with `@ref`, and with `@extref` from other packages, since these anchors are written to the `objects.inv` inventory. All references to numbered results now link to them. A small CSS asset keeps the admonition title visible when following such a link. Restructure the "Properties of the gradient generator" section so that each subsection (Spectrum, Diagonalizability, Non-normality, Adjoint, Inner products and norms) starts with the practical consequence for propagating gradient vectors: e.g., a gradient generator cannot be propagated by diagonalizing it (the eigenvector method silently returns wrong results, as Moler and Van Loan describe), because the derivative of a phase grows linearly in time. Define "normal" informally, speak of expectation values instead of Rayleigh quotients, remind the reader what L is, and link back to the reduction to a single control. Rename the left eigenvector in Proposition 9 to avoid a clash with the control index l. Also: cite Moler and Van Loan (2003), give the section of Bock (1981) for internal numerical differentiation, update the links and wording in the how-to guides accordingly, and note in the changelog that `check_normalization` in the Chebychev propagator now fails for gradient vectors instead of passing by accident.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #37 +/- ##
========================================
- Coverage 86.9% 85.9% -1.0%
========================================
Files 6 7 +1
Lines 297 311 +14
========================================
+ Hits 258 267 +9
- Misses 39 44 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
This builds on the "Background" page from #36. It establishes which properties of a gradient generator
Gfollow from those of the dynamical generatorĤ, uses them in the implementation, and documents what the gradient states of a numerical propagation mean for different propagation methods.Code
specrange,eigvals,tr, anddetof aGradgenOperatorare evaluated fromG.Halone.Gis block upper-triangular withĤin allL+1diagonal blocks, sodet(G - λ) = det(Ĥ - λ)^(L+1):Ghas the eigenvalues, spectral range, and spectral radius ofĤ. This reduces an exact diagonalization from dimensionN(L+1)toN, and it avoids an Arnoldi estimate for the non-normalG, whose Ritz values can lie outside the spectral range. Withmethod=:auto, the choice between:diagand:arnoldiis now based on the size ofG.H.norm(::GradVector)is now the Euclidean norm of the block vector, consistent withdot, as the Arnoldi iteration requires. It used to be the sum of the norms of the state and the gradient states.test/test_properties.jl). Two Arnoldi tests intest/test_specrad.jlpassed only because of the(L+1)-fold eigenvalues ofG(and one of them was flaky); they now use a seeded RNG and test the estimate forĤ. Thecheck_statetests now use gradient vectors with non-zero gradient states: with zero gradient states, they could not detect the inconsistentnorm.Documentation
Ĥ; a gradient generator cannot be propagated by diagonalization (it is not diagonalizable, because the derivative of a phase grows linearly in time, and the eigenvector method silently returns wrong results); methods that assume a Hermitian generator (Lanczos, norm conservation, bounds on expectation values) do not apply, sinceGis never normal; a backward propagation needsG[Ĥ†], notG[Ĥ]†; andnorm/dottreat a gradient vector as one long vector.@refand, via the inventory, with@extreffrom other packages. References to numbered results throughout the page now state what the result says.internalnorm), with numerical comparisons.Related
check_normalization=truein the Chebychev propagator compares expectation values with the spectral range, which is not valid for a gradient generator. With the correctednorm, it now fails for gradient vectors instead of passing by accident. QuantumPropagators will skip the check (with a warning) for non-Hermitian generators; until that is released, the how-to advises against passing it.*(::GradgenOperator, ::AbstractVector), so that the ODE how-to no longer needscheck = false.