-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Should we statically associate Store
instances with Buffer
types?
#2473
Comments
@d-v-b The arguments you make are compelling, but we should think through this fully before committing to this strategy of static association of
I think this is the critical part of this proposal. How do we ensure the callers of |
I do think it's important to factor in that every Zarr array is composed of two distinct pieces of data: the array schema / metadata, which is JSON, and the array chunks, which are little arrays. I suspect users will mostly care about processing the chunks on specialized hardware (I don't think GPUs or TPUs solve vital performance problems associated with parsing tiny JSON documents). That's not to say that metadata should never be stored outside CPU memory, but only that a basic scenario might be "device pluralism", where array metadata is stored separately from the array chunks. In @jhamman has often advocated for making our storage APIs more "zarr-aware". I think the proposal to partition metadata storage and chunk storage fits with that vision. What isn't clear to me is whether we:
|
to put the point differently, with our current design of a global |
IMHO, the key feature we need to support is the ability to specify output data location (e.g., CPU, GPU) across the entire stack. Preferably on a per chunk basis. This is useful for several reasons:
Agree, you do not want to change the global If you want to read into GPU-memory, you should specify the GPU prototype when calling zarr-python/tests/test_buffer.py Lines 88 to 93 in 693e11c
This uses the Now, if we want a more centralized way to set the prototype, we could add an extra |
Thanks for the clarification @madsbk. I'm not sure I fully understand the link between our current In both cases the caller is responsible for moving the buffer retrieved from storage to the desired medium, but in the second case this is not baked into the |
In cuda, we have cpu memory allocations that improve CPU<->GPU transfer performance significantly such as page-locked and managed memory. Thus, if the final destination is gpu memory, it would be very useful to let the
In principle, you are right. We could allow
However, I don't think it will reduce code complexity. |
It seems a bit odd that the signature of
Store.get
takes aprototype
parameter, which ultimately defines the return type of that method. Beyond cluttering the.get
method, which will be used 99.9% of the time for CPU buffers, this makes it rather hard to reason about the data copying behavior ofstore.get
, because depending on theprototype
argument data might get copied, or it might not.There is a simple alternative -- make
store.get
statically return instances of a fixedBuffer
class, and require callers ofstore.get
who want a differentBuffer
type to cast as needed. This would require associating aBuffer
class withStore
classes instances, which I think aligns with how the stores actually work -- e.g.,LocalStore
andRemoteStore
are always going to return buffers backed by CPU memory. We can imagine alternative file system or s3 implementations that return GPU-backed buffers, but IMO those would be best expressed as different store classes.One objection to associating
Store
withBuffer
that I can think of is the possibility that someone wants one store that mixes cpu-backed buffers and gpu-backed buffers. I would emphasize that to my knowledge this is just a hypothetical, but I think this hypothetically could be accomplished by defining a store that wraps two sub-stores,Store[GPUBuffer]
for gpu stuff, andStore[CPUBuffer]
for cpu stuff.Thoughts?
cc @kylebarron
The text was updated successfully, but these errors were encountered: