NVIDIA / NVIDIA/cuda-python

[FEA]: Add a `release()` method to `cuda.core.Buffer` to side-step the Python garbage collector

オープン
#567 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

cuda.core feature
主要言語
Cython
スター
3.4k
フォーク
329
平均マージ
1日 23時間
マージ済み PR(30日)
116

説明

Is this a duplicate?
Area

cuda.core

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

@realarnavgoel brought up this issue offline that we currently have a fallback weak finalizer
https://github.com/NVIDIA/cuda-python/blob/d425a8895bd778fffb993263dbf5d9bc631fea22/cuda_core/cuda/core/experimental/_memory.py#L51
in case users forget to explicitly call .close() to free the memory. This could interfere with projects such as nvmath-python and nvSHMEM who require explicit control over the buffer lifetime and deallocation timing.

Describe the solution you'd like

We discussed offline and came up with this proposal that we'll add a .release() method to the buffer object. The idea is that if it is called, the weak finalizer will be unregistered, so that the only way to free the buffer is to call .close() explicitly later.

Describe alternatives you've considered

No response

Additional context

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

フォールバックの弱いファイナライザが定義されている cuda_core/cuda/core/experimental/_memory.py の51行目付近から始め、Buffer オブジェクトの close パスがそれをどのように管理しているかを追ってください。release() がそのファイナライザの登録を解除し、close() が引き続きバッファを解放する明示的な方法である状態になれば作業は完了です。関連する動作について、近くにある Buffer の実装の詳細を確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。