Skip to content

Bypass some overhead in TensorMap constructor, bypass overhead in sectorequal/sectorhash for trivial symmetry#476

Open
lkdvos wants to merge 4 commits into
mainfrom
ld-constructor
Open

Bypass some overhead in TensorMap constructor, bypass overhead in sectorequal/sectorhash for trivial symmetry#476
lkdvos wants to merge 4 commits into
mainfrom
ld-constructor

Conversation

@lkdvos

@lkdvos lkdvos commented Jul 8, 2026

Copy link
Copy Markdown
Member

As discussed with @Jutho and @kshyatt before, this PR consists of two changes:

The first (set) is:

  • The inner constructors for TensorMap are now no longer doing the checks, bypassing a small amount of overhead for looking up some of the cached data, as well as a small amount of overhead for the warnings with maxlog = 1.
  • The outer constructors now have these warnings/checks to keep the external behavior more or less the same

The second is:

Note that this is only a partial fix for #475, and to thoroughly fix some of this we would probably rather try to avoid caching the symmetry structure, which requires slightly more plumbing which I would like to hold off on for now, if this turns out to not be required it's a bunch of specialized code to maintain and check.

lkdvos added 3 commits July 8, 2026 16:11
This removes the checks in the inner constructors to allow TensorMap
construction without any overhead. To keep some of the warnings, I've
added this back to some of the outer constructors.
Comment thread src/spaces/cartesianspace.jl Outdated
Comment thread src/spaces/complexspace.jl Outdated
@VinceNeede

Copy link
Copy Markdown

I tested an earlier version of this branch (commit 6f6ea02, before the recent test-related changes) against a downstream MPS/MPO tensor-network package I maintain (built on TensorKit) — its own real benchmark suite, not just the earlier synthetic MWE: PkgBenchmark.judge comparing this branch against the currently released TensorKit, across MPO-MPS application (three algorithms) and DMRG, at multiple system sizes and bond dimensions.

Allocation counts for DMRG dropped ~25-30% consistently:

DMRG benchmark branch allocs released allocs ratio
dmrg_tfim_L20_open, nsite=1 604,339 857,127 0.71
dmrg_tfim_L20_open, nsite=2 635,210 840,741 0.76
dmrg_tfim_L20_periodic, nsite=1, maxdim=10 695,778 957,995 0.73
dmrg_tfim_L20_periodic, nsite=2, maxdim=10 732,462 948,522 0.77

(judge's own comparison doesn't report allocation counts directly — these are computed from the raw per-side results.)

More broadly, essentially every MPO-MPS-application benchmark across all three algorithms and both tested sizes shows a real improvement — time ratios mostly 0.67–0.99, memory ratios 0.39–1.00, with zero memory regressions anywhere in the suite. DMRG's own time ratios land in a similar 0.88–0.99 range.

Happy to share the full judge markdown output if useful, or re-run once the current changes land.

@Jutho

Jutho commented Jul 9, 2026

Copy link
Copy Markdown
Member

That is great to hear. Can I ask why you want to create a new MPS/MPO package, instead of using MPSKit, or, if you find that functionality is missing, contributing to it? I see in the description of your package that you think that MPSKit is somehow "VUMPS first", but that doesn't make any sense. MPSKit has full support for standard finite MPS, including DMRG, TDVP and a bunch of other functionality (like finite size excitations).

Co-authored-by: Jutho <Jutho@users.noreply.github.com>
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