Template Struct PeakBatchedModel¶
Defined in File cost_model.hpp
Nested Relationships¶
Nested Types¶
Struct Documentation¶
-
template<typename IdxToSz>
struct PeakBatchedModel¶ Multi-mode batched peak-memory single-term cost model (DensePeakSizeBatched objective).
Implements the per-batchable-index all-co-resident pebble-game DP, factored into the CostModel hooks driven by run_single_term_opt. Follows the batch-aware cost model design (section 6.2, model A): each DP cell is indexed by both a subset
nand a sliced-set contextBover the batchable indices, so a model State is the[B]-vector of per-context BatchedRes. No CSE; persistence-gated batching.- Template Parameters:
IdxToSz – A callable mapping an Index to its extent.
Public Types
-
using State = container::vector<container::vector<BFrontPoint>>¶
Per-subset DP cell: a
[B]-vector (sizenB= 2^m) of Pareto frontiers, one non-dominated (peak, flops) set per sliced-set context B.
Public Functions
-
template<typename TIdxs>
inline Context build_context(TensorNetwork const &network, TIdxs const &tidxs) 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 EvalSequence reconstruct(Context const &ctx, container::vector<State> const &st) const¶
Public Members
-
std::function<double(Index const&, std::size_t)> inner_pow = {}¶
Optional k-aware inner (CSV/PNO composite) extent; see footprint_counter.
-
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). Uses full (unsliced) operand+result footprints (total per-replay traffic; slicing reduces peak, not total work).
-
double fast_mem_elems = 0.0¶
-
double block_tiles = 3.0¶
-
double block_prefactor = 1.0¶
-
bool batch_persistent_only = false¶
If true, batch only persistent subtrees (decline any subset containing a volatile leaf). Default false = batch across the board. See BatchPolicy::persistent_only.
-
double peak_flops_tolerance = 0.0¶
Relative peak tolerance for the final (root) selection; see PeakModel::peak_flops_tolerance. 0 (default) = strict peak-min.
-
double accumulation_factor = 0.0¶
In-flight batch-contribution footprint multiplier; see BatchPolicy::accumulation_factor. Charged only on nodes that contract a batchable index (Ap != 0), into the all-co-resident peak term, to price the accumulator + contribution co-residency of K += contribution.
-
bool prune_outer_products = true¶
Prune disconnected (outer-product) subsets from the DP (see OptimizeOptions::prune_outer_products). Default true.
-
struct BFrontPoint¶
One non-dominated (peak, flops) trade-off for a (subset, sliced-set
B) cell.aprimeis the sliced-set chosen at this node; the children are read at contextC= B | aprime, at frontier indiceslp_idx/rp_idx. See PeakModel::FrontPoint for why a frontier (not a single peak-min cell) is needed.
-
struct Context¶
Precomputed tables and per-(subset, sliced-set) lookup parameters built once by build_context.
Public Functions
-
inline double fast_flops(std::size_t lp, std::size_t rp) const¶
Flop count of the binary contraction (subset
lp) x (subsetrp), equivalent to flops_of(idx[lp], idx[rp], idx[n]) with n = lp|rp, but reading precomputed atom-ID lists instead of rebuilding index sets per call. (idx[n] is a subset of idx[lp] U idx[rp], so it adds nothing.)
-
inline double sz(std::size_t s, std::size_t ctx) const¶
Context-restricted size of subset s under sliced-set ctx (the table is indexed by the part of ctx actually open in s; mirrors the oracle).
-
inline double Lof(std::size_t s, std::size_t ctx) const¶
Per-context leaf-sum of subset s (sum of singleton sizes under ctx).
Public Members
-
std::size_t m = 0¶
Number of batchable indices (= aux.size()).
-
std::size_t nB = 1¶
Number of sliced-sets (= 2^m).
-
std::size_t nt = 0¶
Number of tensors in the network.
-
container::vector<container::vector<double>> tables¶
tables[B][n] = footprint of subset n under sliced-set B.
-
container::vector<std::size_t> open_aux¶
open_aux[n] = bitmask of batchable indices open in subset n.
-
std::size_t volatile_mask = 0¶
Bitmask of volatile leaf tensors.
-
std::function<double(IndexSet const&, IndexSet const&, IndexSet const&)> flops_of¶
flops_of(lhs, rhs, result) = flop count of one binary contraction. Retained as the reference for the fast_flops parity test; the relax hot loop uses fast_flops (see below).
-
bool use_fast_flops = true¶
-
bool f_inner_engaged = false¶
-
inline double fast_flops(std::size_t lp, std::size_t rp) const¶