← Back to Pull requests

Observe completion of an independently synchronized context #3611

Closed
unknown closed this pull request without merging on Nov 26, 2026 02:51 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 19:53 UTC
Author

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) and isready(token). Creating or polling the token submits no GPU work. A subsequent successful device_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.

Diff: 170 lines (+127 / -43) across 2 files Reviewer: maleadt Review duration: 9058m
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
0.35
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 70%
64%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 64% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 35.2% (MEDIUM) · Higher = larger blast radius
35.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 64% · Lower = rushed or shallow review
64%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 12.7% · Safe to merge
12.7%