ITensor / ITensor/BlockSparseArrays.jl

[BUG] `*(block sparse, dense)` (and vice versa) is slow

Open
#197 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Julia
Stars
3
Forks
3
Avg merge
14m
Merged PRs (30d)
3

Description

I found that even with an empty BlockSparseArray, doing a matrix vector mul is slow and causes large allocations. Is this expected behavior?

julia> using BlockArrays, BlockSparseArrays

julia> using BenchmarkTools

julia> cnt = fill(16, 128);

julia> bsa = BlockSparseArray{T}(undef, cnt, cnt);

julia> o = ones(2048);

julia> @benchmark $(bsa) * $(o)
BenchmarkTools.Trial: 4 samples with 1 evaluation per sample.
 Range (min … max):  1.603 s …   1.627 s  ┊ GC (min … max): 21.85% … 21.13%
 Time  (median):     1.613 s              ┊ GC (median):    21.64%
 Time  (mean ± σ):   1.614 s ± 10.349 ms  ┊ GC (mean ± σ):  21.63% ±  0.36%

  █          █                      █                     █
  █▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
  1.6 s          Histogram: frequency by time        1.63 s <

 Memory estimate: 17.06 GiB, allocs estimate: 29376515.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided BenchmarkTools case for an empty BlockSparseArray multiplied by a dense vector. Trace the matrix-vector multiplication entry point and allocation-heavy path; done means the empty case no longer incurs the reported large allocations and multi-second runtime, with benchmark coverage for the regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.