Template Function sequant::cache_manager(meta::eval_node_range auto const&, auto&&, size_t)¶
Defined in File cache_manager.hpp
Function Documentation¶
-
template<bool force_hash_collisions = false>
auto sequant::cache_manager(meta::eval_node_range auto const &nodes, auto &&is_volatile, size_t min_repeats = 2)¶ Make a cache manager that distinguishes persistent (P) from non-persistent (NP) intermediates, deriving persistence from a solver-supplied volatility predicate and the evaluation DAG.
A node is volatile (V) if its value changes between evaluations (e.g. it depends on the amplitudes being solved).
is_volatileflags intrinsically volatile nodes (typically the amplitude leaves); volatility is then propagated up the DAG (a node is V iff it is intrinsically volatile or any child is V). Persistence is derived from volatility and the consumer (parent) relationship:V node -> NP (released after last use)
NV node with >=1 V consumer -> P (the NV/V frontier: constant data feeding per-iteration work; kept across evaluations)
NV node with no V consumer -> NP (only feeds other NV nodes, so it is absorbed into them and not needed across evaluations)
Only internal (non-leaf) nodes are cached: NP nodes that repeat at least
min_repeatstimes (the usual CSE rule), plus all P nodes regardless of repeat count (a P node is reused across evaluations even if used once each).See also
- Parameters:
nodes – the evaluation forest.
is_volatile –
bool(TreeNode const&): true if the node is intrinsically volatile. Only its value on leaves matters in practice (volatility propagates up), but it is consulted on every node.min_repeats – minimum NP repeats to cache (default 2).