Treat constant-typed Julia call results as inactive in mixed activity errors #4113
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 · 181 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.311
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4113"
general
weight: 0.35
vchuravy
When a constant value meets an active one, for example an integer array returned in a tuple next to an active array, the ET_MixedActivityError handler in julia_error accepts the mismatch only if it can show that the constant value cannot carry derivatives. For the result of a non-inlined Julia call it could not: abs_typeof reads the call's Julia return type (enzymejl_rt) only when the call uses an sret. In that case the call returns void, so the type was never known. Returning the result of findall, sortperm or reshape(Int32[...], 1, 1, :) next to an active argument from a @noinline function therefore raised an EnzymeRuntimeActivityError, even when the function producing the integer array was marked inactive.
The handler now checks the call's Julia return type directly, before it falls back to abs_typeof. If the call returns without an sret and that type is guaranteed_const_nongen, the value is inactive and its primal is used as its shadow.
Flipping the sret check in abs_typeof instead makes it type call results for all of its callers. That broke "Literal RT mismatch" in test/mixed.jl and "Zero type unstable shadow" in test/typeunstable.jl, so abs_typeof is unchanged.
Tests: two new testsets in test/absint.jl cover Forward, batched Forward and Reverse with findall, sortperm and an inactive sortperm wrapper, plus the reshape case from the issue.
Fixes #3873.