Comments (3)
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.
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.
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)
- Question: @cutensor not defined HOT 5
- possible memory leak with metaprogramming
- Is TensorOperations able to take advantage of symmetry in the output? HOT 8
- Manual allocation strategy HOT 2
- Floating Point Accuracy of @tensor results with CUDA HOT 3
- Enable multithreads when doing the permutedims in the TTGT algorithms HOT 2
- Unexpected `DimensionMismatch` (v4.0.2 -> v4.0.3) HOT 3
- Wrong result with subnetworks with equal labels HOT 2
- Bug in CUDA backend HOT 6
- Unintuitive `ncon` result when scalar HOT 2
- Taking gradients of traces HOT 6
- np.einsum_path vs TensorOperations HOT 3
- `ncon` fails with AD HOT 2
- `tensortrace` not working on Arrays of Symbolic Expressions from Symbolics.jl. HOT 2
- Combining LinearAlgebra.Diagonal with a CuArray inside @tensor HOT 2
- Compability with CUDA 5.2 HOT 3
- Confusion when using cuTENSOR HOT 4
- cuTENSOR not working with automatic differentiation HOT 5
- Freed reference problem when combining cuTENSOR and Zygote HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensoroperations.jl.