Skip to content

Use caching for SU and CTMRG algos on GPU - #478

Draft
kshyatt wants to merge 3 commits into
mainfrom
ksh/caches
Draft

kshyatt wants to merge 3 commits into
mainfrom
ksh/caches

Conversation

@kshyatt

@kshyatt kshyatt commented Oct 27, 2026

Copy link
Copy Markdown
Member

I originally tried this to help on AMD, which doesn't have a warm pool for memory allocations, making any alloc/dealloc extremely expensive. Happily it turns out to help by ~10% on CUDA too.

The basic idea is to store buffers for reuse where possible in CTMRG and SU, allowing us to avoid allocating and deallocating repeatedly. We can reuse buffers through a CTMRG iteration and then release them after (when truncation would change their size anyway) saving us a lot of wasted work in the GPU GC. This should be enough to get ROCm test times under the 2 hour limit I set on BuildKite.

@kshyatt
kshyatt requested review from leburgel and pbrehmer October 27, 2026 08:14
@Yue-Zhengyuan

Copy link
Copy Markdown
Member

Does #459 help as well?

@kshyatt

kshyatt commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Haven't tried yet but in theory they should be complimentary, I would imagine? I'll do some benchmarking :)

@lkdvos

lkdvos commented Oct 27, 2026

Copy link
Copy Markdown
Member

In principle this is something we do have quite a bit of support for in TensorOperations, and just never got around pushing this all the way through (mostly because I got scared/tired of Zygote). I have some code laying around specifically for some more efficient SU stuff, let me try if it is actually worth it.

The main thing is that with the growing buffers, which are also used in MPSKit, only the first couple iterations have to allocate and the remainder is fine, even with different truncations

@kshyatt

kshyatt commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

I kind of suspected that might be the case, if this serves as a forcing function elsewhere it's fine with me to close it. Anything I can do to help?

@kshyatt

kshyatt commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

I got scared/tired of Zygote

Many such cases!!!

@lkdvos

lkdvos commented Oct 27, 2026

Copy link
Copy Markdown
Member

Anything I can do to help?

If I get the SU through, maybe you could have a look at the CTMRG? Let me get to the office first, and see how much of this I really have just laying around

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ext/PEPSKitGPUArraysExt.jl 72.00% 7 Missing ⚠️
src/utility/alloc_cache.jl 95.23% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/PEPSKit.jl 100.00% <ø> (ø)
src/algorithms/ctmrg/ctmrg.jl 86.86% <100.00%> (+2.25%) ⬆️
src/algorithms/time_evolution/simpleupdate.jl 97.14% <100.00%> (+0.06%) ⬆️
src/utility/alloc_cache.jl 95.23% <95.23%> (ø)
ext/PEPSKitGPUArraysExt.jl 75.86% <72.00%> (-24.14%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kshyatt

kshyatt commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Let me get to the office first, and see how much of this I really have just laying around

@lkdvos any updates on this?

@lkdvos

lkdvos commented Oct 29, 2026

Copy link
Copy Markdown
Member

The SU stuff just got merged!

@kshyatt

kshyatt commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Let me see if that obviates the SU part of this with some benchmarks :D

@kshyatt

kshyatt commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Also sorry, which PR was it that just got merged?

@lkdvos

lkdvos commented Oct 29, 2026

Copy link
Copy Markdown
Member

#459

@lkdvos

lkdvos commented Oct 29, 2026

Copy link
Copy Markdown
Member

Also looking at this a bit more, I might have made the GPU support for symmetries slower because of the multiple kernel launches, but at least it's not allocating anymore 🙃

More seriously though, the buffer is mostly what I was talking about, having that in CTMRG would be amazing

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.

3 participants