You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: Should np.from_dlpack raise BufferError instead of ValueError on unsupported dl_device values? #30937
BufferError – The dlpack and dlpack_device methods on the input array may raise BufferError when the data cannot be exported as DLPack (e.g., incompatible dtype, strides, or device).
I read the meaning as: incompatible dtype, incompatible strides, or incompatible device - which would suggest a BufferError should be raised when device is incompatible?
I understand BufferError may seem like an odd choice (#30341 (comment)) but just raising the question from my interpretation of the docs.
Ah, now that I see the code change, I realize why it wasn't the case. BufferError is vital for the exporter, but this is on the consumer side it is a bit less clear cut (and not actually specified at all, I think).
But it sounds like it helps you, so happy to change it.
Now that I read the docs more carefully it does talk about exporting: "data cannot be exported as DLPack" - but doing some digging, the spec also says:
If an array that is accessed via the interchange protocol lives on a device that the requesting (consumer) library does not support, it is recommended to raise a BufferError, unless an explicit copy is requested (see below) and the producer can support the request.
Ah, you are right, so that hints to it, good to know. And it makes sense anyway, I think. (Sorry for the noise, I think it mostly explains why we missed it, fixing it for the export part at some point, but not here.)
Activity
seberg commentedon Mar 5, 2026
Yeah, I agree, would be better/correct to raise a
BufferErrorhere, seems there is always one more path...seberg commentedon Mar 11, 2026
Ah, now that I see the code change, I realize why it wasn't the case.
BufferErroris vital for the exporter, but this is on the consumer side it is a bit less clear cut (and not actually specified at all, I think).But it sounds like it helps you, so happy to change it.
lucyleeow commentedon Mar 11, 2026
Now that I read the docs more carefully it does talk about exporting: "data cannot be exported as DLPack" - but doing some digging, the spec also says:
seberg commentedon Mar 11, 2026
Ah, you are right, so that hints to it, good to know. And it makes sense anyway, I think. (Sorry for the noise, I think it mostly explains why we missed it, fixing it for the export part at some point, but not here.)
lucyleeow commentedon Mar 11, 2026
Honestly, I am always confused with DLPack 🤔 (I also do not have a good sense if it makes sense... 😅 )