Skip to content

feat: sketch for a Julia template and MWE#552

Draft
jpbrodrick89 wants to merge 3 commits into
mainfrom
jpb/julia
Draft

feat: sketch for a Julia template and MWE#552
jpbrodrick89 wants to merge 3 commits into
mainfrom
jpb/julia

Conversation

@jpbrodrick89

@jpbrodrick89 jpbrodrick89 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

@dionhaefner I know you're working on your own version of this and I definitely don't want to step on any toes, but I've been playing around with this a bit in the background and thought it better to have in the open to work out what direction we want to go in (both/and is potentially a possibility too). I'm not a Julia expert by any means and this probably needs some more cycles if we go with it, but this seems to work when packages support Enzyme (not all do). Happy to hear how you want play it.

I tried to give an example using a simple linear solver with verifiable gradients that could be useful in a Jax setting as no Jax packages expose modified Cholesky.

@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.87912% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.63%. Comparing base (ea2dbcc) to head (328a661).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...esseract_core/sdk/templates/julia/tesseract_api.py 11.68% 68 Missing ⚠️
tesseract_core/sdk/engine.py 60.00% 0 Missing and 2 partials ⚠️
...sseract_core/runtime/testing/finite_differences.py 75.00% 0 Missing and 1 partial ⚠️
...seract_core/sdk/templates/julia/julia/Project.toml 75.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (ea2dbcc) and HEAD (328a661). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (ea2dbcc) HEAD (328a661)
33 31
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #552      +/-   ##
==========================================
- Coverage   77.13%   69.63%   -7.50%     
==========================================
  Files          32       35       +3     
  Lines        4356     4499     +143     
  Branches      717      745      +28     
==========================================
- Hits         3360     3133     -227     
- Misses        712     1082     +370     
  Partials      284      284              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PasteurBot

PasteurBot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Benchmarks use a no-op Tesseract to measure pure framework overhead.

🚀 0 faster, ⚠️ 0 slower, ✅ 36 unchanged

✅ No significant performance changes detected.

Full results
Benchmark Baseline Current Change Status
api/apply_1,000 0.495ms 0.495ms +0.1%
api/apply_100,000 0.498ms 0.498ms +0.1%
api/apply_10,000,000 0.497ms 0.499ms +0.4%
cli/apply_1,000 1650.711ms 1657.890ms +0.4%
cli/apply_100,000 1653.257ms 1645.324ms -0.5%
cli/apply_10,000,000 1682.491ms 1684.052ms +0.1%
decoding/base64_1,000 0.029ms 0.029ms +0.3%
decoding/base64_100,000 0.970ms 0.970ms +0.0%
decoding/base64_10,000,000 106.318ms 106.556ms +0.2%
decoding/binref_1,000 0.178ms 0.177ms -0.5%
decoding/binref_100,000 0.227ms 0.233ms +2.9%
decoding/binref_10,000,000 8.648ms 8.562ms -1.0%
decoding/json_1,000 0.100ms 0.100ms +0.2%
decoding/json_100,000 9.490ms 9.601ms +1.2%
decoding/json_10,000,000 1119.859ms 1117.219ms -0.2%
encoding/base64_1,000 0.028ms 0.028ms +0.1%
encoding/base64_100,000 0.144ms 0.145ms +0.3%
encoding/base64_10,000,000 22.061ms 21.778ms -1.3%
encoding/binref_1,000 0.263ms 0.262ms -0.1%
encoding/binref_100,000 0.430ms 0.427ms -0.8%
encoding/binref_10,000,000 16.496ms 16.755ms +1.6%
encoding/json_1,000 0.144ms 0.144ms +0.4%
encoding/json_100,000 14.514ms 14.551ms +0.3%
encoding/json_10,000,000 1514.957ms 1512.533ms -0.2%
http/apply_1,000 2.912ms 3.099ms +6.4%
http/apply_100,000 8.007ms 8.276ms +3.4%
http/apply_10,000,000 663.527ms 666.111ms +0.4%
roundtrip/base64_1,000 0.059ms 0.059ms +0.7%
roundtrip/base64_100,000 1.126ms 1.123ms -0.2%
roundtrip/base64_10,000,000 128.577ms 129.030ms +0.4%
roundtrip/binref_1,000 0.454ms 0.453ms -0.2%
roundtrip/binref_100,000 0.667ms 0.664ms -0.5%
roundtrip/binref_10,000,000 25.671ms 25.378ms -1.1%
roundtrip/json_1,000 0.253ms 0.252ms -0.5%
roundtrip/json_100,000 21.975ms 21.197ms -3.5%
roundtrip/json_10,000,000 2630.813ms 2636.945ms +0.2%
  • Runner: Linux 6.17.0-1008-azure x86_64

@jpbrodrick89
jpbrodrick89 marked this pull request as draft April 2, 2026 15:54
@dionhaefner

Copy link
Copy Markdown
Contributor

Thanks @jpbrodrick89, this looks really comprehensive. I wonder what an appropriate path to getting this merged would look like. Maybe someone who knows Julia well can give this a spin and report back? Perhaps @llueg ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be a vectoradd-like example. This way we have a nice symmetry: vectoradd vanilla, vectoradd-jax, vectoradd-julia, ...

Alternatively univariate if we want to cover more edge cases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why those changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I import expand_path_pattern to separate diff and nondiff arguments, it recurses through a tree into optional arguments but the pattern always includes the the attribute name of the optional argument. If the optional argument is itself a container or a model then it will try to recurse further e.g. by calling None.sub (for TridiagBlock | None) and then error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like this should be an independent fix?

@jpbrodrick89

Copy link
Copy Markdown
Contributor Author

thanks @dionhaefner , @llueg would be great to collaborate, I have some changes locally I need to tidy up. Basically I think we aim to have three examples

  1. Fortran with Enzyme
  2. Julia with Enzyme
  3. Julia with SciMLSensitivities (locally I got this working for jvp as well as vjp)

we can reuse some boilerplate between 1 and 2 I think. I was going to deprioritise this for the next couple of weeks but if you're keen to dig into this as (re-)onboarding @llueg I'll tidy up this week.

@llueg

llueg commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

This sounds very cool! Happy to try this out - doesn't necessarily fit in my onboarding project but I can make time whenever you think it's ready for review/testing. I should add a disclaimer that I wouldn't consider myself a Julia expert 😄

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.

4 participants