test: fix shear-wave review findings (runner finiteness, source pin, contract)
- run_case: finite_row accepts list diagnostics; sample() shared by sample and READY paths; verify_source pins shear_wave.py path+SHA256 for --flow shear_wave (default TG flow unchanged, does not import it). - assess_shear_wave.py: fixed N128 four-case contract and 4-JSON CLI, reusing assess_projected_pairs provenance/build/workload/time checks plus shear metadata; missing/duplicate/mixed/extra records -> INVALID_SET. - tests: mocked refined runner sample (list diagnostics, NaN, TG unchanged), contract pass + reproduced false-pass mutations, divergence check uses analytic E.k=0 and a derived h^2 truncation + roundoff bound with h-halving scaling instead of a fixed 1e-12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
10069feadb
commit
3554cb2fde
4 files changed
+262
-12
No files matched your search
@@ -18,6 +18,7 @@ SOURCE_SHA256 = "a5dbfd804befce868067d79a23e5fd47dce7f505b3f9b1bb2145fb57cb5f217
|
||||
BUILD_CAPTURE_SHA256 = "3dbaa6547cb0a4cb1541054f3b64ad8b6e18cc70527ac6166e56b944e9bd464a"
|
||||
REFERENCE_HARNESS = "11901a7f77557a901e017a171eeae1758d584fa5"
|
||||
INITIALIZATION = "physical FP64 equilibrium G at actual cell centers; rho=1+3p"
|
||||
SHEAR_WAVE_SHA256 = "49ab589d15d964d38ed90a49758e159c67a516191c7501c19fe2732e19742395"
|
||||
|
||||
|
||||
def flow_functions(flow="taylor_green"):
|
||||
@@ -30,6 +31,19 @@ def flow_functions(flow="taylor_green"):
|
||||
raise ValueError(f"unknown flow {flow!r}")
|
||||
|
||||
|
||||
def finite_row(row):
|
||||
"""Every scalar or list-valued diagnostic is finite (TG rows are all scalars)."""
|
||||
return all(np.isfinite(np.asarray(value, dtype=float)).all() for value in row.values())
|
||||
|
||||
|
||||
def sample(run, masks, step, n, viscosity, initial_mass, metrics, depth, label="sample"):
|
||||
arrays = (run.download(),) if depth == 1 else run.download()
|
||||
row = metrics(arrays, masks, step, n, viscosity, initial_mass)
|
||||
if not finite_row(row):
|
||||
raise FloatingPointError(f"nonfinite {label} diagnostics")
|
||||
return row
|
||||
|
||||
|
||||
def sample_steps(n, early_pressure=False):
|
||||
"""Root synchronization steps; early ladder matches the 707afe6 diagnostic."""
|
||||
main = [round(tstar * n / U) for tstar in TIMES]
|
||||
@@ -74,7 +88,7 @@ def provenance(repo):
|
||||
)
|
||||
|
||||
|
||||
def verify_source(repo, revision):
|
||||
def verify_source(repo, revision, flow="taylor_green"):
|
||||
"""Exact clean harness commit, fixed production tree, and reviewed capture helper."""
|
||||
import oracle
|
||||
from tests.validation.multigrid import check_projected_pairs as gate
|
||||
@@ -93,6 +107,13 @@ def verify_source(repo, revision):
|
||||
if result["source_tree_sha256"] != SOURCE_SHA256:
|
||||
raise RuntimeError("Wrong numerical source fingerprint")
|
||||
result["build_capture_sha256"] = BUILD_CAPTURE_SHA256
|
||||
if flow == "shear_wave":
|
||||
import shear_wave
|
||||
module = harness / "shear_wave.py"
|
||||
if (Path(shear_wave.__file__).resolve() != module
|
||||
or hashlib.sha256(module.read_bytes()).hexdigest() != SHEAR_WAVE_SHA256):
|
||||
raise RuntimeError("Wrong shear_wave module checkout or content")
|
||||
result["shear_wave_sha256"] = SHEAR_WAVE_SHA256
|
||||
return result
|
||||
|
||||
|
||||
@@ -175,7 +196,7 @@ def main():
|
||||
p.error("--run-gpu and exactly one explicit CUDA_VISIBLE_DEVICES are required")
|
||||
repo = args.repo.resolve()
|
||||
sys.path[:0] = [str(repo / "src"), str(repo)]
|
||||
source = verify_source(repo, args.expected_revision)
|
||||
source = verify_source(repo, args.expected_revision, args.flow)
|
||||
runtime = runtime_source(repo)
|
||||
if args.dry_run:
|
||||
print(json.dumps(dict(source=source, runtime_source=runtime, dry_run=True)))
|
||||
@@ -267,10 +288,8 @@ def main():
|
||||
initial_mass = None
|
||||
for step in sorted(set(main_steps + early_steps)):
|
||||
run.step(step - run.step_count)
|
||||
arrays = (run.download(),) if args.depth == 1 else run.download()
|
||||
row = metrics(arrays, masks, step, args.n, cfg.viscosity, initial_mass)
|
||||
if not all(np.isfinite(value) for value in row.values()):
|
||||
raise FloatingPointError("nonfinite sample diagnostics")
|
||||
row = sample(run, masks, step, args.n, cfg.viscosity, initial_mass,
|
||||
metrics, args.depth)
|
||||
row["step"] = step
|
||||
if initial_mass is None:
|
||||
initial_mass = row["mass"]
|
||||
@@ -297,10 +316,8 @@ def main():
|
||||
# Exercise real kernels/halos/transfers on every level before READY.
|
||||
# This is the first measured trajectory step, not discarded warmup.
|
||||
run.step(1)
|
||||
probe = (run.download(),) if args.depth == 1 else run.download()
|
||||
probe_metrics = metrics(probe, masks, 1, args.n, cfg.viscosity, initial_mass)
|
||||
if not all(np.isfinite(value) for value in probe_metrics.values()):
|
||||
raise FloatingPointError("nonfinite READY diagnostics")
|
||||
sample(run, masks, 1, args.n, cfg.viscosity, initial_mass,
|
||||
metrics, args.depth, "READY")
|
||||
report["ready_after_step"] = 1
|
||||
save()
|
||||
print(
|
||||
|
||||
Reference in new issue
Block a user