Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This was referenced Oct 15, 2026
lkdvos
force-pushed
the
ld/sorted-directproduct
branch
from
October 15, 2026 15:35
8beb0d7 to
cba7abe
Compare
lkdvos
force-pushed
the
ld/memoizationkit
branch
from
October 23, 2026 13:37
54c98dc to
c613a5d
Compare
The F- and R-symbols were cached in one `LRU` per rank, which takes a lock on every lookup, hits included, so that TensorKit reading them from many threads serializes on it. They are now `@cached` with MemoizationKit (`SUN_Fsymbol` and `SUN_Rsymbol`), whose default `ClockCache` is read without a lock (since MemoizationKit 0.1.1). The distinct irreps of a direct product, which `⊗` iterates over (`productirreps`), are cached in the same way. `Nsymbol` stays uncached: for small products it costs about as much as a cache lookup. The Clebsch-Gordan coefficients (`SUN_CGC`) are cached in RAM and in MemoizationKit's disk cache, an SQLite database per machine, which replaces the JLD2 files with pidfile locks. They are written in a compact format of their own (`CGCSerializer`), which does not depend on the Julia version, and is a third smaller and 7x faster to read than that of `Serialization`. The location of the disk cache and whether it is used are MemoizationKit preferences, which replace `use_disk_cache`, `cgc_cache_dir` and `clear_disk_cache!`; `precompute_disk_cache` and `cache_info` remain. SQLite replaces JLD2, Pidfile, Scratch and LRUCache as dependencies. The CGC, F- and R-symbol caches keep their previous size of 10^5 entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lkdvos
force-pushed
the
ld/memoizationkit
branch
from
October 24, 2026 10:13
c613a5d to
0942f3f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The caches of SUNRepresentations, now with MemoizationKit.jl:
LRUper rank, which takes a lock on every lookup, hits included, so that TensorKit reading them from many threads serializes on it. They are now@cachedfunctionsSUN_FsymbolandSUN_Rsymbol, in MemoizationKit's defaultClockCache, which is read without a lock (since MemoizationKit 0.1.1).s1 ⊗ s2(productirreps) are cached in the same way. Their result is shared and must not be mutated.Nsymbolstays uncached: for small products it costs about as much as a cache lookup.SUN_CGC) are cached in RAM and in MemoizationKit's disk cache, an SQLite database per machine, which replaces the JLD2 files with pidfile locks. Processes on one machine share it, and writes are transactions. The coefficients are written in a compact format of their own (CGCSerializer: the size, and the linear indices and values of the nonzero entries), which does not depend on the Julia version, and is a third smaller and 7× faster to read than that ofSerialization.MemoizationKit.default_cache_settings), which can be changed with MemoizationKit's preferences; the direct products use MemoizationKit's default of 10⁴.⊗now shows the sorted order of Sort⊗output and speed upNsymboland⊗#58.Breaking (for 0.5.0):
use_disk_cache,cgc_cache_dir,clear_disk_cache!,ram_cache_infoanddisk_cache_infoare removed, in favour of MemoizationKit's preferences and functions:set_cache_preferences!(SUNRepresentations; disk_path = ...)ordisk = false,empty_disk_caches!(SUNRepresentations.SUN_CGC)andempty_caches!(SUNRepresentations).precompute_disk_cache(N, a_max, T)(withoutforce) andcache_info()remain; the latter lists all four caches and the disk cache of the CGCs. The README describes the new setup.Tests: the CGC disk cache is filled by
precompute_disk_cache, and read back once the RAM cache is emptied (counted as disk hits, and equal to the coefficients computed without any cache);CGCSerializerround-trips CGCs withFloat64andFloat32entries.Benchmarks
The reproducer of #56 (cold construction of the recoupling data of one permutation in a CTMRG step of an SU(3)-symmetric PEPS), minimum over two interleaved rounds:
mainCache hits (
@belapsed), and when many threads hit at once (8 tasks, each looking up the same 2404 warm SU(3) F-symbols, time per lookup):mainFsymbolhitRsymbolhit(1, 1) ⊗ (2, 1)Fsymbolhits, 8 tasksReading CGCs from the disk cache, with the RAM cache emptied, per CGC, with the cache in its default location (a scratch space in
~/.julia, here on a network file system) and on a local disk:mainmainOn the network file system, the file locks of
mainmade reading a small CGC from disk over 10× slower than computing it; with SQLite, reading the smallest CGCs takes about as long as computing them, and the disk cache pays off for everything larger. On a local disk, reading is faster than computing for all of them. For large CGCs (SU(5)), reading the entries dominates, and the two are within 20% on a local disk.Caveats
LRUCachebefore.disk_pathis faster still.MemoizationKit v0.1.1, TensorKit v0.17.2, TensorKitSectors v0.3.11, Julia 1.13.2, shared 32-core workstation (load average 1–9 during these runs; the tables use the minimum).
🤖 Generated with Claude Code