Use the shadow global under global activity #3883
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.41) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.41 · 208 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: 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.320
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3883"
general
weight: 0.35
vchuravy
<!-- claude-projects-attribution: {"github_login":"vchuravy"} -->
_Requested by Valentin · project thread_
Replaces #3342.
What
In combined and forward mode,
invertPointerMgives a global withoutenzyme_shadowa zeroed local alloca as its shadow when no call in the function may touch it. With-enzyme-global-activityset, this PR skips that shortcut and always uses the shadow global.Why
Under global activity the derivative held in a global outlives the call. In the test,
@fwrites@gand calls@leaf, which reads it.@diffeleafadded its adjoint into a local zeroed copy of@g, while@diffefread the adjoint from@g_shadowafter the call, so the gradient was 0. The same happens across repeated calls of one function and for Fortran SAVE/COMMON state. Found differentiating MITgcm with LLVM flang and full LTO.#3342 kept the shortcut and checked whether any other function uses the global. Under global activity every global derivative may be read by a caller or a later call, so this PR drops the shortcut in that mode instead. Without global activity nothing changes.
Test
enzyme/test/Enzyme/ReverseMode/global-activity-callee-global-shadow.llchecks that@diffeleafhas no alloca and accumulates into@g_shadow, and that@diffefreads the adjoint from there. It fails on main and passes here on LLVM 24 (df0a91f6). The other global tests in ReverseMode and ForwardMode give the same results with and without the change. On that LLVM, 10 of them fail on main too.---
_Generated by Claude Code_