Changelog¶
0.4.0 — 2026-11-21¶
The library of the VertAX paper: the Hessian-weighted cost, bounded T1 tension reset and aspect-ratio costs enter, the image costs leave, and the line-search and L-BFGS fixes are included. A minor rather than a patch release: removing the image costs removes public functions, and the fixes change bounded and line-search results.
Python 3.11 or 3.12 only (requires-python = ">=3.11,<3.13"): JAX and jaxlib 0.4.34, NumPy 1.26.4 and
Matplotlib 3.8.0, which this version pins, have no wheels for later Pythons.
Development of this release was supported by Anthropic's AI for Science program; parts of the code were written with Claude and reviewed by the developers.
One library for the paper, its figure code and the documentation: the features that the VertAX paper's figure code uses and that only its branch had are merged in, the image costs leave the library, and the Hessian-weighted cost of the paper enters it. Without the new options, results are those of 0.3.0 with the fixes below.
Added: the Hessian-weighted cost \(\mathcal C_W\) and the staged schedule¶
hessian_at_target(target, energy, edges_params=None): the Hessian of the inner energy at the target geometry, every edge parameter set to one by default, symmetrized and divided by its spectral norm.make_cost_hessian_weighted(target, energy, edges_params=None): \(\mathcal C_W=\tfrac12\lVert\widehat{\mathbf H}(\mathbf X-\mathbf X_{\text{target}})\rVert^2\) in the periodic outer-cost signature, with displacements to the nearest periodic image as incost_v2v.switch_cost_at_target_topology(optimizer, mesh, cost): called after every epoch, it disables T1 transitions and sets the outer cost at the first epoch where the mesh has the target topology, the second stage of the staged schedule (\(\mathcal C_{\text{v2v}}\), then \(\mathcal C_W\)).- New test:
tests/test_cost_hessian_weighted.py, against the values of the code that defined \(\mathcal C_W\) for Figure 3 of the paper, on two mesh pairs of the synthetic benchmark.
Added: from the paper's branch¶
T1TensionReset(bounded meshes, off by default): the edge created by a T1 transition starts at the mean tension of the other edges of its kind instead of inheriting the tension of the edge it replaces.BoundedBilevelOptimizer.t1_tension_resetandlast_t1_resets; with the option,update_T1_boundedreturns the post-reset parameters and the transitions per edge, and the bounded outer functions return aT1ResetReportas an eighth value. New test:tests/test_t1_tension_reset_bounded.py.reopen_margin, a keyword ofupdate_T1_bounded: length of the reopened edge,(1 + reopen_margin) * min_dist_T1, as for the periodicupdate_T1; default unchanged (min_dist_T1 + 1e-3). New test:tests/test_bounded_t1_reopen_margin.py.get_cluster_moments_bounded(area, centroid and central second moments of a bounded cluster, arc caps included),aspect_ratio_along_x,aspect_ratio_principal, and the outer costsmake_cost_aspect_ratio_along_xandmake_cost_aspect_ratio. New test:tests/test_cluster_aspect_ratio.py;tests/test_bounded_crescent_cell.pyalso checks the cluster moments of a crescent cell.
Removed: the image costs¶
cost_dmic,make_cost_dmic,render_interface_image,cost_mesh2image,make_cost_mesh2image,erode_mask_for_psfand the constantLEGACY_PSF_SIGMA, with their tests, their README section and their website pages. They are kept on the branchimage-cost.- The outer-cost protocol keeps its last argument,
image_target, which no library cost now uses.
Fixed since 0.3.0¶
PbcMesh.from_image,mask_analysis.mask_from_imageandmask_analysis.segmenttakegpu: bool | None = None, the device of Cellpose:Noneuses a CUDA GPU when one is available and the CPU otherwise (never Apple's GPU, on which Cellpose fails),TrueandFalseforce it.segmentused to force the GPU.- The line search scores the vertex steps capped and the bounded arc angles clipped, as the update leaves them.
- L-BFGS: the stored positions follow the vertices that
update_pbcwraps across the periodic box. - Bounded meshes: opt-in reset of the solver state after a T1 transition (
reset_solver_on_t1);update_T1_boundedskips the triangular-twin-face emergency when the twin half-edge is an arc. - The bounded inverse regression runs on a clipped-SGD outer step; reference regenerated on Linux.
0.3.0 — 2026-10-28¶
Four fixes, docstring corrections and test tolerances for references made on another machine. A minor rather than a patch release: the bounded-angles fix changes bounded bilevel results and the return value of the four bounded outer functions.
Fixed: a bounded outer step leaves the arc angles of the estimator's equilibrium on the mesh¶
- The automatic-differentiation, equilibrium-propagation and implicit-differentiation estimators of
BoundedBilevelOptimizerreplacemesh.vertices,mesh.edgesandmesh.facesby the equilibrium of their inner solve (the free one, for EP), but kept the oldmesh.angles: the mesh was left with the vertices of one state and the arc angles of another, and the relaxation thatbilevel_optimizationanddo_n_bilevel_optimizationrun next started from that mixed state. The functionalopt_bounded.bilevel_opt_boundeddid the same. The angles now go with the other tables. - API:
outer_opt_bounded,outer_eq_prop_bounded,outer_implicit_boundedandouter_adjoint_state_boundedreturn(vertices, angles, edges, faces, vertex, edge and face parameters), seven arrays instead of six. The adjoint-state estimator returns the state it was given, unchanged, as before. - New test:
tests/test_bounded_outer_step_angles.py.
Bounded bilevel results change for the AD, EP and ID estimators whenever a relaxation follows an outer
step on the same mesh (bilevel_optimization, do_n_bilevel_optimization, bilevel_opt_bounded).
The parameter update of an outer step is unchanged, and so is a run that restores the mesh state after
outer_optimization and relaxes from it. The bounded inverse regression reference
(tests/reference_result_test_inverse_modeling_bounded.npz) is regenerated: final energy 51.766 (was
51.643), outer cost 0.5616 (was 0.5760). Periodic meshes are not affected.
Fixed: BoundedBilevelOptimizer honours params_regularizer and ep_variant, and refuses persist_outer_state¶
- The bounded optimizer passed neither
params_regularizernorep_variantto its estimators: a bounded run ignored the regularizer, whose docstring says it is honoured by all estimator paths, and its EP estimate was always centered. Both are now passed to the four bounded estimators, as in the periodic ones;EPVariant.ONE_SIDEDsolves the free problem atbeta = 0and divides bybeta. persist_outer_state=True, which the bounded EP path ignored, now raisesValueErrorat the first outer step: onlyPbcBilevelOptimizerthreads the outer optimizer state across epochs.- New test:
tests/test_bounded_bilevel_options.py.
This fix alone leaves results with the defaults (no regularizer, CENTERED, persist_outer_state=False)
unchanged, bit for bit.
Fixed: cost_areas can be used as an outer cost¶
cost_areascalledgeo.get_areawithout its face-walk bound and raisedTypeErrorat its first call. Its arguments were also not in the 12-argument order in which the optimizers call an outer cost; they now are (targets before selections),widthandheightare static as incost_v2v, andselected_faces=Nonemeans every face.- New test:
tests/test_cost_areas.py.
Fixed: minimize with a line-search solver and a target other than the vertices¶
- The
paramsandvalue_fnthatminimizehands tosolver.updatewere chosen by branches numbered 0, 2, 3, 4, 5, 6 whileOptimizationTargetis numbered 0 to 5. For every target other thanVERTICESa line-search solver (gd_linesearch,cg_linesearch,optax.lbfgs()) received another array and re-evaluated the energy along it; with the usual table shapes the call raisedTypeError. Fixed-step solvers do not usevalue_fnand were not affected. - New test:
tests/test_minimize_value_fn_targets.py.
Results are unchanged for OptimizationTarget.VERTICES, the only target VertAX itself uses (the branch
is unchanged).
Documentation¶
Docstrings that said something the code does not do, corrected without a change of behaviour:
BoundedMesh.faces is (nb_faces, 2), a half-edge of the face and the cell's fate;
make_energy_line_tensions returns a 7-argument function that has to be wrapped as an inner loss;
BilevelOptimizationMethod.AUTOMATIC_DIFFERENTIATION is reverse mode (jax.grad), not forward mode;
trace_mask_closed does not raise, and its record is in mesh.diagnostics; no VertAX function writes
the file that clamped.load_mesh reads; save_mesh_txt and load_mesh_txt also write and read the
parameter tables and the constants. minimize now says to build the solver once and reuse it: the
relaxation loop is compiled for each solver object, so a new solver at every call recompiles and keeps
every compiled copy.
Tests¶
Four tests compared floating-point results bit for bit with references made on a Mac and failed on
Linux x86-64, off in the last bits (test_default_float_dtype, test_trace, and two in test_clamped).
They now compare within a tolerance derived from the computation (float32 ulps of the array's scale,
or the rounding bound of a reordered sum), and integer and exact lattice quantities stay exact. Set
VERTAX_EXACT_REFERENCES=1 on the machine that produced the references to compare them bit for bit
(new fixture exact_references in tests/conftest.py). Three of these tests are renamed, without
exactly or bit_identical in their names.
0.2.1 — 2026-10-22¶
Bug-fix release, with two fixes.
Fixed: mesh constructors follow JAX's default float dtype¶
PbcMesh(from_seeds,from_random_seeds,from_mask,from_image) andBoundedMesh(from_seeds,from_random_seeds) built theirvertices(and, forBoundedMesh, theirangles) asfloat32whateverjax_enable_x64was set to, so a user who enabled x64 still relaxed afloat32mesh. Both now use JAX's default float dtype:float32by default,float64underjax_enable_x64. Integer index tables are unchanged.- Docstrings and notes that told users to cast
PbcMesh.verticestofloat64after construction (rheology,clamped,require_float64's error message) are updated. - New regression tests:
tests/test_default_float_dtype.py, with reference arrays from 0.2.0.
Results without jax_enable_x64 are unchanged; users who enabled x64 without casting the mesh now get
float64, as intended. The mesh constructors and one relaxation of each mode are bit-identical to 0.2.0
without x64 (checked by the new tests).
Fixed: area of a bounded cell whose chord polygon has turned over¶
get_area_bounded(and with itBoundedMesh.get_area, the bounded energy and the energy check of the bounded T1 update) returned0.5 (|polygon| + caps)for a cell, where polygon is the signed area of the polygon through the cell's vertices and caps the area between each free-interface chord and its arc.BoundedMeshbuilds every face counterclockwise and T1 transitions keep it, so the sign of the polygon is not the cell's orientation: it turns over when a free-interface cell's interior vertices cross the chord of its arc while the arc keeps the cell open (a crescent). Such a cell was given cap + |polygon| instead of cap − |polygon|, and a folded cell was hidden. The area is now the signed polygon plus the caps: a crescent has area cap − |polygon|, and a folded cell has a non-positive area.- Because the area now relies on the counterclockwise convention,
BoundedMesh.from_seeds,load_meshandload_mesh_txtcheck it. A mesh whose faces are clockwise raisesValueError(it would be read inside out, with negative areas and no error); a mesh with a face whose chord polygon has turned over, a crescent or a fold, emits aUserWarning. A mesh built and saved by VertAX is never refused. - New tests:
tests/test_bounded_crescent_cell.py(closed-form area and energy gradient of a crescent, on the configuration and its mirror image) andtests/test_bounded_mesh_orientation_guard.py.tests/test_area_bounded_groundtruth.pynow asserts the signed area, on a stored mesh with a folded cell.
Results are unchanged, bit for bit, for any bounded mesh without a turned-over cell (checked on the two
stored bounded regression meshes: the other 19 cell areas are identical). The two bounded regression
references (tests/reference_result_test_{forward,inverse}_modeling_bounded.npz) held a folded cell that
the unsigned area could not resist, and are regenerated: that relaxation no longer folds the cell.
0.2.0 — changes since the merge base ed504f2¶
Solver and T1 options (defaults unchanged)¶
- Nonlinear CG: integer state keeps its dtype under
jax_enable_x64(fix);linesearch_initial_guess="one"(opt-in; default"keep") starts every line search from a unit step. update_T1(..., reopen_margin=0.1): length of the reopened edge as a keyword (default unchanged,1.1 * min_dist_T1).- Bounded mode: the arc half-angle limit is applied after every relaxation step, also with T1 transitions disabled (fix).
minimize(..., reset_solver_on_t1=True): opt-in reset of the solver state after a T1 transition (defaultFalse);optax.lbfgs()now runs underjax_enable_x64(fix).minimize(..., count_t1=True): opt-in T1 counts in the loop state, exact underjit,vmapandgrad(defaultFalse);recording_t1_statistics()collects them from the bilevel estimators.
Vertex step cap and T1 counts¶
cap_vertex_steponPbcBilevelOptimizerandBoundedBilevelOptimizer(defaultNone= automatic): the per-step vertex displacement is capped at5 * min_dist_T1for line-search inner solvers (gd_linesearch,cg_linesearch,optax.lbfgs(), recognised by the line-search state they carry) and left uncapped for fixed-step ones (optax.sgd,optax.adam, whose results are unchanged). An explicitTrueorFalsealways wins. The choice reaches every relaxation the optimizer runs, including the inner solves of the automatic-differentiation, equilibrium-propagation, implicit-differentiation and adjoint-state hypergradients. Behaviour change for line-search users: an uncapped line-search step can move a vertex across whole cells and turn a cell inside out, whichget_areaandget_area_bounded(absolute values) do not penalise; setcap_vertex_step = Falseto keep the old behaviour. Original work by Michael Corbeau.- Fix:
recording_t1_statistics()now also records the two solves of the equilibrium-propagation hypergradient (they were dropped). - Note: the "kept" count of
minimize(..., count_t1=True)is exact only when the flips of one iteration share no cell; under the forced T1 rule neighbouring flips can make it differ from the flips performed, and presented minus kept is then unreliable.
New modules¶
vertax.trace: traces a segmentation label mask, including a raw crop, into a straight-edge vertex mesh, with a free/clamped vertex partition and mask regularisation.vertax.clamped: force balance on a cropped tissue patch with clamped rim vertices, using signed areas;relax,newton_polish, residual and gradient-splitting utilities.vertax.rheologyandvertax.bilevelopt.rheobop: bulk-driven shear rheometry on periodic tissues (cosine drive mode, compliance, modulus) andShearRheologyOptimizerfor inverse design against a target modulus.
Image-based cost¶
cost_dmicrewritten to the published interface-density model;make_cost_dmic.render_interface_image: optional intensity normalisation, pixel-footprint averaging (exact pixel average), and the PSF width as a call-time parameter.
Energies and gradient estimators¶
make_energy_line_tensions(K_areas)andmake_energy_line_tensions_bounded(K_areas, ...)replace the former fixed-stiffness energies;K_areasis always explicit.- New shape-factor energy with area stiffness.
- Centered equilibrium propagation corrected (free phase at
-beta); the2x betaconvention is gone from docstrings. - Mean-tension normalization constraint (post-step projection) generalised to
any parameter array via
params_normalization;mean_tension_gaugeremains as an alias.params_regularizeris honoured on every estimator path.
Costs¶
cost_v2vfixed to the published formula;d_iasrenamedd_topo; the former IAS cost family and the dead topology costs are removed.
Fixes¶
get_area_boundedadds the arc caps on clockwise faces.- Periodic T1 swap repair refused on bounded meshes.
load_mesh_txtno longer truncates parameter arrays to integers.PbcMeshraises instead of hanging in periodic face ordering.plot_meshdoes not display or close the figure by default and returns(fig, ax).from_maskandfrom_imageare marked unsupported for real masks.
Tests, environment and documentation¶
- Test suite runnable, order-independent and green; periodic regression test in
two tiers; long-running tests carry the
longmarker and are deselected by default (pytest -m long);pytest-timeoutadded to the dev group. - Pinned environment (
uv.lock,requirements.txt, Python 3.12). - API documentation regenerated with pdoc 16; tension inference guide updated for the mean-tension normalization constraint; README section on the new modules.