max_chunk_size_within ===================== .. py:function:: t3toolbox.backend.sampling_derivatives.max_chunk_size_within(mode_shapes, tucker_ranks, tt_ranks, order, n_probes, target_bytes, *, n_tangent = 1, n_shards = 1, dtype = None) .. code-block:: python def max_chunk_size_within( mode_shapes: typ.Sequence[int], # (N_1..N_d) ambient dims tucker_ranks: typ.Sequence[int], # (nU_1..nU_d) Tucker ranks tt_ranks: typ.Sequence[int], # (r_0..r_d) the d+1 TT bonds order: int, # highest derivative order K n_probes: int, # |W| (global; divided by n_shards) target_bytes: float, # absolute peak-memory cap for the assembly (per device) *, n_tangent: int = 1, n_shards: int = 1, dtype: typ.Any = None, ) -> int: # the largest chunk_size whose assembly peak fits target_bytes The largest ``chunk_size`` whose gradient-assembly peak stays within ``target_bytes`` (per device) -- the "use my whole device" policy: pass an absolute byte budget (e.g. a fraction of device memory). Contrast the device-agnostic :py:func:`estimate_chunk_size`. Same measured per-row cost.