[BUG]: DLPack tensors may be released before async launch work is finished
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Bắt đầu trong cext/tile_kernel.cpp bằng cách lần theo arrayrepr_dlpack() qua arrayrepr_dlpack_common() đến launch(), đồng thời so sánh thời điểm capsule bị xóa với thời điểm cuLaunchKernelEx() được gọi. Xác thực hành vi lifetime bằng một Producer có Deleter giải phóng Owner cuối cùng của nó hoặc trả bộ nhớ về một pool. Hoàn tất khi tensor được quản lý vẫn được giữ lại cho đến khi công việc launch bất đồng bộ đã sử dụng nó xong một cách an toàn, với coverage cho đường đi DLPack generic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
current main checkout (0477a34 locally); this code path appears to date back to the initial public import as well
CUDA Toolkit Version
not pinned yet; this came from source review rather than a runtime repro on a specific toolkit version
Which installation method(s) does this occur on?
Source
Describe the bug
I think the generic DLPack launch path is releasing consumed DLManagedTensor objects too early.
In cext/tile_kernel.cpp, arrayrepr_dlpack_common() renames the capsule to "used_dltensor" and then immediately calls tensor->deleter(tensor). That happens while kernel arguments are still being prepared, before prepare_launch() returns, and before cuLaunchKernelEx() is called.
For generic __dlpack__ objects, arrayrepr_dlpack() also calls __dlpack__(stream=-1), so the producer is explicitly being told not to synchronize.
My understanding of the DLPack ownership/lifetime contract is that once the consumer takes ownership of the capsule, it should keep the managed tensor alive until the consumer is actually done with it. Releasing it during argument parsing looks wrong on its own, and in the async CUDA launch path it seems like it could become a stale-pointer / premature-release problem for producers that rely on the deleter to hold the export alive until consumer work has safely passed.
What made me look twice is that there is already a comment in the code saying this is "technically an incorrect implementation" and suggesting an event-based deferred release after launch.
The control flow I am looking at is:
arrayrepr_dlpack()calls__dlpack__(stream=-1)arrayrepr_dlpack_common()reads the pointer, renames the capsule, and immediately calls the deleter- the actual kernel enqueue happens later in
launch()viacuLaunchKernelEx()
Minimum reproducible example
I do not have a clean runtime repro yet. I found this during code review because the control flow itself looks off:
1. producer returns a DLPack capsule
2. cuTile reads the exported pointer
3. cuTile immediately calls the DLPack deleter
4. the CUDA kernel launch happens afterwards, asynchronously
The repro shape I would expect to fail is a producer whose deleter drops the last owner or returns memory to a pool before the launched kernel has actually finished using the pointer.
Relevant log output
none yet
Full env printout
not available yet
Other/Misc.
Code pointers on current main:
cext/tile_kernel.cpp:arrayrepr_dlpack_common()cext/tile_kernel.cpp:arrayrepr_dlpack()cext/tile_kernel.cpp:launch()
If I am reading the intent correctly, it seems like the managed tensor probably needs to stay alive until launch work on the relevant stream is safely past the point where the producer can release it, rather than being deleted during argument extraction.
Happy to help with a repro if that would be useful.
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 155
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA/cutile-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA/cutile-python#105 · 2 bình luận ·
-
bug status: needs-triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
NVIDIA/cutile-python#102 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
NVIDIA/cutile-python#101 ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
NVIDIA/cutile-python#97 · 1 bình luận ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
NVIDIA/cutile-python#96 · 1 bình luận ·
Tất cả issue của NVIDIA/cutile-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
anthropics/skills#1811 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
speaches-ai/speaches#678 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
datalayer/mcp-compose#42 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
conda-forge/spacy-feedstock#177 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
UKGovernmentBEIS/inspect_evals#2523 ·