Repository navigation
Vendor CCCL and use it to reactivate tensormap - #2940
Conversation
|
This now does two things. First, it vendors CCCL into cuda-core (largely agent driven). Two notes on this: * I removed CCCL_HOME env var as it seems the submodule should cover this * The `sdist` bloats a lot (12.5MiB) due to this. This seemed fine since we never intend to ship it? * On a whim: added to dependabot to update monthly. The other thing is that the TMA code now actually uses the CCCL path (enabled by having the newest version with multiple fixes). Note that even with this there are some few paths that cannot take this path due to DLPack exchange limitations, unfortunately. Which makes this all slightly unclear. Notes on the TMA changes: * I moved everything to Cython, C++ is nice, but just adds a layer here. * I moved a lot of things to be proper `cdef` (changed some tests) * Since the CCCL path is now used and I moved things to Cython, the error normalization is slightly less precise. Raising a CUDAError with the CCCL string and also raising it for the bad compute capability check included there (probably also a cuda error on the driver path, though). This seems likely not the last word here...
5503921 to
a75c3b6
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Priority: ⬇️ Low Change: Feature Merge Risk: ⚪ Minimal · up to
|
| except RuntimeError as err: | ||
| # RuntimeErrors here should in practice be CUDAErrors. | ||
| # (either driver error or compute capability check). | ||
| raise CUDAError(str(err)) from err |
There was a problem hiding this comment.
You call this out in the PR body, but worth capturing a decision inline: everything CCCL throws as a std::runtime_error — the driver-return path and the compute-capability guard — collapses to CUDAError here. CUDAError is defined elsewhere as "a CUDA driver call returned non-success," so a host-side CC rejection carrying that type is a semantic regression vs. the old C++ shim, and users keying off exception type to distinguish "driver said no" from "my GPU is too old" lose that signal.
One option: catch the two upstream shapes separately — let CC check surface as RuntimeError (or a dedicated UnsupportedComputeCapabilityError) and keep CUDAError for genuine driver returns. If upstream makes that hard to tell apart from the exception alone, a cheap pre-check against view.__dlpack_device__() → device CC before invoking CCCL would also work.
| def test_swizzle_via_options(self, dev, skip_if_no_tma): | ||
| # SWIZZLE_128B caps the innermost box at 128 bytes; 64 float32 is 256. | ||
| buf = dev.allocate(1024 * 4, stream=dev.default_stream) | ||
| with pytest.raises(ValueError, match="bytes128"): |
There was a problem hiding this comment.
match="bytes128" here, and match="multiple of 16" further down at line 320, are both matching substrings of CCCL's own _CCCL_THROW(std::invalid_argument, …) message strings (see cuda_core/third_party/cccl/libcudacxx/include/cuda/__tma/make_tma_descriptor.h). With dependabot bumping CCCL monthly, any upstream wording tweak breaks these without a real behavior change.
Either match on the exception type alone and assert the behavioral invariant another way, or pick a tighter semantic token the upstream maintainers are likely to keep stable (e.g. the enum spelling tma_swizzle::bytes128, or box_sizes).
There was a problem hiding this comment.
right... I think I like matching something and this seems pretty sensible for "probably stable" already.
As to the CUDAError, yes we could try to narrow it, but part of why to use CUDAError is that it is what the other branch currently will give.
| [submodule "cuda_core/third_party/cccl"] | ||
| path = cuda_core/third_party/cccl | ||
| url = https://github.com/NVIDIA/cccl.git | ||
| branch = main |
There was a problem hiding this comment.
branch = main + the dependabot entry means we're floating on CCCL's dev tip. The current pin (ba8eb88f) is 544 commits past v3.6.0 because the TMA fixes you need aren't in a tagged release yet — understandable — but once they are, I'd advocate switching to the release tag and treating the dependabot PRs as "take the latest tag" rather than "take latest main". Either way, worth adding a one-line comment here capturing the policy so the next maintainer isn't guessing.
There was a problem hiding this comment.
Hmmm, yeah, I guess we may want to change this to not track main but rather the latest release tag eventually.
(ignored the "add comment", though)
| # setuptools-scm only records the submodule gitlink, so the checkout must be | ||
| # grafted or wheel-from-sdist has no CCCL headers. Exclude .git so the sdist | ||
| # does not ship a pointer into this repository. | ||
| graft third_party/cccl |
There was a problem hiding this comment.
graft third_party/cccl ships the entire CCCL repo (~47 MiB on disk; cub, thrust, cudax, docs, python, c, ci) when _get_cccl_include_dirs() only consumes libcudacxx/include (~16 MiB on disk). Narrowing to
graft third_party/cccl/libcudacxx/include
include third_party/cccl/LICENSE
include third_party/cccl/libcudacxx/LICENSE.TXT
should shrink the sdist by roughly 2/3 without changing the build. You acknowledged the 12.5 MiB bloat in the PR body — since no sdist is published to PyPI today, this is CI-internal weight only, but trimming it also removes the question of whether we're redistributing cub/thrust under their own license terms. Fine to defer; worth deciding one way or the other before merge.
I'll guess that this'll need some discussion. Doing the CCCL and TMA at the same time is nice for testing, but I can split it out for easier review: My understanding is that we expect more usage out of a CCCL submodule (otherwise this would be dubious to me).
Description
This now does two things. First, it vendors CCCL into cuda-core (largely agent driven). Two notes on this:
sdistbloats a lot (I believe to 12.5MiB) due to this. This seemed fine since we never intend to ship it?The other thing is that the TMA code now actually uses the CCCL path (enabled by having the newest version with multiple fixes). Note that even with this there are some few paths that cannot take this path due to DLPack exchange limitations, unfortunately. Which makes this all slightly unclear.
Notes on the TMA changes:
cdef(changed some tests)This seems likely not the last word here...
Checklist