[BUG]: CUtensorMap owned storage does not honor required alignment
Maintainer thường phản hồi trong vòng 1 ngày
@isVoid đang làm issue này rồi.
Từ ngày 22/10/2026.
Đá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
- 45/100
Hướng nghiên cứu
Read cuda_bindings/cuda/bindings/driver.pyx and _v2/driver.pyx at the cited constructors, then inspect the generator's AUTO_LOWPP_CLASS allocation and existing tensor-map tests. Compare owned storage addresses with alignof(CUtensorMap) for the supported CUDA headers, including encoding wrappers and copy-producing construction. Done means owned storage is explicitly aligned, deallocated correctly, and regression tests assert pointer alignment.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Type of Bug
Something else: backing-storage alignment does not meet the C type's declared requirement.
Component
cuda.bindings
Describe the bug
I discovered this alignment issue while reviewing #3095, which adds the _v2.driver API. Checking the existing cuda.bindings.driver.CUtensorMap implementation showed that the same allocation pattern is already present in released versions.
The wrapper embeds the C descriptor inside a Python object and does not explicitly enforce its alignment. The required alignment depends on the CUDA header version: the wrapper documentation specifies 128 bytes in v13.4.4 and 64 bytes in v12.9.9.
Released implementations with this allocation pattern
- v13.4.4:
CUtensorMap_st.__cinit__points_pvt_ptrat the inline_pvt_val; its docstring specifies 128-byte alignment. - v12.9.9: the same constructor pattern is present; its docstring specifies 64-byte alignment.
These are concrete released examples confirmed by source inspection, not a claim about the first affected release. PR #3095 uses equivalent inline storage for _v2.driver.TensorMap. This issue tracks the shared allocation limitation separately from that PR.
In the legacy wrapper, default construction points _pvt_ptr at &self._pvt_val:
The C compiler can align a member's offset within the containing object, but CPython's object allocator does not guarantee a 128-byte-aligned base address. Consequently, the descriptor's actual address need not meet the C type's alignment requirement.
How to Reproduce
Inspect the backing addresses of existing legacy API objects, for example with cuda.bindings v13.4.4; no GPU or CUDA API call is needed:
from cuda.bindings import driver
# Keep the objects alive so the allocator cannot simply reuse one address.
maps = [driver.CUtensorMap() for _ in range(200)]
addresses = [int(m.getPtr()) for m in maps]
print("address residues modulo 128:", sorted({p % 128 for p in addresses}))
print("address residues modulo 64:", sorted({p % 64 for p in addresses}))
assert all(p % 128 == 0 for p in addresses)
For v12.9.9, check modulo 64 instead, matching that version's documented requirement.
The assertion can fail because alignment stronger than the Python allocator's guarantee occurs only incidentally. Exact residues depend on the Python build and allocator; a run that happens to return aligned addresses does not establish a guarantee.
Validation: source inspection confirms the inline allocation in both versions. A separately compiled Cython reproduction using the actual CUDA header and the new wrapper's class layout produced descriptor addresses with residues 0, 16, 32, and 48 modulo 64. The legacy-API script above is provided for validation against an installed build; it was not run as part of that reproduction.
Expected behavior
Owned tensor-map storage should honor alignof(CUtensorMap) (128 bytes in the inspected header), including storage used internally by encoding wrappers. Regression tests should check the pointer alignment directly, not only whether encoding succeeds.
Observed impact and scope
No CUDA encoding failure or protected-memory fault has been demonstrated here. Existing tensor-map tests do not establish a storage-alignment guarantee, and successful encoding alone does not prove that guarantee. This report concerns meeting the documented alignment contract; it should not claim that tensor-map APIs are generally unusable or that #3095 newly breaks them.
Possible fix
Provide explicitly aligned owned storage for tensor-map wrappers, with matching deallocation and support for copy-producing construction paths. The generator's external-storage mode currently uses ordinary allocation, so selecting it alone does not guarantee extended alignment.
A broader generator enhancement could support alignment-aware allocation for AUTO_LOWPP_CLASS; a dedicated tensor-map allocation path is another option. Borrowing an externally aligned pointer is already possible, but does not fix wrappers that construct their output object internally, such as the new tensor_map_encode_tiled.
- Ngôn ngữ chính
- Cython
- Star
- 3.4k
- Fork
- 353
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 163
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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/cuda-python
-
[BUG]: the `__cuda_stream__` deprecation warning points to `Stream(obj)`, which always raisesCó thể đã có người làm @Iamsohungrynow đã nhận 5 ngày trước. Đang mởbug cuda.core P1
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
NVIDIA/cuda-python#3505 · 3 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG]: ProcessInfo.used_gpu_memory returns the NVML_VALUE_NOT_AVAILABLE sentinel as a byte countĐang mởtriage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
NVIDIA/cuda-python#3468 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
NVIDIA/cuda-python#3409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG]: cleanup-pr-previews never removes previews of deleted PRsCó thể làm lại được @rwgk đã nhận 48 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
NVIDIA/cuda-python#2952 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookupCó thể đã có người làm @rwgk đã nhận 62 ngày trước. Đang mởtriage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA/cuda-python#2646 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NVIDIA/cuda-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vllm-project/vllm#70030 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
help wanted small extra
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
t: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)Có thể đã có người làm @waleedkadous đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
iaser-ai/ansari#444 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày