← Back to Pull requests

Treat constant-typed Julia call results as inactive in mixed activity errors #4113

Closed
unknown closed this pull request without merging on Nov 26, 2026 10:18 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 10:20 UTC
Author

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.

Diff: 181 lines (+135 / -46) across 2 files Reviewer: vchuravy Review duration: 4318m
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
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: 35%
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.311
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4113"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% 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.6% (MEDIUM) · Higher = larger blast radius
35.6%
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.5% · Lower = rushed or shallow review
60.5%
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.1% · Safe to merge
14.1%