Skip to content

[BlockSparseArrays] BlockSparseArray functionality #2

Open
@ogauthe

Description

@ogauthe

This issue lists functionalities and feature requests for BlockSparseArray.

using LinearAlgebra
using NDTensors.BlockSparseArrays: BlockSparseArray

a = BlockSparseArray{Float64}([2, 3], [2, 3]);

Bugs

Feature requests

  • Allow the syntax BlockSparseArray{Float64}([U1(0) => 2, U1(1) => 3], [U1(0) => 2, U1(1) => 3]) which could implicitly create axes with GradedUnitRange internally.
  • Use NestedPermutedDimsArray instead of SparsePermutedDimsArrayBlocks (similar to how we are removing SparseAdjointBlocks/SparseTransposeBlocks in [BlockSparseArrays] Simplifications of blocks for blocksparse Adjoint and Transpose ITensors.jl#1580). Started in [NDTensors] Introduce NestedPermutedDimsArrays submodule ITensors.jl#1589, [SparseArrayInterface] NestedPermutedDimsArray support ITensors.jl#1590.
  • An alternative design to [NDTensors] Introduce NestedPermutedDimsArrays submodule ITensors.jl#1589 would be to redefine NestedPermutedDimsArray as a PermutedDimsArray wrapping a MappedArray where the map and inverse map convert to PermutedDimsArray, that would be good to explore so we don't have to support all of the NestedPermutedDimsArrays code, which is mostly just a copy of Base.PermutedDimsArrays anyway.
  • If slices are just blockwise, like b = @view a[Block.(1:2), [Block(2), Block(1)], define blocks(b) as @view blocks(a)[1:2, [2, 1]], as opposed to using the more general SparseSubArrayBlocks in those cases. Like the new NestedPermutedDimsArray, in principle SparseSubArrayBlocks could be replaced by a NestedSubArray type that defines the slicing behavior of the array storing the blocks and also the slicing of the blocks themselves, but that might be overkill and the concept is very particular to block arrays. But maybe SubArray of the blocks could still be used to simplify the code logic in SparseSubArrayBlocks.
  • Constructor from Dictionary should check block sizes ([BlockSparseArrays] BlockSparseArray functionality #2).
  • Blockwise linear algebra operations like svd, qr, etc. See [ENHANCEMENT] Blockwise matrix factorizations #3. These are well defined if the block sparse matrix has a block structure (i.e. the sparsity pattern of the sparse array of arrays blocks(a)) corresponding to a generalized permutation matrix. Probably they should be called something like block_svd, block_eigen, block_qr, etc. to distinguish that they are meant to be used on block sparse matrices with those structures (and error if they don't have that structure). See 1 for a prototype of a blockwise QR. See also BlockDiagonals.jl for an example in Julia of blockwise factorizations, they use a naming scheme svd_blockwise, eigen_blockwise, etc. The slicing operation introduced in [BlockSparseArrays] Sub-slices of multiple blocks ITensors.jl#1489 will be useful for performing block-wise truncated factorizations.
  • Define storedblockview(a, ::Block) to get the view of a stored block, which would allow avoiding wrapping the block in a view. Also define getstoredindex(a, ::Block).
  • Change the behavior of slicing with non-blocked ranges (such as a[1:2, 1:2]) to output non-blocked arrays, and define @blocked a[1:2, 1:2] to explicitly preserve blocking. See the discussion in Functionality for slicing with unit ranges that preserves block information JuliaArrays/BlockArrays.jl#347.
  • Reconsider the design of how duality is stored in graded unit ranges (graded axes), for example storing it at the level of the sector labels with a new SectorDual type and/or as a boolean flag.
  • Display non-initialized blocks differently from zero-initialized blocks, currently they both print as zeros.

Fixed

Footnotes

  1. https://github.com/ITensor/ITensors.jl/blob/v0.3.57/NDTensors/src/lib/BlockSparseArrays/src/backup/LinearAlgebraExt/qr.jl

  2. https://github.com/JuliaGPU/GPUArrays.jl/blob/v11.1.0/lib/GPUArraysCore/src/GPUArraysCore.jl#L27, https://github.com/JuliaGPU/CUDA.jl/blob/v5.4.2/src/array.jl#L396

  3. https://github.com/ITensor/ITensors.jl/pull/1452, https://github.com/JuliaArrays/BlockArrays.jl/pull/255

  4. [BlockSparseArrays] Fix adjoint and transpose ITensors.jl#1470

  5. [BlockSparseArrays] More general broadcasting and slicing ITensors.jl#1332 2 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions