Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Improve caching of structural data #9

Open
ogauthe opened this issue Jan 6, 2025 · 3 comments
Open

[ENHANCEMENT] Improve caching of structural data #9

ogauthe opened this issue Jan 6, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@ogauthe
Copy link
Collaborator

ogauthe commented Jan 6, 2025

As title. Currently there is one LRU cache

const unitary_cache = LRU{
  Tuple{
    SectorFusionTree,SectorFusionTree,SectorFusionTree,SectorFusionTree,Tuple{Vararg{Int}}
  },
  Float64,
}(;
  maxsize=10000,  # TBD size
)

This can be cleaned up.

@ogauthe ogauthe added the enhancement New feature or request label Jan 6, 2025
@lkdvos
Copy link
Collaborator

lkdvos commented Jan 7, 2025

A small comment on the keytype: I think that in general for non-concrete containers, unless the range of types is small you are better off replacing that with LRU{Any,Float64}, since the compiler cannot do anything smart with the knowledge about the abstract types anyways, and the sysimage might already contain code for working with containers of Any, such that you reduce code size. (This is rather technical and probably won't matter too much, but it might reduce compile times in the future and is a minor comment to make)

On a separate note, I'm a bit surprised you put both input and output trees in the key. If I am not understanding this wrong, that means you have to store N^2 entries for each permutation (N being the number of tree pairs of a single tensor), while this object is generally really sparse. You could store a dictionary of output tree => coefficients for each input tree + permutation key, severely reducing the number of entries (and also reducing the loop you need in the actual permutation code from looping over all entries to only the non-zero ones)

@ogauthe
Copy link
Collaborator Author

ogauthe commented Jan 7, 2025

Thnaks for the clue on Any.

Concerning your second point, this cache stores the overlap of the fusion trees. It is not the unitary matrix itself, which reuses the cache data. The cache is only written if the input and output tree pairs match, i.e. correspond to the same outer block.

@lkdvos
Copy link
Collaborator

lkdvos commented Jan 7, 2025

Makes sense, thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants