Repository navigation
Add EnzymeCore extension declaring the searches inactive - #116
Merged
Merged
Conversation
Member
|
Get rid of your noise. |
Every FindFirstFunctions entry point returns or fills indices and sees its arguments only through comparisons, so no derivative flows through it. The new `FindFirstFunctionsEnzymeCoreExt` (weak dependency on EnzymeCore) declares `searchsorted_last`, `searchsorted_first`, the batched `searchsortedlast!`/`searchsortedfirst!`/`searchsortedrange` and the equality searches `findequal`/`findfirstequal`/`findfirstsortedequal` as `EnzymeRules.inactive`. This is exact. It also avoids a hard abort: the early-exit search loops emit `gc_preserve_begin`/`gc_preserve_end` token pairs that Enzyme's reverse pass cannot reorder yet (EnzymeAD/Enzyme.jl#3404, "Instruction does not dominate all uses!"), so any reverse-mode differentiation through an interpolation interval lookup, e.g. DataInterpolations inside an ODE right-hand side under `EnzymeVJP`, killed the process. With the rule Enzyme never enters the loop. Adds an `Enzyme` test group (piecewise-linear interpolant: reverse-mode gradients w.r.t. knot values and query point, forward mode, batched and equality searches under autodiff) and bumps the version to 3.3.0. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
SebastianM-C
force-pushed
the
smc/enzymecore-ext
branch
from
September 16, 2026 22:25
8eb1527 to
272b476
Compare
Member
Author
|
trimmed the comments to trigger a rebuild huh... the docs error is quite odd that link works for me, it looks like a transient network issue, should I keep retrying? |
SebastianM-C
marked this pull request as ready for review
September 16, 2026 22:36
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 22, 2026
Ships two new package extensions declaring the searches inactive for AD: EnzymeCore (#116) and Mooncake (#117). Minor because both add weak dependencies and new extension behaviour. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 22, 2026
Ships two new package extensions declaring the searches inactive for AD: EnzymeCore (#116) and Mooncake (#117). Minor because both add weak dependencies and new extension behaviour. Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL) Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
FindFirstFunctionsEnzymeCoreExt, a weak-dependency extension onEnzymeCorethat declares every search entry pointEnzymeRules.inactive:searchsorted_last,searchsorted_first, the batchedsearchsortedlast!/searchsortedfirst!/searchsortedrange, and the equality searchesfindequal/findfirstequal/findfirstsortedequal.Why
The searches return or fill indices and see their arguments only through comparisons, so no derivative flows through them in either direction: the declaration is exact, not an approximation.
It also fixes a hard abort. The early-exit search loops emit
gc_preserve_begin/gc_preserve_endtoken pairs that Enzyme's reverse pass cannot reorder yet (EnzymeAD/Enzyme.jl#3404 —LLVM ERROR: function failed verification, "Instruction does not dominate all uses!"). Today any reverse-mode differentiation through an interpolation interval lookup — e.g.DataInterpolations.LinearInterpolationdriving an ODE right-hand side under SciMLSensitivity'sEnzymeVJP— aborts the Julia process, even though the search itself carries no derivative. With the rule, Enzyme never enters the loop. Verified on Enzyme 0.13.184–0.13.204 with a package-free reproducer and on the real model that motivated it (the VJP then matches an uncompiled ReverseDiff tape to the same accuracy).The rule lives here rather than in DataInterpolations because DataInterpolations does not own these functions.
Changes
ext/FindFirstFunctionsEnzymeCoreExt.jl: theinactivedeclarations.Project.toml:EnzymeCoreweakdep + extension,EnzymeCore = "0.8"compat,Enzymeas a test extra.test/Enzyme/enzyme_tests.jl+[Enzyme]group intest/test_groups.toml: a piecewise-linear interpolant whose interval lookup goes throughsearchsorted_last, differentiated in reverse mode w.r.t. the knot values and the query point, in forward mode, plus the batched and equality searches under autodiff.NEWS.md, version 3.2.1 → 3.3.0.Draft while the new CI group runs; happy to trim the set of functions covered if you would rather keep the rule to the sorted searches.
Written by Claude Code on Sebastian's behalf.
🤖 Generated with Claude Code