Skip to content

Generalize AsyCost#538

Open
ajay-mk wants to merge 8 commits into
masterfrom
ajay/feat/improve-asycost
Open

Generalize AsyCost#538
ajay-mk wants to merge 8 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
- Include aux slots (const_braketaux_indices) in space_counts so DF/THC auxiliary spaces contribute to the cost
- Support batched indices: present in left, right, and result
- Add eval_node tests covering PPL + density-fitting, batched-index cost, and an MRCC-like example
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR generalizes AsyCost from a fixed occupied/virtual (O/V) polynomial representation to a map keyed by arbitrary IndexSpace, enabling asymptotic cost and memory scalings to be expressed over any number of index spaces (including auxiliary and batching spaces).

Changes:

  • Replaced O/V exponent pairs with an IndexSpace -> exponent map and updated printing/comparison semantics accordingly.
  • Updated flop/memory accounting in eval_node to count indices by IndexSpace (including aux slots).
  • Updated and expanded unit tests to construct/compare costs via the exponent-map API and to cover generalized spaces.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
SeQuant/core/asy_cost.hpp Updates AsyCost public API and documentation to use IndexSpace-keyed exponent maps.
SeQuant/core/asy_cost.cpp Implements generalized exponent-map storage, printing, ordering, and numeric evaluation via extents.
SeQuant/core/eval/eval_node.hpp Updates flop/memory estimation to count indices per IndexSpace (including auxiliary indices).
SeQuant/core/eval/cache_manager.hpp Adjusts documentation to match generalized AsyCost semantics.
tests/unit/test_asy_cost.cpp Refactors tests for new API and adds coverage for >2 spaces and missing extents behavior.
tests/unit/test_eval_node.cpp Updates expected costs to the new API and adds tests for density-fitting, batching, and MR-like examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SeQuant/core/asy_cost.hpp Outdated
Drop the unused counts(NodePos) accessor and add comments
@ajay-mk ajay-mk force-pushed the ajay/feat/improve-asycost branch from 2ffed47 to 5a94615 Compare June 6, 2026 21:52
@ajay-mk ajay-mk marked this pull request as ready for review June 6, 2026 21:56
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

3 participants