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
Support the new DLPack exchange protocol from Python Array API #56
Comments
IMHO, DLPack has a minor but fatal spec flaw: Then did not add a |
Tentative and untested implementation in the feature/dlpack branch. I had the code for some time, but it was missing sanity error checks, and had no tests to validate. But it is a start. PS: If we manage to get this in, then we make a release. |
Yes, this is being discussed in this meta-issue dmlc/dlpack#74. But at least we can use the macro
It is interesting to see this brought up again! Someone also mentioned about it: dmlc/dlpack#73, but does MPI 3.1 currently support quad precision?!
Oh wow, that's quick...Thanks Lisandro! But I took a quick look and it does not meet the standard -- Can I take over and polish it? We need
I was counting on you to say this 😄
Sure, will do. |
BTW, why the No, MPI does not support quad precision. But that's not my point. If DLPack wants to ever support quad complex, it has to break ABI, or introduce some new ugly special case. If they decide to break ABI, for quad complex or any any other reason, consumers have no way to know what's the version the producer returning. I'll repeat it again: About my conde not being compliant, you should probably elaborate.
I have no idea about the details involving |
There is probably a way out by defining a helper C API in the DLPack header: typedef struct {
int abi_version;
int api_version;
} dlpack_info;
dlpack_info get_dlpack_info() {
dlpack_info info;
info.abi_version = SOME_MACRO; // defined in the same header, bumped in a new release with ABI-breaking change
info.api_version = ANOTHER_MACRO; // or just DLPACK_VERSION
return info;
} This is what is under discussion (dmlc/dlpack#74) and part of reasons we want to vendor the header.
I agree it's an awful choice but it's not something we get to pick 😇
Oh OK...Thought I missed something...
I will also repeat again that it is under discussion 🙂 So if you have time to join the game, please do feel free to do so by first going through dmlc/dlpack#74 and the linked issues therein... I was trying to avoid dragging you into all these tedious discussions, but I would be happy to have you voice out your thoughts. I am doing my best to keep the ball rolling, while I am not alone it does take a lot of work to get everyone on board.
I mentioned one benefit above. But your argument can be turned to against yourself: What you implement here can go outdated, and the worst thing is it is hard to tell because there is no accompanying DLPack header to diff against. In the present form you need to at least add a comment to say which version (or commit) the Cython implementation is based on, like what I did for CuPy: https://github.com/cupy/cupy/blob/master/cupy/_core/include/cupy/dlpack/README.md But having the header around is so much easier to inspect and update. I can point you to at least one place where people expect vendoring: dmlc/dlpack#69 (comment). If you're interested, you can take a look at the NumPy PR and the PyTorch PR. CuPy and cuDF have also done that. Everyone is vendoring a copy to reduce the maintenance overhead.
It is necessary for CPU libraries to use If this helps: Recall that in CAI we used The special case you are referring to can be queried via def from_dlpack(x):
device_type, device_id = x. __dlpack_device__()
if device_type == cpu:
capsule = x.__dlpack__(stream=None)
elif device_type == gpu:
my_stream = get_the_stream_to_use() # <-- for mpi4py this is -1
capsule = x.__dlpack__(stream=my_stream)
else:
raise NotImplemntedError
return _capsule_to_my_array_or_buffer(capsule) ps. I still need your answer to my question:
|
I force-pushed a few enhancements. I'm still not sure a about whether the destructor should be called or not. Your CuPy code does not call the
PS: I found another minor issue in DLPack. When you care about ABI, you should avoid using enum types inside structs. Thus, this line should read for example PS: Inconsistencies: |
Parallel PRs:
Spec: https://data-apis.org/array-api/latest/design_topics/data_interchange.html
The text was updated successfully, but these errors were encountered: