ufv_aligned_padded_frame#
- t3toolbox.uniform_frame_variations_format.ufv_aligned_padded_frame(x_old, tucker_ranks, tt_ranks, hint, project=None, level_widths=None, sharing=None, oversampling=ALIGN_OVERSAMPLING, oversampled_passes=ALIGN_OVERSAMPLED_PASSES, max_passes=ALIGN_MAX_PASSES, tol=ALIGN_TOL, alternate=ALIGN_ALTERNATE, seed=ZERO_FRAME_SEED, use_jit=False)#
def ufv_aligned_padded_frame( x_old: 'ut3.UniformTuckerTensorTrain', # the old point; rank 0 = the zero tensor tucker_ranks: typ.Union[typ.Sequence[int], NDArray], # len=d, or HOST int (d,)+C, target tt_ranks: typ.Union[typ.Sequence[int], NDArray], # len=d+1, or HOST int (d+1,)+C, target hint: typ.Any, # UniformTuckerTensorTrain (x_old's padded N), or anything with `project` project: typ.Optional[typ.Callable] = None, # project(frame_data, hint) -> variations data; None = by the hint's class level_widths: typ.Optional[typ.Tuple[int, int, int, int]] = None, # (WU, WD, WL, WR); None = ufv_frame_widths(x_old.N, max target Tucker rank, max target TT rank) sharing: typ.Optional[typ.Sequence] = None, # len=d group labels; None = unshared oversampling: int = ALIGN_OVERSAMPLING, oversampled_passes: int = ALIGN_OVERSAMPLED_PASSES, max_passes: int = ALIGN_MAX_PASSES, tol: float = ALIGN_TOL, alternate: bool = ALIGN_ALTERNATE, seed: int = ZERO_FRAME_SEED, use_jit: bool = False, # the whole loop as one jax.jit; `project` must then be traceable ) -> typ.Tuple[ 'UT3Frame', # the aligned frame at level_widths, prefix masks (the level's frame structure for that padding) NDArray, # movements, shape=(max_passes,)+C, NaN after the last pass ]:
The uniform twin of
fv_aligned_padded_frame(): a padded frame ofx_oldwhose new directions are aligned with a hint, returned at a level’s padded widths.Purpose, method, fixed point, properties are those of the ragged twin, whose docstring explains them; the user guide is The aligned padded frame. In short, it biases the new directions of every rank store toward the hint’s tangent projection. It does so by a fixed-point iteration (oversampled passes, a truncating pass, then two-colour
(('D', 'L'), ('U', 'R'))pairs).At a fixed point, every store’s completion spans the leading new directions of its own content, given the other stores’ completions, so one more pass moves nothing. The completions are then a stationary point of the captured hint energy
‖Π_{T(F)} hint‖²(proved for matrices, measured on T3s) but generally not a maximum of it: rotating one store’s completion alone never lowers that energy and generically raises it at second order. In measurements on small trees, they are a strict local maximum of the cone merit, one of many.The hint-free start depends on the representation, slot signs included, and the aligned output does not, to
tol.What is uniform about it.
Internally every rank slot is
[old block | new block](block layout): the old frame as its masks give it (gappy patterns are fine), then the completions.UT3Frame.padded()returns that layout and its split. This function returns the frame COMPACTED tolevel_widths: real slots first, prefix masks. That is the structure of the frameut3_orthogonal_representationsgives a point padded to that level, so Newton can start from it without recompiling.level_widths=Noneusesufv_frame_widths(x_old.N, max target Tucker rank, max target TT rank).hint: aUniformTuckerTensorTrainwithx_old’s paddedN(utv_project_ut3_onto_tangent_space). Otherwise passproject(frame_data, hint), which receives the raw block-layout frame data and returns raw variation data.Target ranks may vary per stack element.
Returns
(frame, movements): the alignedUT3Frameat the level’s widths, and the movement record, a fixed-length(max_passes,)+Carray, NaN after the last pass. The record cannot tell a NaN movement (which never stops the loop) from an unrun pass.
Jit.
use_jit=Trueruns the WHOLE loop – the start, every pass, the projections and the compaction – as onejax.jitprogram. It compiles once per structure (about 9 s at d = 6 and d = 24);toland the hint’s arrays are traced, so new values do not recompile. A customprojectmust then be traceable and module-level (the library’s projections and the optimizers’ misfit gradient are). numpy inputs are converted to jax. Withoutuse_jit, jax inputs run eagerly: their first run at a new structure compiles hundreds of operations and adds thousands of process memory mappings (see the ragged twin and the user guide). Passuse_jit=Truefor jax.Examples
The two layers’ hint-free starts generally differ (their orthogonal representations can pick different slot signs), yet the uniform loop reaches the ragged loop’s fixed point, with the same captured energy:
>>> import numpy as np >>> import t3toolbox.tucker_tensor_train as t3 >>> import t3toolbox.uniform_tucker_tensor_train as ut3 >>> import t3toolbox.uniform_frame_variations_format as ubv >>> import t3toolbox.frame_variations_format as bvf >>> import t3toolbox.manifold as t3m >>> import t3toolbox.uniform_manifold as ut3m >>> np.random.seed(0) >>> shape, old, target = (5, 6, 5, 6), ((2, 2, 2, 2), (1, 2, 2, 2, 1)), ((3, 4, 4, 3), (1, 3, 4, 3, 1)) >>> x_old = t3.TuckerTensorTrain.randn(shape, *old) >>> hint = t3.TuckerTensorTrain.randn(shape, (5, 6, 5, 6), (1, 5, 25, 6, 1)) >>> ux_old, uhint = ut3.UniformTuckerTensorTrain.from_t3(x_old), ut3.UniformTuckerTensorTrain.from_t3(hint) >>> UF, movements = ubv.ufv_aligned_padded_frame(ux_old, *target, uhint, tol=1e-10, max_passes=300) >>> F, _ = bvf.fv_aligned_padded_frame(x_old, *target, hint, tol=1e-10, max_passes=300) >>> uniform = float(ut3m.UNIFORM_MANIFOLD.norm(ut3m.UNIFORM_MANIFOLD.project_ambient(UF, uhint))) >>> ragged = float(t3m.MANIFOLD.norm(t3m.MANIFOLD.project_ambient(F, hint))) >>> bool(abs(uniform - ragged) < 1e-8 * ragged) True
The record: one entry per pass run, NaN after; the last pair below
tol:>>> ran = movements[~np.isnan(movements)] >>> movements.shape, len(ran) < 300, bool(np.all(ran[-2:] < 1e-10)) ((300,), True, True)
- Parameters:
x_old (UniformTuckerTensorTrain)
tucker_ranks (t3toolbox.backend.common.typ.Union[t3toolbox.backend.common.typ.Sequence[int], NDArray])
tt_ranks (t3toolbox.backend.common.typ.Union[t3toolbox.backend.common.typ.Sequence[int], NDArray])
hint (t3toolbox.backend.common.typ.Any)
project (t3toolbox.backend.common.typ.Optional[t3toolbox.backend.common.typ.Callable])
level_widths (t3toolbox.backend.common.typ.Optional[t3toolbox.backend.common.typ.Tuple[int, int, int, int]])
sharing (t3toolbox.backend.common.typ.Optional[t3toolbox.backend.common.typ.Sequence])
oversampling (int)
oversampled_passes (int)
max_passes (int)
tol (float)
alternate (bool)
seed (int)
use_jit (bool)
- Return type: