Skip to content

fix(cuda): Preserve CUDA buffer alignment metadata during upload - #11329

Merged
0ax1 merged 2 commits into
developfrom
ad/cuda-upload-alignment
Nov 9, 2026
Merged

0ax1 merged 2 commits into
developfrom
ad/cuda-upload-alignment

Conversation

@0ax1

@0ax1 0ax1 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Preserve alignment metadata when uploading host buffers through
ensure_on_device and its synchronous variant. Uploading a typed buffer as
bytes currently reduces its recorded alignment to one byte, even when the
CUDA allocation satisfies the original alignment. This causes decimal
reconstruction to reject otherwise valid device buffers, as exposed by the
Widen tests in #11303.

Restore the source alignment with a metadata-only update after the existing
upload. No additional data copy, device allocation, or synchronization is
introduced for alignment.

Changes

  • Preserve source alignment in asynchronous and synchronous uploads.
    Already-device buffers remain unchanged.
  • Check alignment against the actual device pointer, including the slice
    offset. Requests above 256 bytes remain supported when the address
    satisfies them.
  • Return an error rather than panic or copy when the device pointer cannot
    satisfy the requested alignment. Uploads now explicitly fail if the source
    alignment cannot be preserved.
  • Reduce slice alignment metadata according to its offset instead of
    retaining an invalid stronger guarantee.
  • Add regression coverage for all six decimal widths, full/sliced/empty
    uploads, both upload paths, already-device identity, and metadata-only
    alignment updates.

Preserve source alignment after host-to-device uploads without an
additional data copy. Report unsupported pointer alignment as an error
and reduce alignment metadata when slicing device buffers.

Add regression coverage for async and synchronous decimal uploads,
metadata-only alignment updates, and sliced buffers.

Signed-off-by: Alexander Droste <[email protected]>
@0ax1 0ax1 added the changelog/fix A bug fix label Nov 9, 2026
@0ax1

0ax1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

fixes: #11303

@0ax1
0ax1 requested a review from robert3005 November 9, 2026 11:42
@0ax1
0ax1 enabled auto-merge (squash) November 9, 2026 11:43
@0ax1
0ax1 requested a review from mprammer November 9, 2026 11:43
@0ax1 0ax1 changed the title fix(CUDA): Preserve CUDA buffer alignment metadata during upload fix(cuda): Preserve CUDA buffer alignment metadata during upload Nov 9, 2026
@0ax1
0ax1 disabled auto-merge November 9, 2026 11:43
@0ax1
0ax1 enabled auto-merge (squash) November 9, 2026 11:44
@0ax1
0ax1 merged commit 3fb46d5 into develop Nov 9, 2026
77 checks passed
@0ax1
0ax1 deleted the ad/cuda-upload-alignment branch November 9, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants