Struct CostParams

Struct Documentation

struct CostParams

Cost-model tuning knobs consumed by opt::single_term_opt and forwarded to the objective models. Bundled so callers (and sequant::optimize via OptimizeOptions) pass one object rather than five positional arguments. All have neutral defaults: an empty is_volatile_leaf disables replay weighting, and roofline.machine_balance == 0 keeps the pure-flop tie-break.

Public Members

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

Marks a LEAF tensor as volatile (amplitude-dependent), so the contraction forming any subset that contains it is replayed every iteration. Empty => nothing volatile (replay weighting off).

double volatile_weight = 1.0

Replay weight on volatile contractions (conceptually the replay count).

double footprint_weight = 0.0

Per-intermediate storage-footprint penalty (DenseFLOPs/DenseSize only; see OptimizeOptions::footprint_weight). Not used by the peak objectives.

double peak_flops_tolerance = 0.10

Relative peak tolerance for DenseSpaceTime’s final selection; see OptimizeOptions::peak_flops_tolerance. Unused by DenseSpaceTimeBatched, whose final selection is instead threshold-gated by peak_threshold.

RooflineParams roofline = {}

Roofline parameters for the peak objectives’ secondary cost; see RooflineParams. machine_balance == 0 => pure-flop tie-break.

double accumulation_factor = 0.0

In-flight batch-contribution footprint multiplier for the batched objectives; see BatchPolicy::accumulation_factor. 0 (default) = no penalty.

double peak_threshold = std::numeric_limits<double>::infinity()

Peak-memory budget in bytes for the batched objectives; see BatchPolicy::peak_threshold. A feasibility ceiling on root selection under both batched objectives (space-first minimizes flops among the points that fit, ties by lower peak; time-first minimizes flops, ties by fewer slices then lower peak), and the enable switch for batching itself: +infinity (the default) opens no loop at all.

bool prune_outer_products = true

Prune disconnected (outer-product) subsets from the single-term DP; see OptimizeOptions::prune_outer_products. true (default) = prune.

bool batch_spectator_indices = false

Gate for external-index batching; see BatchPolicy::batch_spectator_indices. false (default) => the DP opens no external loop, so opt::detail::PeakBatchedModel emits no BatchModeType::External entries, so a non-external-aware caller sees none. Note this is necessary but not sufficient: the per-node gate in PeakBatchedModel::relax is batch_spectator_indices && std::isfinite(peak_threshold), so a finite peak_threshold is required too. It is not conditioned on the objective, and there is no post-DP external placement pass.

std::function<bool(Index const&)> is_batchable_contracted_index = [](Index const&) { return false; }

Spaces batchable in the contracted role, threaded from BatchPolicy::is_batchable_contracted_index. Building block consumed by the single-term optimizer’s DP contracted-role filter (a mode of such a space is sliced where it is summed). Declared adjacent to its external companion. Defaults to decline every index.

std::function<bool(Index const&)> is_batchable_external_index = [](Index const&) { return false; }

Spaces batchable in the external role, threaded from BatchPolicy::is_batchable_external_index. Defaults to decline every index; a caller that wants external batching sets it explicitly (there is no fallback to the contracted-role predicate).

std::function<std::size_t(Index const&)> batch_target_size = {}

Per-index per-batch slice size (an upper bound) for a batchable index; threaded from BatchPolicy::batch_target_size. Consulted only by the batched objectives. Empty (default) => no target => no slicing.

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

k-aware inner (CSV/PNO composite) extent applied by every cost counter; threaded from OptimizeOptions::inner_pow. Required whenever the network has composite indices: empty does not fall back to the idxsz provider (k=1) &#8212; inner_aware_volume throws instead, since such a fallback grossly mis-sizes multi-composite tensors, e.g. a 4-PAO integral. No default (matching OptimizeOptions::inner_pow and PeakBatchedModel::inner_pow); pass an explicit no-op only for composite-free work.

bool batch_persistent_only = false

When true, only persistent (volatile-leaf-free) subnetworks are batched; threaded from BatchPolicy::persistent_only. Batched objectives only.