Fix `cuMemcpyBatchAsync` with `cuMemHostRegister`-ed host memory on WSL2 #1108
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 261 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.333
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1108"
general
weight: 0.35
wence-
Summary
On WSL2, every KvikIO write from device memory fails with
CUDA_ERROR_ILLEGAL_ADDRESS(inFileHandle::pwrite->posix_device_write), in both compat and GDS modes.Since #954,
posix_device_iocopies withcuMemcpyBatchAsync(viacuda_memcpy_async). Writes stage data throughCudaPageAlignedPinnedBounceBufferPool, which pins analigned_allocbuffer withcuMemHostRegister. On devices whereCU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEMis 0 (as on WSL2), the device address of such memory differs from its host address (for example host0x7fffa5dfe000maps to device0x204e00000).cuMemcpyAsynctranslates the host address, butcuMemcpyBatchAsyncdoes not: it returnsCUDA_SUCCESSand the copy engine writes to the raw host address. The fault only appears at the nextcuStreamSynchronize. Reads aren't affected because their bounce buffers come fromcuMemHostAlloc, whose addresses match.This change replaces each pinned host pointer with its
cuMemHostGetDevicePointeralias before callingcuMemcpyBatchAsync. Only pointers thatcuPointerGetAttributereports as host memory are translated, so device pointers are passed through unchanged. Where host and device addresses are identical the alias equals the host pointer and behavior does not change.Two regression tests copy to and from a page-aligned,
cuMemHostRegister-ed buffer in both directions.Dependency
This is stacked on the
DevBufferfix in #1107 (the first commit in this PR), because the new tests are only reliable with it. That PR should merge first; until then this diff also shows its commit.Testing
On WSL2 (RTX 2070 Super, driver 617.14, CUDA 13.3):
CUDA_ERROR_ILLEGAL_ADDRESSwithout the fix and pass with it.SHIM_CUDA_TEST: 25 of 25 runs pass.ctest: 29 of 29 pass. Without the fix,BASIC_IO_TESTandOBSERVATION_TESTfail on this machine.