Hi @tqchen I’ve gone through the code and have some initial ideas, but wasn’t sure of the best approach for modifying the builtins.
The way it is right now,
On the one hand there is the R.vm.alloc_storage
and the vm.builtin.alloc_storage
functions that take the memory to be allocated in terms of the number of bytes. On the other hand, we have the AllocDataSpace
device api method that supports mem_scope, but it takes the ndim
and shape
of tensor as arguments.
So we would need to either add new alloc_storage relax function and builtin to take ndim
and shape
as arguments, or add another overload of AllocDataSpace
that takes mem_scope along with the nbytes version.
I guess adding new relax functions with ndim
and shape
support makes more sense, but in order to lower that properly, I might need to add support for pooled allocator for Relax VM that accepts ndim, shape and mem_scope. I’m not sure if it makes sense to implement a generic pooled allocator for potentially multi-dimensional memory allocation.
So, I wanted to ask whether it makes sense to not support pooled allocator for other memory scopes and let appropriate device managers handle pooling within their APIs? Only naive allocator would be supported for memory scoped versions
Also I wanted to ask if we would need to go through an RFC for the changes as we’re probably introducing new Relax functions/builtins and changes to Relax VM with new allocators