t3_precompute_inner_product_sweep#

t3toolbox.backend.t3_linalg.t3_precompute_inner_product_sweep(z, core_pair)#
def t3_precompute_inner_product_sweep(
        z:          typ.Tuple[
            typ.Sequence[NDArray],  # tucker_cores of z. len=d, elm_shape=C+(nZi, Ni)
            typ.Sequence[NDArray],  # tt_cores of z.     len=d, elm_shape=C+(rZi, nZi, rZ(i+1))
        ],
        core_pair:  typ.Tuple[
            typ.Sequence[NDArray],  # tucker_cores of theta. len=d, elm_shape=C+(ni, Ni)
            typ.Sequence[NDArray],  # tt_cores of theta.     len=d, elm_shape=C+(ri, ni, r(i+1))
        ],
) -> typ.Tuple[
    typ.Tuple[NDArray, ...],        # zB.  len=d, elm_shape=C+(nZi, ni):          z's Tucker cores against theta's
    typ.Tuple[NDArray, ...],        # G2.  len=d, elm_shape=C+(rZi, ni, rZ(i+1)): z's TT cores in theta's basis
    typ.Tuple[NDArray, ...],        # ZL.  len=d, elm_shape=C+(rZi, ri):          left environments
    typ.Tuple[NDArray, ...],        # ZR.  len=d, elm_shape=C+(rZ(i+1), r(i+1)):  right environments
    typ.Tuple[NDArray, ...],        # env. len=d, elm_shape=C+(ri, nZi, r(i+1)):  one-hole environments
]:

The (z, theta)-dependent part of t3_inner_product_corewise_hessian(), computed once.

zB_i = B_z,i B_i^T; G2_i = G_z,i x_2 zB_i (z’s TT cores re-expressed in theta’s Tucker basis, tails squashed); ZL / ZR the left-to-right / right-to-left zippers of G2 against theta’s TT chain (ZL_i is everything left of core i, ZR_i everything right of it); and env_i = ZL_i G_z,i ZR_i, the one-hole environment of core i. These are exactly the intermediates of the gradient t3_inner_product_corewise_transpose() (dG_i = env_i x_2 zB_i, dB_i = <env_i, G_i>^T B_z,i); the Hessian differentiates each of them along a direction. In a Newton-CG inner solve z and theta are fixed while the direction varies, so this is the per-frame sweep and only the dotted terms are per matvec. Stack C.

Polymorphic over ragged core tuples and uniform supercores ((d,)+C+(...): d-prefixed grouped contractions, the zippers’ uniform scan; each returned family is then one supercore). Mask-free by contract: a uniform caller masks z and theta first (ut3_precompute_inner_product_sweep()).

Parameters:
  • z (t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray]])

  • core_pair (t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Sequence[NDArray], t3toolbox.backend.common.typ.Sequence[NDArray]])

Return type:

t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Tuple[NDArray, …], t3toolbox.backend.common.typ.Tuple[NDArray, …], t3toolbox.backend.common.typ.Tuple[NDArray, …], t3toolbox.backend.common.typ.Tuple[NDArray, …], t3toolbox.backend.common.typ.Tuple[NDArray, …]]