BUG: test_dunder_dlpack: accept spec-mandated BufferError for a no-copy cross-device export - #457
Conversation
test_dunder_dlpack pins the requested dl_device to kDLCPU while drawing copy
from {True, False, None}. For a library whose array is not already on kDLCPU
(e.g. a SYCL/GPU device reported as kDLOneAPI), the copy=False case forces a
cross-device transfer. The __dlpack__ specification requires that a no-copy
cross-device transfer be refused with a BufferError, so the test was failing
on spec-compliant behavior.
Compare the requested dl_device against x.__dlpack_device__() and accept a
BufferError when copy is False and the devices differ; all other exceptions
(and the copy=None/True paths, which must copy and succeed) are still treated
as failures.
Fixes data-apis#456
|
Thanks @antonwolfy. From the test output, the failure is To make sure I understand it right. So what it says is that torch is not compliant: it emits a |
|
Yes, per my understanding. Every spec version mandates
|
|
Thanks for confirming. I opened pytorch/pytorch#194267 |
Closes #456.
This PR proposes to tolerate
BufferErroronly whencopy is Falseand the requesteddl_devicediffers from the array's own__dlpack_device__().CPU-native backends are unaffected (
cross_deviceisFalse). Thecopy=None/Truepaths must still copy and succeed, and non-BufferErrorexceptions still propagate.The change is verified and passed with dpnp.