Observe completion of an independently synchronized context #3611
All Vouch review confidence checks passed
Residual risk 0.13 = Change Risk (0.35) × (1 − Review Confidence (0.64)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 170 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 70%
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.308
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3611"
general
weight: 0.35
maleadt
CUDA.jl defers release of memory last used on a per-thread default stream until reclaim. At that point the original host thread can be unknown. An application may already have synchronized the context since retirement, but the release currently has no way to observe that and requests a second synchronization.
This adds
CUDACore.device_completion(ctx)andisready(token). Creating or polling the token submits no GPU work. A subsequent successfuldevice_synchronize()or synchronous reclaim on the same context makes it ready. A context synchronization already in progress at registration cannot qualify the token. Stream synchronizations leave it pending.The existing per-thread cleanup checks a token taken at retirement before requesting its own synchronization. Contexts with no observers take a fast path. The registry holds weak references so tokens own their observation state.
Tests cover stream-only synchronization, blocking and cooperative device synchronization, independent contexts, synchronous reclaim, failure, and registration during an in-flight synchronization. All nine focused checks passed on an RTX PRO 6000 with Julia 1.13.4, including a token registered while an actual cooperative device synchronization waited for a running kernel.
Related discussion about observing host synchronization in ownership tracking is in #3590.