Skip to content

Update adapt cost microbenchmark for current APIs - #476

Open
ss2098 wants to merge 1 commit into
underworldcode:developmentfrom
ss2098:ss2098/update-adapt-cost-microbench
Open

Update adapt cost microbenchmark for current APIs#476
ss2098 wants to merge 1 commit into
underworldcode:developmentfrom
ss2098:ss2098/update-adapt-cost-microbench

Conversation

@ss2098

@ss2098 ss2098 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This PR updates scripts/adapt_cost_microbench.py so the microbenchmark runs with the current Underworld3 APIs.

Changes include:

  • convert AdvDiffusionSLCN estimate_dt() output to a scalar before passing it to solve()
  • replace internal mesh._deform_mesh() calls with the public mesh.deform() API
  • replace the retired smooth_mesh_interior(..., method="anisotropic") path with uw.meshing.node_redistribution()
  • add fail-fast SNES convergence checks so the benchmark does not continue after a failed solve
  • simplify the Stokes boundary condition so the microbenchmark runs stably as a cost diagnostic

This does not change solver internals.

Validation:

  • pixi run python scripts/adapt_cost_microbench.py

Example local output:

  • plain (adv+stokes) step: 1.217 s
  • one pristine adaptation total: 3.586 s
  • adaptation / step ratio: 2.9x

@ss2098
ss2098 requested a review from lmoresi as a code owner July 29, 2026 08:11

@lmoresi lmoresi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adversarial review

The API modernizations are correct (we live-probed node_redistribution, metric_density_from_gradient(amp=, name=), Mesh.deform, .snes — all present), but two substitutions change what the benchmark measures:

  1. MAJOR — the upper boundary changed from penalty free-slip to no-slip (add_essential_bc((0,0))). That silently changes the convection physics while the docstring still claims "same setup as the saturation runner", so the numbers are no longer comparable to the recorded baselines this script exists to track. add_natural_bc still exists; the sanctioned modernization is add_rotated_freeslip_bc(0, "Upper").
  2. MAJOR — the timed Stokes solves flipped zero_init_guess=False → True: the benchmark now times cold-start solves, inflating t_step and deflating the adaptation/step cost ratio.
  3. MINOR — _deform_mesh → deform: deform() runs remesh_with_field_transfer itself before the script overwrites T, so the remap timings now double-count transfer work.

Requested changes: restore free-slip via add_rotated_freeslip_bc(0, "Upper"), restore zero_init_guess=False in the timed loops (or explicitly re-baseline and relabel), and note the deform double-transfer in the timing comment. With those, this is mergeable — the rest of the update checked out clean.

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.

2 participants