Skip to content

Use comprehensions for dims, dual and flip of SumSpace - #90

Open
KristofferC wants to merge 1 commit into
QuantumKitHub:mainfrom
KristofferC:kc/sumspace-no-map
Open

KristofferC wants to merge 1 commit into
QuantumKitHub:mainfrom
KristofferC:kc/sumspace-no-map

Conversation

@KristofferC

@KristofferC KristofferC commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

When the type of a SumSpace is not concrete, map(dual, S.spaces) maps over a vector with an abstract element type. If that call is reached from within another map call, type inference applies its recursion limit to it, and since limited results are not cached, every function between the two map calls is inferred again at every call site. Comprehensions give the same result and are not limited. The analysis is in JuliaLang/julia#64862; QuantumKitHub/MPSKit.jl#554 removes the outer map for this particular case.

First call of InfiniteMPOHamiltonian([P, P], (1, 2) => h, (2, 3) => h) from that issue, with MPSKit main:

Julia main this PR
1.10.13 10.7 s, 4.5 GiB 9.4 s, 3.5 GiB
1.13.3 36.0 s, 16.7 GiB 17.5 s, 7.8 GiB
1.14.0-alpha2 29.5 s, 16.4 GiB 14.4 s, 7.8 GiB

🤖 Generated with Claude Code

When the type of a `SumSpace` is not concrete, `map(dual, S.spaces)` maps over a vector with an
abstract element type. If such a call is reached from within another `map` call, type
inference applies its recursion limit to it. The limited results are not cached, so every
function between the two `map` calls is inferred again at every call site
(JuliaLang/julia#64862). Comprehensions give the same result and are not limited.

First call of `InfiniteMPOHamiltonian([P, P], (1, 2) => h, (2, 3) => h)` from that issue, with
MPSKit at 263fe273:

| Julia         | before           | after            |
|---------------|------------------|------------------|
| 1.10.13       | 10.7 s, 4.5 GiB  | 9.4 s, 3.5 GiB   |
| 1.13.3        | 36.0 s, 16.7 GiB | 17.5 s, 7.8 GiB  |
| 1.14.0-alpha2 | 29.5 s, 16.4 GiB | 14.4 s, 7.8 GiB  |

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/vectorspaces/sumspace.jl 68.29% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant