Skip to content

Generalize AsyCost#538

Draft
ajay-mk wants to merge 6 commits into
masterfrom
ajay/feat/improve-asycost
Draft

Generalize AsyCost#538
ajay-mk wants to merge 6 commits into
masterfrom
ajay/feat/improve-asycost

Conversation

@ajay-mk
Copy link
Copy Markdown
Member

@ajay-mk ajay-mk commented Jun 2, 2026

Generalize AsyCost from O/V to arbitrary IndexSpace

AsyCost previously hard-coded asymptotic cost as a polynomial in exactly two orbital spaces: occupied (O) and virtual (V), with each entry storing a fixed (occ, virt) exponent pair.

This PR replaces the fixed O/V representation with a general map from IndexSpace to integer exponent, so a cost term is now a rational multiplier times a product of arbitrary space sizes raised to integer powers

Changes

  • A cost entry now stores a map from IndexSpace to exponent instead of fixed occupied/virtual powers, so any number of spaces is supported.
  • Constructors take an exponent map; ops() takes a map of space extents instead of two numbers.
  • Printing uses base labels of each IndexSpace.
  • Cost ordering now compares total scaling first, then breaks ties space by space.
  • test_asy_cost.cpp and test_eval_node.cpp updated to construct costs via the exponent-map API, and new tests are added with general IndexSpaces.

@ajay-mk ajay-mk linked an issue Jun 2, 2026 that may be closed by this pull request
@ajay-mk ajay-mk added the enhancement New feature or request label Jun 2, 2026
ajay-mk added 2 commits June 2, 2026 01:38
Replace the hard-coded (active-occupied, virtual) pair with an ExponentMap<IndexSpace, size_t> so an AsyCost term can carry any number of index spaces. Ordering is driven by IndexSpace's own ordering. ops() now takes an ExtentMap and falls back to extent 1 for any space absent from it.

Entries print via IndexSpace::base_key(). The old AsyCost(nocc, nvirt) constructors are removed in favor of AsyCost(ExponentMap, count=1).
@ajay-mk ajay-mk force-pushed the ajay/feat/improve-asycost branch from 9156e91 to 8f33716 Compare June 2, 2026 05:41
Comment thread SeQuant/core/asy_cost.cpp Outdated
Comment thread SeQuant/core/eval/eval_node.hpp Outdated
ajay-mk added 2 commits June 2, 2026 12:59
Sort by the sum of exponents (overall polynomial / worst-case scaling) first, falling back to the existing space-by-space comparison only as a tie-breaker. Update the generalized-spaces test that asserted the old "highest space dominates" semantics.
space_counts was a non-template free function with internal linkage, living in an anonymous namespace in a header; TUs that include the header but never call it tripped -Wunneeded-internal-declaration under -Werror, which a [[maybe_unused]] attribute had been silencing.

Move NodePos, space_counts, and ContractedIndexCount into sequant::detail and mark space_counts inline. The function now has external linkage with a single merged definition, so the warning is gone for the right reason and the attribute is no longer needed.
@ajay-mk ajay-mk marked this pull request as ready for review June 3, 2026 13:03
@ajay-mk ajay-mk marked this pull request as draft June 3, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyCost doesn't work for generalized index spaces

2 participants