Skip to content

Conversation

@stiepan
Copy link
Member

@stiepan stiepan commented Nov 27, 2025

Description

If dlpack's make_py_capsule is interrupted with an exception, it does not free memory malloced for the dl tensor and layout data.
This PR:

  • splits the make_py_capsule into a couple of different helpers (allocating the dlm tensor, layout setup, device setup, dtype setup) for readability
  • adjusts deleters so that they can be safely run with partially initialized object
  • adds a test that checks if the cleanup was run when exception is raised by checking the refcount of the buffer object. As the decref is not left to the deleter, this assures the deleter was run.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Nov 27, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@leofang leofang added bug Something isn't working P1 Medium priority - Should do cuda.core Everything related to the cuda.core module labels Nov 30, 2025
@leofang leofang added this to the cuda.core beta 10 milestone Nov 30, 2025
@leofang
Copy link
Member

leofang commented Nov 30, 2025

/ok to test 044f179

@leofang leofang enabled auto-merge (squash) November 30, 2025 02:09
@github-actions

This comment has been minimized.

@leofang leofang merged commit ca74d6d into NVIDIA:main Nov 30, 2025
64 checks passed
@github-actions
Copy link

Doc Preview CI
Preview removed because the pull request was closed or merged.

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

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants