Generalize AsyCost#538
Draft
ajay-mk wants to merge 6 commits into
Draft
Conversation
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).
9156e91 to
8f33716
Compare
Krzmbrzl
reviewed
Jun 2, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generalize
AsyCostfrom O/V to arbitraryIndexSpaceAsyCostpreviously 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
IndexSpaceto integer exponent, so a cost term is now a rational multiplier times a product of arbitrary space sizes raised to integer powersChanges
IndexSpaceto exponent instead of fixed occupied/virtual powers, so any number of spaces is supported.ops()takes a map of space extents instead of two numbers.IndexSpace.test_asy_cost.cppandtest_eval_node.cppupdated to construct costs via the exponent-map API, and new tests are added with generalIndexSpaces.