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 oft3_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 intheta’s Tucker basis, tails squashed);ZL/ZRthe left-to-right / right-to-left zippers ofG2againsttheta’s TT chain (ZL_iis everything left of corei,ZR_ieverything right of it); andenv_i = ZL_i G_z,i ZR_i, the one-hole environment of corei. These are exactly the intermediates of the gradientt3_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 solvezandthetaare fixed while the direction varies, so this is the per-frame sweep and only the dotted terms are per matvec. StackC.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 maskszandthetafirst (ut3_precompute_inner_product_sweep()).