Skip to content

merge(zarr3): expose fast-merge config levers + TPS warp + optimal-site seeding#228

Merged
mat10d merged 5 commits into
zarr3from
merge-fast-path-levers-zarr3
Jul 10, 2026
Merged

merge(zarr3): expose fast-merge config levers + TPS warp + optimal-site seeding#228
mat10d merged 5 commits into
zarr3from
merge-fast-path-levers-zarr3

Conversation

@mat10d

@mat10d mat10d commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

What

Ports the fast-merge levers onto the zarr3 line (companion to #227 which lands the same change on main). Same 3 backward-compatible commits, adapted to zarr3's merge code + house style:

  1. feat(merge): expose hardcoded fast-merge levers as backward-compatible config params
  2. feat(merge): thin-plate-spline warp + find-optimal-site seeding (gated)
  3. style(merge): single-line comments, lib high->low order, ruff format

All levers default to unset ⇒ config.get(...)None → lib literal ⇒ existing zarr3 screens byte-identical.

Scope

5 merge-path files only: workflow/lib/merge/{fast_merge,hash}.py, workflow/scripts/merge/{fast_alignment,fast_merge}.py, workflow/rules/merge.smk. No test files.

zarr3-specific notes

  • Conflict resolution matched zarr3's conventions: kept the defensive config.get("merge", {}).get(...) param style used throughout zarr3's merge.smk (main uses config["merge"].get(...)), and preserved zarr3's optional det_range/score/threshold semantics.
  • Also removed a latent leftover threshold_region = 50 in evaluate_match that was shadowing the (now parameterized) threshold_region argument.

ruff format --check + ruff check clean; merge modules compile.

🤖 Generated with Claude Code

mat10d and others added 5 commits July 10, 2026 09:25
…e config params

Parameterize the formerly-hardcoded fast-merge knobs so they can be tuned per screen:
- evaluate_match: threshold_triangle, threshold_point, threshold_region, ransac_kwargs
- initial_alignment / multistep_alignment: evaluate_kwargs (+ batch_size)
- refine_local_warp: degree, iterations, min_correspondences via warp_kwargs,
  threaded through merge_triangle_hash / merge_sbs_phenotype
Wired through scripts/merge/{fast_alignment,fast_merge}.py and rules/merge.smk
(all config.get default None -> lib literal). Defaults unchanged => existing
screens byte-identical.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAWdQnZAy3WU6bdxy41EgP
Adds two validated two-scope merge levers, both backward-compatible (defaults
off -> byte-identical to the affine path already on this branch):

- TPS warp: `local_refinement` now doubles as the warp-model selector
  ("polynomial" | "thin_plate_spline"); wire `warp_smoothing` /
  `warp_max_correspondences` through scripts/merge/fast_merge.py + merge.smk.
  On two-scope OPS merges TPS roughly halves the median residual vs polynomial
  while staying stable. String selector is byte-identical to an explicit
  warp_kwargs["model"]; a bare truthy keeps the polynomial default.

- find-optimal-site (`seed_optimize`, `seed_topk`): the stage-nearest phenotype
  tile is not always the best real overlap when the two scopes have a
  metadata-alignment residual. When on, evaluate the top-K nearest tiles per SBS
  seed and keep the highest-scoring one per site. Default off = nearest-tile,
  unchanged.

Verified: default (local_refinement=None, seed_optimize=False) path untouched;
polynomial selector == explicit model kwarg; TPS routes end-to-end and both
warps recover matches an affine drops on distorted data.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAWdQnZAy3WU6bdxy41EgP
Cleanup of the merge fast-path (no behavioral change; smoke test identical):
- Collapse multiline block comments to single lines across fast_merge.py and
  fast_alignment.py.
- Reorder lib/merge/fast_merge.py high-level -> low-level: merge_triangle_hash,
  merge_sbs_phenotype, then helpers build_linear_model, refine_local_warp.
- Trim refine_local_warp docstring to the file's density; ruff format + check clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAWdQnZAy3WU6bdxy41EgP
…nobs

Per review of the merge autoresearch results, keep as config-exposed only the
levers with measured impact (threshold_triangle, ransac_random_state,
local_refinement, warp_degree/iterations/smoothing, seed_optimize/seed_topk).
Revert the inert knobs to hardcoded literals in the lib (threshold_point=2,
threshold_region=50, batch_size=180, warp min/max_correspondences=30/700).
Defaults unchanged => byte-identical. TPS + find-optimal-site kept (validated
on Vaishnavi: median 0.08px).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
plot_merge_example / fast_merge_example gain local_refinement + warp_kwargs and
apply refine_local_warp to the affine prediction, so the notebook match preview
reflects the levers an operator sets. Notebook-only helper; defaults None => unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mat10d mat10d merged commit 92fe01e into zarr3 Jul 10, 2026
1 check passed
@mat10d mat10d deleted the merge-fast-path-levers-zarr3 branch July 10, 2026 15:21
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.

1 participant