Skip to content

Inline the Recurrence keyword constructor so Enzyme static activity holds under coverage - #1066

Merged
seabbs merged 1 commit into
mainfrom
fix/enzyme-static-activity
Dec 5, 2026
Merged

seabbs merged 1 commit into
mainfrom
fix/enzyme-static-activity

Conversation

@seabbs-bot

Copy link
Copy Markdown
Collaborator

This fixes the six static activity errors on the Enzyme reverse AD job, first seen on #1063's sharded run.
The cause is code coverage: under coverage, Julia stopped inlining the Recurrence keyword constructor.
Enzyme then rejected the constant kernel inside the operator the constructor returned.
The fix marks that constructor @inline.

Claude Opus 5.5 [high]

Cause

  • CI: Enzyme reverse shard 1/2 of run 47466446534 (job 145528247136) failed on all six cases of "Enzyme reverse in its default mode takes each rule" in test/ad/static_activity.jl with EnzymeRuntimeActivityError. The error is "Constant memory is stored ... to a differentiable variable", in var"#Recurrence#432", the body of the keyword constructor, with kernel::Array stored into sret.
  • Each loss builds Recurrence(g; ...) from a constant g captured by a Const closure.
  • Without coverage the constructor inlines into the loss and Enzyme sees through it.
  • The AD job runs with --code-coverage=@., and the coverage counters stop the compiler inlining the constructor body. The operator then comes back from a call through sret, and Enzyme's static activity analysis refuses the constant kernel stored in it.
  • This is not an Enzyme bug, and it does not depend on the Julia version:
Julia Coverage Code Result
1.13.4 none main all 4 reproducer cases pass
1.13.4 @. main all 4 error, plain Recurrence(g) with no coupling included
1.12.7 @. main all 4 error
1.13.4 @. this PR all 4 pass; all 18 checks in test/ad/static_activity.jl pass

All runs use Enzyme 0.13.221, the version CI resolved.

Fix

@inline on Recurrence(kernel; coupling, modifiers, lags, width), with a comment on why.
Nothing else changes. Without coverage the constructor was already inlined.

Evidence

The local runs in the table, which use the reproducer of the failing cases and TestItemRunner filtered to test/ad/static_activity.jl.
The Enzyme reverse job on this PR runs the item under coverage.

This was opened by a bot. Please ping @seabbs for any questions.

Under code coverage the compiler stopped inlining it, so a loss that built
a recurrence from its constant data got the operator back from a call.
Enzyme's static activity analysis rejects the constant kernel stored in
that returned operator, which failed the six static activity items on
the Enzyme reverse job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@seabbs-bot
seabbs-bot requested a review from seabbs as a code owner December 5, 2026 07:45
@seabbs
seabbs merged commit fb1f0c7 into main Dec 5, 2026
18 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants