State of `Differentiation` in Swift 6.4 updates

Hello everyone!
Swift 6.4 released last week so it's time for another differentiable Swift update wrt the compiler!
(See our previous update back in February here)

What's new:

  • Differentiation of throwing functions is finally supported on all platforms. Previously the work for throwing functions got cherry picked onto 6.3 release branches but wasn't picked up for Darwin platforms unfortunately.
  • Work continues on autodiff-aware closure specialization. This will result in better optimized derivatives and pullbacks, no source code changes will be required, just a compiler update!
  • Fixed multiple compiler crashes
  • Many more other small improvements

Going forward

We're continuing to focus on improving performance and usability. We'll share additional updates about the swift-differentiation library, and the ongoing work we've been landing on main, targeting Swift 6.5.
From here we're hoping to do a few shorter but more frequent updates, so stay tuned for more over the next few weeks!

Thanks

Thanks to all the people who help us move forward! Be it in contributions, bug reports, code reviews, testing or any other way!

Special thanks goes out to:

Extra

For the curious ones, here is the list of important PRs in 6.4 timeframe:

Features:

  • Landed initial support for differentiating throwing functions, wrapping pullbacks in Optional and emitting the control flow needed to differentiate active try_apply results. This was already working on Linux, but the original 6.3 cherry-pick missed the Darwin releases - #82653 and #86393
  • Extended closure specialization to branch tracing enums, replacing opaque closures stored in enum payloads with their captured values so more multi-block pullbacks can be specialized into direct calls - #85757
  • Required new AST and SIL bridging for derivative functions - #84648, and for optional and enum case construction - #85756
  • Closes the long-standing request for a linear-map-aware closure optimization - #68944

Improvements/fixes:

  • Fixed a crash when differentiating generic code whose Differentiable conformance comes from a protocol's conditional conformance - #77446
  • Taught the SIL combiner to fold differentiable_function_extract inside borrowed scopes, unblocking VJP inlining under OSSA - #87826
  • Allowed implicitly generated VJPs/JVPs to be force-inlined when the original function is marked always-inline - #87859
  • Cleaned up conformance-related SIL warnings introduced by the AutoDiff closure specialization work - #86183
  • Fixed a miscompile where the closure specialization pass reused a specialized function across call sites with different non-reabstraction thunks - #91284
7 Likes