Skip to content

Conversation

lkdvos
Copy link
Member

@lkdvos lkdvos commented Jun 25, 2025

Improve memory management by ensuring proper destruction of operation descriptors and plan preferences in the cuTENSOR plan function.

This is the equivalent of https://github.com/JuliaGPU/CUDA.jl/pull/2794/files

Fixes #211

@lkdvos lkdvos requested a review from Jutho June 25, 2025 16:54
@lkdvos lkdvos merged commit 71191a6 into master Jun 30, 2025
14 checks passed
@lkdvos lkdvos deleted the memleak branch June 30, 2025 11:56
cutensorCreatePlanPreference(handle(), plan_pref, algo, jit)

return CuTensorPlan(desc[], plan_pref[]; workspacePref=workspace)
plan = CuTensorPlan(desc[], plan_pref[]; workspacePref=workspace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how does this work; the OperationDescriptor and PlanPreference are copied by the CuTensorPlan constructor, so the original copies need to be destroyed afterwards?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are used, and then no longer needed. To be honest, I didn’t check precisely what is going on the first time and just copied this over from the cuTENSOR implementation for reductions, so now I just adapted the changes from the PR there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential memory leak for cuTENSOR contractions with minimal example
2 participants