Commit 821fb1b
committed
feat: unlock jax.grad through the Delaunay mesh via frozen integer tables
Wraps the qhull pure_callback input in stop_gradient in _jax_delaunay_tables.
pure_callback has no JVP rule and previously raised under jax.grad; with the
visibility walk running point location, barycentric weights, dual areas and
split points in-graph from the traced arrays, the callback returns only int32
connectivity tables, which are piecewise-constant in the vertex positions —
their true derivative is zero everywhere except the measure-zero triangle-
flip events, where the likelihood itself is discontinuous and no gradient
exists for any method. Freezing them under differentiation therefore yields
the exact almost-everywhere derivative, not an approximation.
Values are bit-identical (the primal is untouched): the jax_likelihood
delaunay regression literal passes unchanged. FD-certified on the production
shape (Hilbert + edge zeroing + AdaptSplit) by the new
autolens_workspace_test scripts/imaging/jax_grad/delaunay.py — 14/14 params
live, lens light at 1e-8..1e-10, mass/shear at 1e-5..2e-3 (FD steps
straddling flip events; documented rtol=1e-2). Mesh docstrings updated:
Delaunay is now gradient-capable; the KNN meshes' remaining edge is batched
throughput (the tables callback is vmap_method=sequential, one host qhull
call per vmap lane).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FSqnkgZv97PU9JdkCcthy1 parent 2897ded commit 821fb1b
3 files changed
Lines changed: 37 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
122 | 137 | | |
123 | 138 | | |
124 | 139 | | |
| |||
130 | 145 | | |
131 | 146 | | |
132 | 147 | | |
133 | | - | |
| 148 | + | |
134 | 149 | | |
135 | 150 | | |
136 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
0 commit comments