Skip to content

Synchronize pageable host uploads - #618

Merged
maleadt merged 1 commit into
mainfrom
tb/sync-pageable-uploads
Aug 20, 2026
Merged

Synchronize pageable host uploads#618
maleadt merged 1 commit into
mainfrom
tb/sync-pageable-uploads

Conversation

@maleadt

@maleadt maleadt commented Aug 19, 2026

Copy link
Copy Markdown
Member

Level Zero memory copies read their host source when the queued command executes, but Array uploads returned after submission and only preserved the source through that submission. A temporary source could therefore be collected and its storage reused before a delayed copy ran, silently corrupting device data.

Synchronize the task-local queue inside the GC preserve region so pageable host memory remains valid until the upload completes. This deliberately makes Array-to-device copies synchronous, matching the existing device-to-Array behavior.

I think this should solve the corruptions seen on AcceleratedKernels.jl.

Level Zero memory copies read their host source when the queued command executes, but Array uploads returned after submission and only preserved the source through that submission. A temporary source could therefore be collected and its storage reused before a delayed copy ran, silently corrupting device data.

Synchronize the task-local queue inside the GC preserve region so pageable host memory remains valid until the upload completes. This deliberately makes Array-to-device copies synchronous, matching the existing device-to-Array behavior.
@github-actions

Copy link
Copy Markdown
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/array.jl b/src/array.jl
index 4c80540..9a99f3e 100644
--- a/src/array.jl
+++ b/src/array.jl
@@ -445,12 +445,12 @@ Base.copyto!(dest::oneDenseArray{T}, src::oneDenseArray{T}) where {T} =
 
 function Base.unsafe_copyto!(ctx::ZeContext, dev::ZeDevice,
                              dest::oneDenseArray{T}, doffs, src::Array{T}, soffs, n) where T
-  GC.@preserve src dest begin
-    unsafe_copyto!(ctx, dev, pointer(dest, doffs), pointer(src, soffs), n)
+    GC.@preserve src dest begin
+        unsafe_copyto!(ctx, dev, pointer(dest, doffs), pointer(src, soffs), n)
 
-    # Keep pageable host memory alive until the queued copy completes.
-    synchronize(global_queue(ctx, dev))
-  end
+        # Keep pageable host memory alive until the queued copy completes.
+        synchronize(global_queue(ctx, dev))
+    end
   if Base.isbitsunion(T)
     # copy selector bytes
     error("oneArray does not yet support isbits-union arrays")

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.02%. Comparing base (5f21420) to head (f01186e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #618      +/-   ##
==========================================
- Coverage   80.90%   79.02%   -1.89%     
==========================================
  Files          50       50              
  Lines        3488     3490       +2     
==========================================
- Hits         2822     2758      -64     
- Misses        666      732      +66     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michel2323

Copy link
Copy Markdown
Member

ALCF pipeline is broken after a maintenance window. Filed a ticket.

@maleadt
maleadt merged commit 8d8be1c into main Aug 20, 2026
4 of 5 checks passed
@maleadt
maleadt deleted the tb/sync-pageable-uploads branch August 20, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants