tv_probe_derivatives_transpose#
- t3toolbox.backend.sampling_derivatives.tv_probe_derivatives_transpose(ztildes, ww, pp, frame, order, sum_over_probes=False, chunk_size=100)#
def tv_probe_derivatives_transpose( ztildes: typ.Sequence[NDArray], # residual jets, len=d, elm_shape=(order+1,)+W+K+C+(Ni,) ww: typ.Sequence[NDArray], # probe vectors X, len=d, elm_shape=W+(Ni,) pp: typ.Sequence[NDArray], # perturbation vectors P, len=d, elm_shape=W+(Ni,) frame: typ.Tuple[ typ.Sequence[NDArray], typ.Sequence[NDArray], typ.Sequence[NDArray], typ.Sequence[NDArray], ], # = T3Frame.data = (U, O, P, Q) order: int, # highest derivative order K sum_over_probes: bool = False, # True: sum the sample stack W (the J^T r back-projection) chunk_size: typ.Optional[int] = 100, # W-chunk size for the gradient assembly; None -> dense. docs/chunking.md ) -> typ.Tuple[ typ.Tuple[NDArray, ...], # dU_tildes (Tucker variation gradient) typ.Tuple[NDArray, ...], # dG_tildes (TT variation gradient) ]: # = T3Variations.data
Transpose of
tv_probe_derivatives(): back-project residual jetsztildesinto a variation gradient(dU_tildes, dG_tildes). The jet-ified adjoint-state method (t4s.pdf Thm 7): every forward contraction is swapped for itstrsversion, then stationarity of the Lagrangian gives the adjoint sweeps (sigma/tau/dxi_tildejets) and the order-less gradient assembly.Full
W + K + Cstacking, base-inner as in plain probing: the residual jetsztildescarry the sample stackW, the tangent stackK(the forward output’sK), and the frame stackC. The tangent batchKalways rides through to the variation gradient. Withsum_over_probes=Falsethe sample stackWrides through into the variation stack too; withTrueit is summed (theJ^T rback-projection used for fitting),K/Calways kept. Verified against the dense adjoint identity<r, J v> = <J^T r, v>andjax.linear_transpose.chunk_sizebounds the peak memory of the (uniform+jax) gradient assembly by processing the sample stackWin slices of that size;None(or>= W) runs the dense assembly. The default is a safe fixed value, tuned only for moderate problems (a fixedchunk_sizebounds the chunk count, not the bytes); for a memory-balanced value from the problem shapes callestimate_chunk_size()once (eagerly). Chunking engages only on the uniform+jax path (numpy/ragged free eagerly). See Memory chunking of the derivative transpose (chunk_size).- Parameters:
ztildes (t3toolbox.backend.common.typ.Sequence[NDArray])
ww (t3toolbox.backend.common.typ.Sequence[NDArray])
pp (t3toolbox.backend.common.typ.Sequence[NDArray])
frame (t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray]])
order (int)
sum_over_probes (bool)
chunk_size (t3toolbox.backend.common.typ.Optional[int])
- Return type:
t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Tuple[NDArray, Ellipsis], t3toolbox.backend.common.typ.Tuple[NDArray, Ellipsis]]