← Back to Pull requests

Report synchronizations with the GPU in `CUDA.@timed` #3635

Closed
unknown closed this pull request without merging on Nov 26, 2026 15:18 UTC
View on GitHub
unknown unknown commented on Nov 26, 2026 03:05 UTC
Author

CUDA.@timed now returns the number of synchronizations with the GPU made while running the expression, in a new field gpu_syncstats (sync_count), next to the compilation statistics of #3625. This lets libraries test that a warm call never makes CUDA.jl wait for the GPU, e.g. when its memory moves to another stream or to a library through its pointer, without mirroring CUDA.jl's ownership logic:

step!(state)
stats = CUDA.@timed (step!(state); step!(state))
@test stats.gpu_syncstats.sync_count == 0

CUDA.@timed synchronizes the GPU before running the expression, and CUDA.jl skips synchronizations whose work has already finished, so the second call is what checks for waits on running work.

Every synchronization of a stream, event or context goes through synchronize_object, which now does one atomic add. Explicit synchronize/device_synchronize calls always count; waits inside driver calls and libraries don't, and neither do CUDA.@timed's own. CUDA.@time doesn't print the count. Like the other statistics, it's global across tasks.

Synchronization cost is unchanged (RTX 5080, minimum per call, two alternating runs each):

| | main | PR |
|:--|--:|--:|
| synchronize() | 165 / 166 ns | 157 / 160 ns |
| synchronize(blocking=true) | 138 / 135 ns | 127 / 140 ns |
| synchronize(event) | 174 / 181 ns | 177 / 171 ns |
| device_synchronize() | 701 / 679 ns | 680 / 670 ns |

Closes #3590. Its destroyed-stream half was already fixed by eb2d739778.

Diff: 187 lines (+140 / -47) across 2 files Reviewer: maleadt Review duration: 733m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 187 lines diff across 2 files
0.36
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%
60%
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.313
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3635"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.2% 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.8% (MEDIUM) · Higher = larger blast radius
35.8%
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: 60.2% · Lower = rushed or shallow review
60.2%
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: 14.2% · Safe to merge
14.2%