Skip to content

[FEA]: Support inheritance from Buffer #2435

Closed as not planned
Closed as not planned

Description

@carterbox

Is this a duplicate?

Area

cuda.core

Is your feature request related to a problem? Please describe.

nvmath-python is considering creating a subclass of Buffer specific to NVSHMEM because we want to mostly follow cuda.core's semantics for Buffer/MemoryResource, but need some different behavior regarding garbage collection.

Describe the solution you'd like

Buffer should use classmethod instead of staticmethod for all methods that return an instance of the class. i.e. from_handle() and _reduce_helper()

Describe alternatives you've considered

Composing Buffer with our Buffer.
Replicating the Buffer protocol with an unrelated class.
Rolling our own MemoryResource/Buffer abstraction that is unique to nvmath's distributed APIs.

Additional context

Related to: #750

Activity

  1. mdboom commented on Jul 29, 2026

    @mdboom
    Contributor

    As an aside, do we want to consider a policy of favoring @classmethod over @staticmethod throughout CUDA core? I think unless there is a good reason to make a class "final" (in the C++ sense) we shouldn't make it hard to subclass.

    @Andy-Jost: thoughts?

  2. added this to the cuda.core next milestone on Sep 24, 2026
  3. added
    P1Medium priority - Should do
    and removed
    triageNeeds the team's attention
    cuda.coreEverything related to the cuda.core module
    on Sep 24, 2026
  4. added
    cuda.coreEverything related to the cuda.core module
    on Nov 4, 2026
  5. leofang commented on Nov 4, 2026

    @leofang
    Member

    I recall in an internal thread around Aug 13 we discussed that we prefer composition over inheritance, except for memory resources inheriting from the abstract base class. @carterbox is this still needed?

  6. removed their assignment
    on Nov 4, 2026
  7. added and removed
    P1Medium priority - Should do
    on Nov 4, 2026
  8. removed this from the cuda.core next milestone on Nov 4, 2026
  9. carterbox commented on Nov 5, 2026

    @carterbox
    ContributorAuthor

    We've decided to take option 3: "Rolling our own MemoryResource/Buffer abstraction that is unique to nvmath's distributed APIs."

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

    cuda.coreEverything related to the cuda.core module

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions