Template Function sequant::opt::detail::single_term_opt

Function Documentation

template<ObjectiveFunction Metric, has_index_extent IdxToSz>
EvalSequence sequant::opt::detail::single_term_opt(TensorNetwork const &network, IdxToSz &&idxsz, bool subnet_cse, CostParams const &cost = {}, std::function<bool(Index const&)> const &is_batchable_index = {}, std::function<std::size_t(Index const&)> batch_target_size = {}, std::function<double(Index const&, std::size_t)> const &inner_pow = {}, bool batch_persistent_only = false)
Template Parameters:
Parameters:
  • network – A TensorNetwork object.

  • idxsz – An invocable on Index, that maps Index to its dimension.

  • subnet_cse – Whether to recognize equivalent subnetworks to try minimizing the ops counts.

  • cost – Cost-model knobs (CostParams): is_volatile_leaf, volatile_weight, footprint_weight, peak_flops_tolerance, roofline. is_volatile_leaf marks a leaf tensor as volatile (its value changes on every replay); empty disables weighting. The predicate MUST be invariant under slot/index canonicalization — key on tensor label or structure, NOT on anonymous index identity — so that two subnetworks deemed equivalent by the subnet-CSE canonicalization also agree on volatility (the CSE path stores one cost per canonical subnet). volatile_weight/footprint_weight apply to DenseFLOPs only; peak_flops_tolerance/roofline apply to the peak objectives only.

  • is_batchable_index – Predicate marking an index as batchable (sliced); ObjectiveFunction::DensePeakSizeBatched only.

  • batch_target_size – Per-index per-batch slice size (an upper bound) for batchable indices; ObjectiveFunction::DensePeakSizeBatched only.

  • inner_pow – Optional k-aware CSV/PNO composite extent applied by every cost counter; see inner_aware_volume. Empty (default) sizes composites by idxsz (k=1), which under-counts multi-composite tensors.

  • batch_persistent_only – When true, only persistent (volatile-leaf-free) subnetworks are batched; ObjectiveFunction::DensePeakSizeBatched only.

Returns:

Optimal evaluation sequence under the chosen cost metric. If there are equivalent optimal sequences then the result is the one that keeps the order of tensors in the network as original as possible.