Coder Social home page Coder Social logo

Comments (3)

lkdvos avatar lkdvos commented on June 8, 2024

I think one of the main reasons we removed this feature from the default TensorOperations installation is that we were unhappy about the interplay with multi-threaded environments. While for small tests this is hard to spot, in real-world larger applications (MPSKit.jl) we noticed that often the cache just filled up and took up most of the available memory and processes got killed because of this. This was mainly because the key for the cache had to include the task-id, and Julia seems to spawn quite a lot of these.

Nevertheless, caching can be a good strategy to reduce the number of allocations, and we have kept this in mind with this rewrite. The updated documentation should lay out the allocation procedure that we now choose, which has explicit calls to tensoralloc and tensorfree!, thus allowing a Backend system to implement a cache, but there are many different strategies there and we have not yet experimented to find the best one.

So, TL;DR, while removed as a default, users can now more easily implement there own caching strategy, either via LRU, Recycler, or any other custom backend.

from tensoroperations.jl.

Jutho avatar Jutho commented on June 8, 2024

In addition to the response of Lukas, I'd like to add that we came to the conclusion that, in typical use cases (at least typical to us, i.e. tensor network algorithms) there are various other places where temporaries are created. As such, a solution to cache or otherwise reduce the allocation cost of a these temporaries should be more general, probably to be developed in a standalone package. The cache in the older TensorOperations versions also did not offer much control as to when to release the cached objects, other than setting the maximum size and relying on the LRU mechanism.

Also, it seems other communities are facing similar issues, so hopefully a more general global solution will be developed, either in a package (e.g. Recyclers.jl ) or in the Julia language itself.

I think an ideal solution would be that a user/developer is able to mark a particular section of code, e.g. a particular hot loop, such that all temporaries (possibly created with a special allocate call, and also manually released with a free cal) within that section of code are cached or otherwise recycled using some buffer, which is then released completely when that piece of code is finished.

We hope that the current interface of TensorOperations v4, and the way the macro is parsed, is sufficiently general to allow an easy adoption of such future developments.

from tensoroperations.jl.

sents avatar sents commented on June 8, 2024

Thank you a lot for your answers. I ran into the same problem of needing to cache other things but TensorOperation calls but I just reused the TensorOperations cache for that. It makes sense to decouple caching and I'm satisfied understanding that tensoralloc and tensorfree! are meant as interfaces to implement an allocation strategy that fits the need of the problem.

from tensoroperations.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.