Repository navigation
Differentiate a ModelSpec with an intervention under plain Enzyme.Reverse - #1255
Merged
Merged
Conversation
… runtime activity Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Contributor
Benchmark comparison vs baseMinimum time per call. Buckets are PR time as a % of base, so lower is faster (🟢 faster, ⚪ within 5%, 🔴 slower). Counts of benchmarks per bucket:
Evaluation — 19 benchmarks (by time change)
AD gradients — 0 benchmarks (by time change)none |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1255 +/- ##
=======================================
Coverage 97.81% 97.81%
=======================================
Files 104 104
Lines 11806 11806
=======================================
Hits 11548 11548
Misses 258 258
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Collaborator
Author
|
The changelog check failed because the pull request had no fragment. I added |
sbfnk-bot
marked this pull request as ready for review
November 25, 2026 13:34
sbfnk
approved these changes
Nov 25, 2026
sbfnk
deleted the
issue-1196-enzyme-with-a-modelspec-that-has-an-inte
branch
November 25, 2026 13:51
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.
Building a
ModelSpecinside a differentiated function, with anIsolationorattributes = clinical_presentation(...)captured from outside, failed under plainEnzyme.ReversewithEnzymeRuntimeActivityError. The constant result of_resolved_key, the state key stored inInfectiousness, was written into a struct that also holds the active offspring law. Marking_resolved_keyas:foldablefolds the call away for a constant name, so the store is no longer seen as constant memory in a differentiable struct.In
test/test_ad.jl, the construction case and thechain_length_distributioncase now run onenzyme_bare(plainEnzyme.Reversefrom Julia 1.11, as for the other closed-form cases) instead ofenzyme_activity. Both failed withEnzymeRuntimeActivityErrorbefore the change. In a scratch script, those two cases, a capture-onlyattributesspec and a capture-onlyIsolationspec all gave gradient[1.0]. I did not run the fulltest_ad.jlor Julia 1.10. A name known only at runtime does not fold, so that case is untested.Left for later:
EnzymeNoTypeError for two RingVaccination doses with requires_dose: Differentiating
loglikelihood(ChainSizes(...), ModelSpec(BranchingProcess(Poisson(R[1])); interventions = [...]))inRwith plain Enzyme reverse fails withEnzymeNoTypeErrorinside the differentiated function when the spec has twoRingVaccinationdoses and the second setsrequires_doseto a label. It fails the same way with a literal:primelabel and withset_runtime_activity, and marking_validate_dose_scheduleinactive does not remove it, so it is not a runtime-activity problem and needs its own diagnosis.This PR closes #1196.