array-api icon indicating copy to clipboard operation
array-api copied to clipboard

Is guidance for `stream=-1` intentional in dlpack

Open seberg opened this issue 7 months ago • 3 comments

Sorry, I don't know the discussion, a question for @leofang or @tqchen probably. The docs for the stream say that:

If stream is -1, the value may be used by the consumer to signal “producer must not perform any synchronization”.

Which seems very strict, but also I was pointed out that there is no real use-case? If users control streams well enough to consider things safe?

I think there may be a use-case where you e.g. visualize a running simulation where the visualization is happy to show an inconsistent state. Was that the reason, or was this just an oversight? And if, should it say "should" rather than "must"?

seberg avatar May 30 '25 08:05 seberg

cc @leofang for thoughts, i do think it have usecases when we only want to exchange the data structure while leaving synchronization need explicitly to the user

tqchen avatar May 30 '25 11:05 tqchen

If the user has tight control of streams, they could just pass in the producer stream (meaning it is a no-op)? No real opion from me either way, but I couldn't answer the question that we actually need it.

seberg avatar May 30 '25 11:05 seberg

It is the consumer that passes the stream to the producer. Whether or not the user can affect which stream to pass by the consumer depends on how the consumer library is implemented. One notable use case is mpi4py, as the consumer it has no knowledge about CUDA (as per the MPI standard), and it does not own any stream. We ask users to handle synchronizations following usual MPI+CUDA practice.

leofang avatar May 30 '25 14:05 leofang

@seberg are there further discussions needed for this issue?

leofang avatar Jun 25 '25 15:06 leofang