Skip to content

Add cuda.core.NDBuffer #674

Closed as not planned
Closed as not planned

Description

@leofang

Moving the tracking issue to the public. Unlike the existing Buffer which is a 1D contiguous, untyped blob, we want to have a typed buffer that feels more natural to use as underlying memory of tensors/arrays. The requirements include

  • Arbitrary dimension
  • Holds the underlying pointer
  • Holds shape
  • Holds strides
  • Exposes same attributes as Buffer does

The only bit that needs discussion during design meetings: Is it owning or non-owning?

Activity

  1. added this to the cuda.core parking lot milestone on Jun 2, 2025
  2. added
    triage
    P1
    feature
    cuda.core
    on Jun 2, 2025
  3. leofang commented on Jun 4, 2025

    @leofang
    MemberAuthor

    Capturing what Satya noted in an offline meeting:

    I think NDBuffer is useful for two reasons:

    • While it's possible for users to compute the offset themselves, it's better to do that as part of the type so that each user is not burdened with it.
    • We can offer efficient copy functions across layouts that users can take advantage of. While it's straightforward to write a copy function, it's hard to write a performant copy function.
  4. kkraus14 commented on Jun 4, 2025

    @kkraus14
    Collaborator

    The name NDBuffer is very confusing to me as I think of a Buffer as an untyped region of memory. I think using ndarray (more Python than mdarray?) is a more natural name, though we don't want to give the impression we will have all of the functionality that Python users expect of an array and we are purely a data container.

    As far as ownership semantics go, we could take the NumPy like approach, where instead of StridedMemoryView that is purely a non-owning class, we could have a single class that can act as both an owning type (where it allocates a Buffer underneath itself on construction as needed) or a view type (where it holds a reference to a Python object that supports __dlpack__ protocol or similar).

  5. cpcloud commented on Nov 17, 2025

    @cpcloud
    Contributor

    It seems like we've already gone down the path of the dual-ownership numpy-like model, since StridedMemoryView has an exporting_obj member that is the owning object of the data backing the view.

  6. leofang commented on Dec 11, 2025

    @leofang
    MemberAuthor

    Yes. This issue could need a bit of update. The tl;dr is: Instead of NDBuffer, we just add StridedLayout. Together with the existing 1D contiguous, untyped Buffer, it can represent what we need with NDBuffer. @stiepan has done this part in #1283 and is working on migrating the ND-copy routine from nvmath-python.

  7. leofang commented on Dec 15, 2025

    @leofang
    MemberAuthor

    Copy-pasting @kkraus14's offline summary:

    • We don't want this to ultimately live in cuda.core, but want it to live in CCCL. We want the implementation in CCCL C++ but with the typical exposure up through CCCL Python that is JITed.
    • We will close the PR at the top of the thread and revert the StridedLayout changes made to SMV prior to the 0.5.0 release of cuda.core.
    • nvmath-python will continue to rely on their internal implementation until we have a new implementation usable in CCCL-Python.
  8. leofang commented on Jan 7, 2026

    @leofang
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1cuda.corefeaturetriage

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions