Repository navigation
Conversation
Forward mode builds on `Piste.Dual` (pushforward, plus Piste's chunked driver for `gradient`); reverse mode builds on Piste's tape (pullback and gradient via `rev_value_and_pullback`). Constant and Cache contexts are supported in both modes. Second order is not. Prepared first-order operators compile under `juliac --trim=safe`, except forward-mode `jacobian` (BatchSizeSettings is type-unstable, see issue). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
This branch has not been deployed
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.
Add Piste.jl as a backend, in forward and reverse mode, following @gdalle's "PR welcome" on Slack.
Piste is small and written so that its derivatives compile under
juliac --trim=safe. That still holds through DI. I compiled small apps that call DI withAutoPisteusing JuliaC (Julia 1.12.7,--trim=safe). Every one built with zero verifier errors, ran with codegen disabled (JULIA_LOAD_CODEGEN_LIB=0), and printed the same output as the JIT:gradientchunksize)derivative,pushforwardpullback,jacobiangradientwithConstant/CachecontextsjacobianThe binary for a prepared DI
gradientis 2.5 MB, against 2.4 MB for the same program calling Piste directly. One app exercising all the ✅ operators above comes to 2.8 MB.The one ❌ is not specific to Piste.
BatchSizeSettings(B::Int, N::Int)computes itssinglebatch/alignedtype parameters from the runtimeN, so any forward backend's jacobian prep has an unknown type under--trim. I've opened #1088 with a proposed fix and kept it out of this PR.Usage
AutoPisteitself is added in SciML/ADTypes.jl#191.What the extension implements
Piste.Dual{B,T}, untagged): one- and two-argumentpushforwardwith batches of tangents.gradientforVector{<:AbstractFloat}inputs goes straight to Piste's chunked driver with a reusableGradientWorkspace. Other inputs fall back to DI's batched pushforwards.pick_batchsizeandthreshold_batchsizemirror the ForwardDiff extension. Withchunksize = nothingthe width is picked fromlength(x)at prep time, which works fine in the JIT, but trimmed code should pass a fixedchunksize.Piste.TapedRealon a tape): one- and two-argumentpullback, recording once per cotangent.gradientis a single pullback reusing aReverseWorkspace. Two-argument functions are recorded through a tracked copy ofy, initialized to constant zeros. This relies on a new publicrev_value_and_pullback(!)in Piste 0.4.ConstantandCachein both modes. Caches are rebuilt with the active number type throughrecursive_similar.inplace_supportisInPlaceSupported().Not supported: second order. Piste's Duals are untagged, and nesting
DualoverTapedRealisn't implemented, soSECOND_ORDERscenarios are excluded from the tests. The docs table shows ❌ for those operators. DI's own fallbacks still work for first-order operators the extension doesn't define, such as forward jacobian and reverse derivative.Tests
test/Back/Pisterunsdefault_scenarios(including the constantified, cachified, constant-or-cachified, tuple and smaller variants) andsparse_scenariosonAutoPiste(),AutoPiste(; chunksize = 2)andAutoPiste(; mode = ReverseMode()), plustest_counterparts. Locally (Julia 1.12.7), 76,419 tests pass and none fail or error. I've added thePistegroup to the CI matrix.Running the suite turned up one Piste bug:
eltype(::Type{Dual})returned the float type, which broke broadcasting with a scalar dual. It's fixed in Piste 0.4.Order of merging
eltypefix). Registration is pending.Piste = "0.4",ADTypes = "1.25.0") assume both releases, so CI for the Piste group will fail until then. Happy to leave this as a draft until they land, and to adjust the ADTypes bound if the release gets a different number.The docs (backends table, a short "Piste" section), the README list and the CHANGELOG are updated.
🤖 Generated with Claude Code