Template Struct PeakModel

Nested Relationships

Nested Types

Struct Documentation

template<typename IdxToSz>
struct PeakModel

Peak-memory single-term cost model (DensePeakSize objective).

Implements the all-co-resident pebble-game DP, factored into the CostModel hooks driven by run_single_term_opt. The recurrence minimizes peak memory: while one child evaluates, the other child’s leaf inputs sit resident. A Pareto frontier of (peak, flops) per subset lets the lexicographic (peak, then flops) optimum be reached. No CSE.

Template Parameters:

IdxToSz – A callable mapping an Index to its extent.

Public Types

using State = container::vector<FrontPoint>

Per-subset DP cell: the PARETO FRONTIER of non-dominated (peak, flops) trade-offs for building the subtree rooted at this subset. A pure peak-min DP is degenerate when the peak is set by an unavoidable leaf/intermediate (e.g. a DF integral) that dominates many factorizations: a single peak-min cell with a local flop tie-break does not give the global flop-min among peak-optimal schedules (the max-recurrence lacks optimal substructure for the secondary objective). Carrying the frontier lets a parent combine a child’s slightly-higher-peak/lower-flops point when that peak is hidden under the parent’s peak-determining term, so the final lexicographic (peak, then flops) optimum is reachable &#8212; e.g. it can form a persistent 4-PNO integral (cheap flops) instead of recomputing the whole ladder, when both are peak-equal.

Public Functions

template<typename TIdxs>
inline Context build_context(TensorNetwork const &network, TIdxs const &tidxs) const
inline State leaf(Context const &ctx, size_t n) const
inline State init(Context const&, size_t) const
inline void relax(Context &ctx, size_t n, size_t lp, size_t rp, State const &lp_st, State const &rp_st, State &acc) const
inline void finalize(Context&, size_t, container::vector<State>&) const
inline EvalSequence reconstruct(Context const&, container::vector<State> const &st) const

Public Members

IdxToSz idxsz
std::function<double(Index const&, std::size_t)> inner_pow = {}

Optional k-aware inner (CSV/PNO composite) extent; see footprint_counter.

std::function<bool(Tensor const&)> is_volatile_leaf = {}

Predicate marking a leaf tensor as volatile (amplitude-dependent). Used ONLY to weight the secondary flop tie-break: a volatile contraction is replayed every iteration, so its flops are scaled by volatile_weight.

double volatile_weight = 1.0

Replay weight applied to volatile contractions in the flop tie-break.

double machine_balance = 0.0

Roofline parameters for the secondary (tie-break) cost; see RooflineParams and roofline_op_cost. machine_balance == 0 (default) => pure-flop tie-break (no behavior change).

double fast_mem_elems = 0.0
double block_tiles = 3.0
double block_prefactor = 1.0
double peak_flops_tolerance = 0.0

Relative peak tolerance for the final (root) selection: among frontier points whose peak is within (1 + peak_flops_tolerance) of the minimum peak, pick the one with the fewest flops. 0 (default) = strict peak-min (exact-tie flop tie-break only). A small positive value trades a bounded peak increase for a potentially large flop reduction (e.g. forming a persistent 4-PNO integral instead of recomputing a ladder).

bool prune_outer_products = true

Prune disconnected (outer-product) subsets from the DP (see OptimizeOptions::prune_outer_products). Default true.

struct Context

Precomputed tables: S[n] = footprint of subset n’s result tensor, L[n] = sum of leaf (singleton) sizes in subset n, idx[n] = subset n’s open (result) indices (for the per-contraction flop tie-break), and flops_of(lhs, rhs, result) the flop count of one binary contraction.

Public Members

container::vector<double> S
container::vector<double> L
container::vector<IndexSet> idx
std::function<double(IndexSet const&, IndexSet const&, IndexSet const&)> flops_of
std::size_t volatile_mask = 0

Bitmask of volatile leaf tensors (for the flop tie-break weight).

struct FrontPoint

One non-dominated (peak, flops) trade-off for a subset, with the bipartition / order / child-frontier-indices needed to reconstruct it. lp_idx / rp_idx select which frontier point of each child was used.

Public Members

double peak = std::numeric_limits<double>::max()
double flops = std::numeric_limits<double>::max()
size_t lp = 0
size_t rp = 0
bool lp_first = true
int lp_idx = -1
int rp_idx = -1