Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NDTensors] Add SortedSets and TagSets #1204

Merged
merged 12 commits into from
Oct 4, 2023
Merged

Conversation

mtfishman
Copy link
Member

Description

This adds SortedSets and TagSets submodules to NDTensors.

SortedSets defines a generic sorted set-like data structure which are more efficient for smaller collections than hash-based sets. Inserting new elements keeps the set sorted (and unique). When combined with SmallVectors from #1202 (using a SmallVector as a data backend for a SortedSet), it should provide very fast data structures for applications like TagSets and QNs. This PR also adds a first draft of a new TagSet type design, which is generic but can make use of SmallVectors and SortedSets to reproduce speed that is similar to the current ITensors.TagSet type but with less code and a simpler, more generic design that will allow users to choose their own tag and storage types.

This is still a draft because I need to test the efficiency of SortedSets (I know there is some part that doesn't fully take advantage of the speed of using a SmallVector but instead uses slower generic code), work out a few more things around the design of the TagSet (and relatedly, QN) type, and add tests and examples.

NDTensors/src/SortedSets/src/SortedSets.jl Outdated Show resolved Hide resolved
NDTensors/src/TagSets/src/TagSets.jl Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (ea0f602) 85.41% compared to head (1f49549) 67.37%.

❗ Current head 1f49549 differs from pull request most recent head 069bc70. Consider uploading reports for the commit 069bc70 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1204       +/-   ##
===========================================
- Coverage   85.41%   67.37%   -18.05%     
===========================================
  Files          88       87        -1     
  Lines        8426     8388       -38     
===========================================
- Hits         7197     5651     -1546     
- Misses       1229     2737     +1508     

see 36 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtfishman mtfishman marked this pull request as ready for review October 4, 2023 00:49
@mtfishman
Copy link
Member Author

mtfishman commented Oct 4, 2023

@emstoudenmire I'm going to merge this so we can start testing it out in the wild. You can look at the new TagSet type (just a prototype for now, not yet used in ITensors.jl to replace the current one) to get an idea for how to design a QN type.

Some set operations on SortedSet (and the associated SmallSet, which is a type alias for a SortedSet wrapping a SmallVector) still need to be optimized, but that will be relatively simple. Basically each one (union, intersect, setdiff, symdiff) can take advantage of the data structures being sorted to run in linear time in the length of the sets, but I only implemented that for union and setdiff so far.

@mtfishman mtfishman merged commit a9eb3cf into main Oct 4, 2023
7 checks passed
@mtfishman mtfishman deleted the NDTensors_sortedsets_tagsets branch October 4, 2023 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants