Skip to content

Refactor pts 11-15, SWE-lake blending reinstatement, 3D Agnesi golden master#67

Open
ray-chew wants to merge 8 commits into
ext/refactor-orthogonalfrom
ext/refactor-pt11
Open

Refactor pts 11-15, SWE-lake blending reinstatement, 3D Agnesi golden master#67
ray-chew wants to merge 8 commits into
ext/refactor-orthogonalfrom
ext/refactor-pt11

Conversation

@ray-chew

@ray-chew ray-chew commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #66 (stacked; retargets to develop when that merges). Eight commits: five gated refactor pts, the SWE↔lake blending reinstatement, the pytest-9 CI fix (cherry-pick of the one on #66), and the true-3D Agnesi golden-master case.

Mechanical refactor pts (bit-identical at tol 0)

  • pt 11 — repo-root hygiene: stale SHA-migration scratch deleted; Phase-C GPU report + TFC plan moved under dev_notes/
  • pt 12 — dead commented _update_solution_variables variant dropped from compute_advection.py
  • pt 13 — repro gate: new blending case set; test_blending_hydrostatic added to full
  • pt 14device_kernels.py host loop split into device_loop.py behind the device_step shim; proven by pre/post-split device↔device bit-identity + 11/11 device equivalence/fullrun tests
  • pt 15 — blending orchestration flattened into named predicates; ModelState iterator unpack and dead debug threading removed

SWE↔lake blending reinstated

The path was provably dead since the ModelState refactor (undefined flux, pre-refactor time_update API, unbound conversion flag). Now:

  • swe_lake.py ported to the ModelState API in the 2D x-y layout; do_lake_to_swe_conv mirrors comp_psinc but rolls back the look-ahead clock (legacy scheduling; no master pins the advanced clock here)
  • legacy convert-back flag threaded as lake_to_swe_pending; latent duplicate-ud TypeError on the continuous-blending call fixed
  • new golden-master case test_blending_swe (balanced SWE vortex, initial swe→lake→swe blend), registered in IC_MODULES / test_blending.py / repro gate
  • blended vs unblended twin agrees to ~3e-4 rel-L2; detail in dev_notes/swe_blending_reinstatement.md

New terrain case

  • test_agnesi_3d: first true-3D (G2 ≠ 0) mountain-wave golden master — circular Agnesi bell, Gal-Chen, 64×32×64; z→−z mirror symmetry ~5e-9. Not CI-wired (~5 min/run).

Validation

  • Every existing golden master bit-identical at tol 0 throughout (fast, blending, device paths)
  • Full 12-case regression capture green; 3/3 blending pytest cases pass
  • CI green on the base branch with the pytest-9 fix

🤖 Generated with Claude Code

ray-chew added 8 commits July 2, 2026 09:54
- drop stale SHA-migration scratch (input/output.md, sha*.py, sha_map.txt)
- move PHASE_C_GPU_RESULTS.md + tfc_generalization_plan.md under dev_notes/
- update path references in STYLE_GUIDE.md (tracked) and local notes
- docs-only; no solver files touched
- delete the commented-out _update_solution_variables/_update_solution_arrays_jit block at the tail of compute_advection.py (34 lines)
- the live _update_solution_variables (ooJ-aware) is untouched
- repro gate fast: 3 cases bit-identical at tol 0
- new CASE_SETS["blending"] = warm bubble + hydrostatic, the cheap gate for edits under interfaces/dynamics_blending
- add test_blending_hydrostatic to CASE_SETS["full"] (was missing)
- coverage extension only; no pass criterion moved
- capture --set blending green (both cases, baselines snapshotted)
- move run_window, CFL host control (_cfl_maxima*, _host_dt), _check_supported, _eval_forcing and the window compile cache (device_kernels.py 697-921, verbatim) into device_loop.py
- device_kernels keeps the traced substeps + make_step (~690 lines)
- device_step shim now re-exports run_window from device_loop; __all__ unchanged
- gates: device<->device bit-identity (fast set, pre-split baseline), 11/11 device equivalence + fullrun tests, numpy fast bit-diff
- port swe_lake.py to ModelState, 2D x-y layout (thin-y 3D form in history); do_lake_to_swe_conv mirrors comp_psinc but rolls back the look-ahead clock
- repair orchestration swe branches: undefined flux, unbound conversion flag (threaded as lake_to_swe_pending through time_update), CFL override kept
- fix latent duplicate-ud TypeError on the continuous-blending do_psinc_to_comp_conv call (8 args vs 7 params; path unexercised by gates)
- new golden-master case test_blending_swe (balanced SWE vortex, initial swe->lake->swe blend) registered in IC_MODULES, test_blending.py, repro gate
- gates: warm bubble + hydrostatic + fast set bit-identical at tol 0; new case 7/7 fields green vs its master; blended vs unblended twin ~3e-4
- named predicates replace the nested conditionals: _window_start_conversion_due, _full_blend_due, _initial_blend_phase (to_limit / to_full / None)
- drop the field-order-dependent ModelState iterator unpack; bind the load-bearing stale sol/npf aliases explicitly and document why
- drop the dead debug threading from prepare_blending/blending_before_timestep
- bit-identical at tol 0 on all three blending masters + the fast set
- the integration job ran the 7 test_jax_* scripts relying on their module-level skip; pytest >= 9 exits 5 on no-tests-collected
- drop them there; the jax-equivalence job runs all 7 with jax installed
- unblocks PR #66 CI (failed at test_jax_operator_equivalence)
- circular Agnesi bell h0=100 m, a=10 km, N=0.01 1/s, U=10 m/s (hydrostatic, linear regime), Gal-Chen, 64x32x64, 10 steps
- first terrain case with orography varying in both horizontal coordinates; z->-z mirror symmetry preserved to ~5e-9
- register in IC_MODULES; freeze stripped target (tol 5e-4, same rationale as 2D Agnesi)
- not CI-wired: ~5 min/run on the numpy path
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