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] BlockSparseArrays prototype #1205

Merged
merged 9 commits into from
Oct 4, 2023
Merged

Conversation

mtfishman
Copy link
Member

Description

This is a prototype for a BlockSparseArray type based on the BlockArrays.jl interface. It is based on wrapping an elementwise sparse array (SparseArray, also introduced in this PR) which uses a dictionary-of-keys data storage, similar to the design of SparseArrayKit.jl.

It is fairly functional with just this amount of code, for example you can get and set elements and blocks and some basic linear algebra works (but isn't optimized for sparsity).

An interesting next step would be to define some tensor operations (perhaps using the interface defined in TensorOperations.jl), remove the type restriction on Tensor constraining the storage to TensorStorage, and see if we can get it working as an ITensor backend.

@kmp5VT I think this could be a good starting point to build off of for reworking the block sparse code. It already allows blocks with general types. The current BlockSparseArray type defined here can have blocks that are slices of a contiguous piece of data but also can be totally general AbstractArrays. If we add a DiagArray type and store them inside the blocks, it would cover our current use cases for the BlockSparse and DiagBlockSparse storage types. A more fully functional type that works with a contiguous data backend will probably require a slightly more sophisticated type, however, which stores an extra data field separate from the block structure, and the block structure stores SubArrays which are slices into that data.

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (ea0f602) 85.41% compared to head (1864f14) 67.22%.

❗ Current head 1864f14 differs from pull request most recent head d9b7d97. Consider uploading reports for the commit d9b7d97 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    #1205       +/-   ##
===========================================
- Coverage   85.41%   67.22%   -18.19%     
===========================================
  Files          88       87        -1     
  Lines        8426     8388       -38     
===========================================
- Hits         7197     5639     -1558     
- Misses       1229     2749     +1520     

see 40 files with indirect coverage changes

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

@emstoudenmire
Copy link
Collaborator

Nice that it's already up and running with so little code.

NDTensors/src/BlockSparseArrays/src/blocksparsearray.jl Outdated Show resolved Hide resolved
NDTensors/src/BlockSparseArrays/src/blocksparsearray.jl Outdated Show resolved Hide resolved
NDTensors/src/BlockSparseArrays/src/blocksparsearray.jl Outdated Show resolved Hide resolved
NDTensors/src/arraytensor/arraytensor.jl Outdated Show resolved Hide resolved
NDTensors/src/arraytensor/blocksparsearray.jl Outdated Show resolved Hide resolved
@mtfishman
Copy link
Member Author

@kmp5VT I'm going to merge this so we can start using it.

You can already use it as an ITensor storage type, but many operations won't work (so far just getting and setting elements will work, but tensor contractions, additions, and decompositions will fail).

@mtfishman mtfishman marked this pull request as ready for review October 4, 2023 01:17
@mtfishman mtfishman merged commit 15decbd into main Oct 4, 2023
7 checks passed
@mtfishman mtfishman deleted the NDTensors_blocksparsearrays branch October 4, 2023 01:18
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.

3 participants