[FEA]: Add a `release()` method to `cuda.core.Buffer` to side-step the Python garbage collector
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Cython
- Sterne
- 3.4k
- Forks
- 329
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 116
Beschreibung
Is this a duplicate?
- I confirmed there appear to be no duplicate issues for this request and that I agree to the Code of Conduct
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in cuda_core/cuda/core/experimental/_memory.py ungefähr bei Zeile 51, wo der schwache Fallback-Finalizer definiert ist, und verfolge, wie der close-Pfad des Buffer-Objekts ihn verwaltet. Die Arbeit ist abgeschlossen, wenn release() diesen Finalizer deregistriert, während close() weiterhin der explizite Weg bleibt, den Buffer freizugeben; prüfe die Details der nahegelegenen Buffer-Implementierung auf das relevante Verhalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100