Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dcd3e0dbe | ||
|
|
d61560d98a | ||
|
|
3496a1e3c1 | ||
|
|
b983c1d095 | ||
|
|
fc0e544c0a | ||
|
|
95cb6d2b9f | ||
|
|
53fad76759 | ||
|
|
8403956a9a | ||
|
|
185a919cc5 |
No files matched your search
@@ -0,0 +1,62 @@
|
|||||||
|
# Selective LES normalization integration on dev8403956
|
||||||
|
|
||||||
|
This change reuses the reviewed correction from 5465832 without merging its
|
||||||
|
branch history. The only production change is the two closed-form coefficients
|
||||||
|
18 -> 18 sqrt(2) and their explanatory comments in turbulence_smag.cuh. Its SHA256
|
||||||
|
is a3db46c2e7d27530b2d1436e65cdbed0b72cc7e047bfbeef2a640877271b51aa.
|
||||||
|
Defaults, iterative/deviatoric/capped closure, collision dispatch, AMR guards,
|
||||||
|
and all other production source files are unchanged.
|
||||||
|
|
||||||
|
## Separate source contract; unchanged experiment
|
||||||
|
|
||||||
|
The single existing flow runner now accepts `--experiment dev8403956`.
|
||||||
|
Its separate source_pins_dev8403956.json pins all 101 production files from the
|
||||||
|
committed 8403956 baseline; corrected mode permits only the exact reviewed
|
||||||
|
header substitution. Results record the actual checkout commit, import path,
|
||||||
|
experiment name and manifest SHA256. No arbitrary manifest-path override exists.
|
||||||
|
|
||||||
|
Omitting the option still selects the original historical source manifest.
|
||||||
|
That manifest, the original paired receipts, scalar preparation manifests and
|
||||||
|
independent continuum oracle are unchanged. Historical baseline and corrected
|
||||||
|
receipts remain evidence for their own exact sources, not new dev receipts.
|
||||||
|
Historical guards intentionally reject this different dev source tree. Eight
|
||||||
|
production files already differed between the historical source snapshot and
|
||||||
|
8403956; neither the old manifest nor its acceptance is silently regenerated.
|
||||||
|
|
||||||
|
The physical experiment and every numerical acceptance threshold are unchanged:
|
||||||
|
8 x 34 nodes, halfway y walls, periodic x, unforced D2Q9/SRT, shifted FP32,
|
||||||
|
double-buffer streaming, Cs=0/.16/1, checkpoints 519/1038/2075. Each case has one
|
||||||
|
actual advancing warm-up followed by complete initial-state restoration before
|
||||||
|
READY. Total launches are 6,225 measured plus three warm-ups. Cs=1 remains an
|
||||||
|
amplified diagnostic, not a physical coefficient recommendation.
|
||||||
|
|
||||||
|
## Host checks
|
||||||
|
|
||||||
|
PYTHONDONTWRITEBYTECODE=1 python -m unittest discover -s tests/unit -p 'test_smagorinsky_normalization.py' -v
|
||||||
|
PYTHONDONTWRITEBYTECODE=1 python -m unittest discover -s tests/unit -p 'test_les_flow_*.py' -v
|
||||||
|
|
||||||
|
The direct-current-header test is copied unchanged from reviewed 5465832:
|
||||||
|
120 tensor parameter cases, Cs=0/equilibrium and omega guards, converged
|
||||||
|
trace-free iterative comparison, and mutation detection in both lattice
|
||||||
|
algebras. This is scalar D2/D3 algebra coverage, not 3D-flow qualification.
|
||||||
|
Flow tests retain analytic/reference checks and add current named-source,
|
||||||
|
reverse-patched baseline, variant rejection, unrelated-source tampering and
|
||||||
|
immutable historical-default checks. The temporary baseline is constructed
|
||||||
|
only inside a test directory; production is never reverse-patched.
|
||||||
|
|
||||||
|
## Pending final-commit GPU gate
|
||||||
|
|
||||||
|
After independent review and explicit executor authorization, run from the
|
||||||
|
exact committed candidate checkout, selecting the authorized physical GPU:
|
||||||
|
|
||||||
|
CUDA_VISIBLE_DEVICES=<physical-GPU> PYTHONDONTWRITEBYTECODE=1 python tests/validation/run_uniform_les_flow.py --root "$PWD" --experiment dev8403956 --variant corrected --run-gpu --device 0 --output <new-evidence-directory>/corrected.json
|
||||||
|
|
||||||
|
Retain all source hashes, exact commit/import/device identity, manifest hash,
|
||||||
|
three READY/reset records, complete result JSON, stdout/stderr and actual exit.
|
||||||
|
Require all frozen gates, DONE passed=true and exit 0. Compare with historical
|
||||||
|
corrected evidence without relabeling it as current evidence. The old-vs-new
|
||||||
|
normalization discrimination already exists; no new baseline GPU run is needed
|
||||||
|
unless review finds a changed exercised uniform solver path.
|
||||||
|
|
||||||
|
No GPU result is claimed by this integration preparation. This does not expand
|
||||||
|
LES qualification to MRT, forcing, AMR LES or three-dimensional turbulent flows.
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# Bounded 2D implementation and validation scope
|
||||||
|
|
||||||
|
This inventory starts from dev `8403956a9afc0b0bb89265cec374392013d89016` and
|
||||||
|
integrates only the reviewed LES normalization production correction from
|
||||||
|
`95cb6d2b9f43c1bdd46cbf27f03f0dfc0877cfb0`. The merged production bytes match that
|
||||||
|
tested candidate exactly; the scope-test changes are retained from `53fad767`.
|
||||||
|
GPU receipts remain associated with their exact tested commits, not relabeled as
|
||||||
|
a new merged-commit run. Historical source identities and gates remain unchanged.
|
||||||
|
|
||||||
|
## Implementation boundaries
|
||||||
|
|
||||||
|
- Uniform D2Q9 supports SRT, TRT and MRT. An available collision selector does not
|
||||||
|
qualify every wall, inlet/outlet, forcing, storage or LES combination.
|
||||||
|
- Fixed refinement supports SRT/MRT, FP32 and double-buffer streaming; TRT and LES
|
||||||
|
are rejected. Shifted refinement requires all-blocked storage. Refined channel
|
||||||
|
boundaries have narrower configuration guards than uniform boundaries.
|
||||||
|
- Uniform checkpoints support compatible same-method continuation. Changing
|
||||||
|
collision or LES parameters is a different evolution, not exact continuation.
|
||||||
|
Jet checkpoints and refined checkpoints are unsupported; synchronized remapping
|
||||||
|
is not persistent restart.
|
||||||
|
- Keep these conclusions 2D. Local D3Q19 operator tests do not establish a supported
|
||||||
|
3D Simulation runtime.
|
||||||
|
|
||||||
|
## Evidence and remaining gaps
|
||||||
|
|
||||||
|
| Area | Available evidence | Boundary of the conclusion |
|
||||||
|
|---|---|---|
|
||||||
|
| MRT cylinder flow and observation windows | Full matched uniform/refined MRT DFG and the window-ledger campaign passed their frozen periodicity, reference and matched-comparison gates. The window campaign used `185a919`; its MRT/no-LES numerical path remains unchanged. Current dev also contains independently scoped test/documentation changes and the LES correction, which do not extend MRT qualification. | This does not qualify other collision/boundary combinations or every refinement interface. Timing improvements are not additional accuracy evidence. |
|
||||||
|
| Uniform forced channel | Six Poiseuille GPU cases on `8403956`: SRT/TRT/MRT at wall-normal resolutions H16/H32 passed. | This is the tested analytic channel configuration, not open-boundary or all-layout qualification. |
|
||||||
|
| Uniform restart | Ten SRT/MRT checkpoint GPU tests passed on `8403956`; the separate representative TRT same-method double-buffer continuation GPU case also passed (one test). | This covers the tested same-method continuation configurations. No LES, Jet or refined checkpoint claim follows. |
|
||||||
|
| Taylor–Green refinement | Independent topology checks are available. The actual-rate phase GPU regression passed one test across two layouts, with errors 1.584e-7 and 4.500e-9. | The physical interface-accuracy gap remains open. Passing topology and phase checks does not establish convergence or close that accuracy gate. |
|
||||||
|
| Porous Couette and annulus | Prior campaign evidence exists and must remain associated with its original setup and source. | The reconstructed annulus is a validation helper, not qualification of a public boundary-condition API. Do not infer absence of evidence from a missing current rerun. |
|
||||||
|
| LES normalization | The reviewed correction is integrated. Exact `95cb6d2` GPU validation passed all nine observations and frozen gates, with three warm-up/reset records, verified 101-source/import identity, DONE and exit 0. Last two SGS decrement relative errors were 6.276e-4 and 6.124e-5 against the unchanged 0.15 gate. | Scope is unforced uniform D2Q9/SRT, shifted FP32, double-buffer streaming and the tested wall-bounded x-periodic shear. No TRT/MRT LES, forcing, EsoPull, objects, refinement or 3D turbulence qualification follows. |
|
||||||
|
|
||||||
|
Historical uniform SRT cylinder-startup and inlet-rounding findings remain separate
|
||||||
|
from the passed MRT DFG result. Raw exchange/window consistency is a measurement
|
||||||
|
contract, not a general stress or force-accuracy certification. Existing source-pinned
|
||||||
|
runners may intentionally reject a newer checkout; never silently repin old receipts.
|
||||||
|
|
||||||
|
## Remaining work
|
||||||
|
|
||||||
|
The related host checks passed (67 checks); they do not replace the GPU or
|
||||||
|
physical-accuracy evidence above. Preserve the existing SRT checkpoint cases,
|
||||||
|
historical LES manifests and all frozen numerical criteria.
|
||||||
|
|
||||||
|
Continue the TG accuracy investigation using its actual fine-level rates and
|
||||||
|
the established analytic convention. Keep the physical accuracy gate open until
|
||||||
|
the relevant comparison passes. Review this integration independently before
|
||||||
|
publication; no new merged-commit GPU run is claimed here.
|
||||||
|
|
||||||
|
No repeat of the accepted full MRT DFG or Cartesian expansion across unsupported
|
||||||
|
combinations is required by this document. Main integration remains a separate
|
||||||
|
review of complete, bounded feature scope.
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# Opt-in observation-window ledger in the DFG runner
|
||||||
|
|
||||||
|
This test-only integration adds `--exchange-window` to `run_refined_dfg.py`. It uses the
|
||||||
|
existing production ledger; no collision, boundary, transfer, physical setup, reference,
|
||||||
|
periodicity gate or acceptance threshold changes. Default remains the historical
|
||||||
|
per-base-step observation path. Uniform stepping/force accumulation is unchanged.
|
||||||
|
|
||||||
|
For the refined case, each existing observation interval opens a new ledger at completed
|
||||||
|
base step `begin`, advances exactly the same `n` base intervals, and reads the integrated
|
||||||
|
root-lattice impulse for `[begin, begin+n]`. The contract requires root units, `window`
|
||||||
|
kind, `2*n` fine samples, matching endpoints, and fine dt=.5. The existing coefficient
|
||||||
|
calculation still divides this impulse by `n` and `.5*U_lattice**2*D_root`; force timestamps
|
||||||
|
remain `(begin+n/2)*U_lattice/D_root`. It does not divide an already averaged force again.
|
||||||
|
Pressure/macro/physical-leaf mass measurements and safety checks remain at the original
|
||||||
|
interval end. Pilot interval is 80 root steps; early full-run intervals remain 2000, and
|
||||||
|
any final shortened interval uses its actual `n`.
|
||||||
|
|
||||||
|
The opt-in uses one `step(n)` call and one window read per observation, rather than `n`
|
||||||
|
Python calls/readbacks. Internal subcycling and per-base synchronization remain owned by
|
||||||
|
the same backend. Cooperative deadline checks surround that complete interval; unlike
|
||||||
|
the default path they cannot interrupt between base steps inside `step(n)`. The existing
|
||||||
|
external hard watchdog is still required. The full-run cadence/cap is documented here,
|
||||||
|
but this preparation does not admit a full run or a GPU operation.
|
||||||
|
|
||||||
|
## Provenance and receipt separation
|
||||||
|
|
||||||
|
`source_manifest_window.json` pins the reviewed a233c9032487a6006e950d1e327079b00466c410
|
||||||
|
snapshot (production ledger origin d930) plus existing helper/reference files. Both SRT
|
||||||
|
and MRT are supported by this explicit opt-in source pin; collision selection remains
|
||||||
|
independent and shared by the two cases. Existing SRT and MRT manifests are untouched.
|
||||||
|
Default mode continues to reject the changed candidate under those historical pins;
|
||||||
|
use a matching historical `--source` checkout to run its default path. There is no
|
||||||
|
silent repinning, source fallback, or reuse of historical outputs as candidate evidence.
|
||||||
|
|
||||||
|
Plan, READY, summaries, timeout/comparison receipts now record `observation_mode` as
|
||||||
|
`last_base_step` or `window`, alongside collision and actual checkout provenance. On a
|
||||||
|
uniform receipt this labels its **paired campaign's refined observation mode**, not a
|
||||||
|
change to uniform observation. Full-mode pilot validation rejects missing or mismatched
|
||||||
|
mode labels in the plan, either case summary, and either READY receipt. Source/runner
|
||||||
|
hash, collision, completeness and health checks remain. Cross-mode pilot reuse is denied.
|
||||||
|
|
||||||
|
The earlier short A/W/W1 timing/capability evidence is not a full-run speedup or accuracy
|
||||||
|
claim. Mathematical impulse integration/units are unchanged; floating-point reduction
|
||||||
|
order can differ, so bitwise equality of force sums is not promised. Physics acceptance
|
||||||
|
continues to use the existing frozen gates. Historical failures/results are untouched.
|
||||||
|
|
||||||
|
CPU preparation commands, from the repository root:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python tests/unit/test_refined_dfg.py
|
||||||
|
PYTHONPATH=src python -m unittest tests.unit.test_raw_exchange_window tests.unit.test_time_window_dfg -v
|
||||||
|
python tests/validation/run_refined_dfg.py --collision MRT --exchange-window --mode plan --output /tmp/new-window-dfg-plan
|
||||||
|
```
|
||||||
|
|
||||||
|
Root must independently review and admit any execution. An admitted paired pilot uses
|
||||||
|
the existing watchdog, device selection, `--gpu-gates-approved`, positive
|
||||||
|
`--max-wall-seconds` and a new output directory, adding only `--exchange-window` to the
|
||||||
|
selected collision's pilot command. No GPU or remote action was performed for this patch.
|
||||||
@@ -5,7 +5,9 @@
|
|||||||
// nu_t = (C_s * Delta)^2 * |S|, Delta = 1 (lattice unit)
|
// nu_t = (C_s * Delta)^2 * |S|, Delta = 1 (lattice unit)
|
||||||
// omega_eff = 1 / (3*(nu + nu_t) + 0.5)
|
// omega_eff = 1 / (3*(nu + nu_t) + 0.5)
|
||||||
//
|
//
|
||||||
// |S| is estimated from non-equilibrium second-order moments using tau0.
|
// |S| = sqrt(2 S_ij S_ij), with Delta = 1 in lattice units.
|
||||||
|
// The stress estimate uses self-consistent tau_eff; tau0 is molecular.
|
||||||
|
// Closed form uses full stress. Iteration uses deviatoric stress and a cap.
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
#ifndef CELERIS_OPERATORS_TURBULENCE_SMAG_CUH
|
#ifndef CELERIS_OPERATORS_TURBULENCE_SMAG_CUH
|
||||||
@@ -65,12 +67,12 @@ __device__ __forceinline__ float compute_omega_smag(const float* __restrict__ f,
|
|||||||
|
|
||||||
#if LES_CLOSED_FORM
|
#if LES_CLOSED_FORM
|
||||||
// Closed-form Smagorinsky (no iteration):
|
// Closed-form Smagorinsky (no iteration):
|
||||||
// ω = 2 / (τ₀ + √(τ₀² + 18·Cs²·√Q / ρ))
|
// ω = 2 / (τ₀ + √(τ₀² + 18·√2·Cs²·√Q / ρ))
|
||||||
// where Q = Πneq_ij · Πneq_ij (Frobenius norm squared)
|
// where Q = Πneq_ij · Πneq_ij (Frobenius norm squared)
|
||||||
const float Q = pixx*pixx + piyy*piyy + 2.0f*pixy*pixy;
|
const float Q = pixx*pixx + piyy*piyy + 2.0f*pixy*pixy;
|
||||||
const float sqrtQ = sqrtf(fmaxf(Q, 0.0f));
|
const float sqrtQ = sqrtf(fmaxf(Q, 0.0f));
|
||||||
const float smag_const_sq = LES_CS * LES_CS;
|
const float smag_const_sq = LES_CS * LES_CS;
|
||||||
const float discriminant = tau0*tau0 + 18.0f * smag_const_sq * sqrtQ / rho_safe;
|
const float discriminant = tau0*tau0 + 18.0f * sqrtf(2.0f) * smag_const_sq * sqrtQ / rho_safe;
|
||||||
const float tau_eff = 0.5f * (tau0 + sqrtf(fmaxf(discriminant, tau0*tau0)));
|
const float tau_eff = 0.5f * (tau0 + sqrtf(fmaxf(discriminant, tau0*tau0)));
|
||||||
return clamp_omega(1.0f / fmaxf(tau_eff, 0.500001f));
|
return clamp_omega(1.0f / fmaxf(tau_eff, 0.500001f));
|
||||||
#else
|
#else
|
||||||
@@ -140,7 +142,7 @@ __device__ __forceinline__ float compute_omega_smag(const float* __restrict__ f,
|
|||||||
+ 2.0f*(pixy*pixy + pixz*pixz + piyz*piyz);
|
+ 2.0f*(pixy*pixy + pixz*pixz + piyz*piyz);
|
||||||
const float sqrtQ = sqrtf(fmaxf(Q, 0.0f));
|
const float sqrtQ = sqrtf(fmaxf(Q, 0.0f));
|
||||||
const float smag_const_sq = LES_CS * LES_CS;
|
const float smag_const_sq = LES_CS * LES_CS;
|
||||||
const float discriminant = tau0*tau0 + 18.0f * smag_const_sq * sqrtQ / rho_safe;
|
const float discriminant = tau0*tau0 + 18.0f * sqrtf(2.0f) * smag_const_sq * sqrtQ / rho_safe;
|
||||||
const float tau_eff = 0.5f * (tau0 + sqrtf(fmaxf(discriminant, tau0*tau0)));
|
const float tau_eff = 0.5f * (tau0 + sqrtf(fmaxf(discriminant, tau0*tau0)));
|
||||||
return clamp_omega(1.0f / fmaxf(tau_eff, 0.500001f));
|
return clamp_omega(1.0f / fmaxf(tau_eff, 0.500001f));
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -65,9 +65,14 @@ def test_shifted_topology_add_remove_preserves_cache_and_finite_flow(streaming,p
|
|||||||
assert np.max(macro['rho'][fluid]) < 1.5
|
assert np.max(macro['rho'][fluid]) < 1.5
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('streaming',['double_buffer','esopull'])
|
@pytest.mark.parametrize('collision,streaming', [
|
||||||
def test_checkpoint_exact_continuation_and_controls(streaming,tmp_path):
|
pytest.param('SRT', 'double_buffer', id='double_buffer'),
|
||||||
with make_sim(nx=48,ny=24,streaming=streaming,shifted=True) as sim:
|
pytest.param('SRT', 'esopull', id='esopull'),
|
||||||
|
pytest.param('TRT', 'double_buffer', id='trt-double_buffer'),
|
||||||
|
])
|
||||||
|
def test_checkpoint_exact_continuation_and_controls(collision,streaming,tmp_path):
|
||||||
|
# Same collision throughout save/load/continue; this is not a method-switch restart.
|
||||||
|
with make_sim(nx=48,ny=24,streaming=streaming,shifted=True,collision=collision) as sim:
|
||||||
sim.add_body('circle',center=(14,12),radius=3)
|
sim.add_body('circle',center=(14,12),radius=3)
|
||||||
sim.add_body('force_region',center=(30,12),radius=2)
|
sim.add_body('force_region',center=(30,12),radius=2)
|
||||||
sim.initialize()
|
sim.initialize()
|
||||||
|
|||||||
@@ -41,45 +41,53 @@ class GuardTests(unittest.TestCase):
|
|||||||
with self.assertRaisesRegex(RuntimeError, "velocity/profile"):
|
with self.assertRaisesRegex(RuntimeError, "velocity/profile"):
|
||||||
decode_macros(invalid, w, cx, cy)
|
decode_macros(invalid, w, cx, cy)
|
||||||
|
|
||||||
def test_baseline_pins(self):
|
def test_current_corrected_pins(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
source_guard(ROOT, "baseline")["base_commit"],
|
source_guard(ROOT, "corrected", "dev8403956")["base_commit"],
|
||||||
"cd3a657f9d3833e812c3cca173525f165b48710a",
|
"8403956a9afc0b0bb89265cec374392013d89016",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_corrected_and_tamper_guard(self):
|
def test_corrected_and_tamper_guard(self):
|
||||||
pins = json.loads((HERE / "data/les_flow/source_pins.json").read_text())
|
pins = json.loads((HERE / "data/les_flow/source_pins_dev8403956.json").read_text())
|
||||||
with TemporaryDirectory() as directory:
|
with TemporaryDirectory() as directory:
|
||||||
root = Path(directory)
|
root = Path(directory)
|
||||||
for name in pins["sources"]:
|
for name in pins["sources"]:
|
||||||
dest = root / name
|
dest = root / name
|
||||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
shutil.copyfile(ROOT / name, dest)
|
shutil.copyfile(ROOT / name, dest)
|
||||||
# Rebuild the reviewed candidate from actual pinned headers, not fixtures.
|
|
||||||
candidate = root / "header_candidate"
|
|
||||||
subprocess.run(
|
|
||||||
[
|
|
||||||
sys.executable,
|
|
||||||
str(HERE / "les/prepare.py"),
|
|
||||||
"--repo",
|
|
||||||
str(ROOT),
|
|
||||||
"--output-dir",
|
|
||||||
str(candidate),
|
|
||||||
],
|
|
||||||
check=True,
|
|
||||||
)
|
|
||||||
shutil.copyfile(candidate / "patched" / HEADER, root / HEADER)
|
|
||||||
with patch(
|
with patch(
|
||||||
"run_uniform_les_flow.subprocess.check_output",
|
"run_uniform_les_flow.subprocess.check_output",
|
||||||
return_value="isolated-fixture\n",
|
return_value="isolated-fixture\n",
|
||||||
):
|
):
|
||||||
source_guard(root, "corrected")
|
source_guard(root, "corrected", "dev8403956")
|
||||||
with self.assertRaisesRegex(RuntimeError, "Source pin mismatch"):
|
with self.assertRaisesRegex(RuntimeError, "Source pin mismatch"):
|
||||||
source_guard(root, "baseline")
|
source_guard(root, "baseline", "dev8403956")
|
||||||
target = root / "src/CelerisLab/lbm/kernels/step/one_step_double.cu"
|
target = root / "src/CelerisLab/lbm/kernels/step/one_step_double.cu"
|
||||||
target.write_bytes(target.read_bytes() + b"\n// tamper\n")
|
target.write_bytes(target.read_bytes() + b"\n// tamper\n")
|
||||||
with self.assertRaisesRegex(RuntimeError, "Source pin mismatch"):
|
with self.assertRaisesRegex(RuntimeError, "Source pin mismatch"):
|
||||||
source_guard(root, "corrected")
|
source_guard(root, "corrected", "dev8403956")
|
||||||
|
|
||||||
|
def test_historical_default_and_manifest_unchanged(self):
|
||||||
|
manifest = HERE / "data/les_flow/source_pins.json"
|
||||||
|
self.assertEqual(hashlib.sha256(manifest.read_bytes()).hexdigest(),
|
||||||
|
"87ca033619da1fc02bee822bfc5681b518a92a155c3c3d1dbbe5265c96066b39")
|
||||||
|
for variant in ("baseline", "corrected"):
|
||||||
|
with self.assertRaisesRegex(RuntimeError, "Source pin mismatch"):
|
||||||
|
source_guard(ROOT, variant)
|
||||||
|
|
||||||
|
def test_named_baseline_accepts_only_reversed_header(self):
|
||||||
|
pins = json.loads((HERE / "data/les_flow/source_pins_dev8403956.json").read_text())
|
||||||
|
with TemporaryDirectory() as directory:
|
||||||
|
root = Path(directory)
|
||||||
|
for name in pins["sources"]:
|
||||||
|
dest = root / name
|
||||||
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
shutil.copyfile(ROOT / name, dest)
|
||||||
|
subprocess.run(["git", "apply", "--reverse", str(HERE / "les/data/smagorinsky_normalization.patch")], cwd=root, check=True)
|
||||||
|
with patch("run_uniform_les_flow.subprocess.check_output", return_value="baseline-fixture\n"):
|
||||||
|
source_guard(root, "baseline", "dev8403956")
|
||||||
|
with self.assertRaisesRegex(RuntimeError, "Source pin mismatch"):
|
||||||
|
source_guard(root, "corrected", "dev8403956")
|
||||||
|
|
||||||
def test_gpu_requires_opt_in_before_import(self):
|
def test_gpu_requires_opt_in_before_import(self):
|
||||||
with TemporaryDirectory() as directory:
|
with TemporaryDirectory() as directory:
|
||||||
|
|||||||
+126
-10
@@ -15,7 +15,11 @@ h, periodic = r.helpers(r.DEFAULT_SOURCE)
|
|||||||
def test_source_pin():
|
def test_source_pin():
|
||||||
historical = json.loads((r.HERE / "data/refined_dfg/source_manifest.json").read_text())
|
historical = json.loads((r.HERE / "data/refined_dfg/source_manifest.json").read_text())
|
||||||
assert historical["commit"].startswith("cd3a657")
|
assert historical["commit"].startswith("cd3a657")
|
||||||
assert r.verify_source(r.DEFAULT_SOURCE, "MRT")["commit"].startswith("3ea131e")
|
mrt_history = json.loads((r.HERE / "data/refined_dfg/source_manifest_mrt.json").read_text())
|
||||||
|
assert mrt_history["commit"].startswith("3ea131e")
|
||||||
|
assert r.verify_source(r.DEFAULT_SOURCE, "MRT", "window")["commit"].startswith("a233c90")
|
||||||
|
with unittest.TestCase().assertRaisesRegex(RuntimeError, "Source mismatch"):
|
||||||
|
r.verify_source(r.DEFAULT_SOURCE, "MRT")
|
||||||
with unittest.TestCase().assertRaisesRegex(RuntimeError, "Source mismatch"):
|
with unittest.TestCase().assertRaisesRegex(RuntimeError, "Source mismatch"):
|
||||||
r.verify_source(r.DEFAULT_SOURCE, "SRT")
|
r.verify_source(r.DEFAULT_SOURCE, "SRT")
|
||||||
|
|
||||||
@@ -139,17 +143,20 @@ def test_axis_specific_sampling_phase():
|
|||||||
|
|
||||||
def test_full_requires_completed_pilot():
|
def test_full_requires_completed_pilot():
|
||||||
with unittest.TestCase().assertRaisesRegex(ValueError, "pilot-results"):
|
with unittest.TestCase().assertRaisesRegex(ValueError, "pilot-results"):
|
||||||
r.verify_pilot(None, r.verify_source(r.DEFAULT_SOURCE, "MRT"))
|
r.verify_pilot(None, r.verify_source(r.DEFAULT_SOURCE, "MRT", "window"))
|
||||||
|
|
||||||
|
|
||||||
def pilot_fixture(path):
|
def pilot_fixture(path, observation_mode="window"):
|
||||||
"""Synthetic contract fixture only; never a physical result or run receipt."""
|
"""Synthetic contract fixture only; never a physical result or run receipt."""
|
||||||
manifest = r.verify_source(r.DEFAULT_SOURCE, "MRT")
|
manifest = (r.verify_source(r.DEFAULT_SOURCE, "MRT", "window")
|
||||||
|
if observation_mode == "window" else
|
||||||
|
json.loads((r.HERE / "data/refined_dfg/source_manifest_mrt.json").read_text()))
|
||||||
(path / "plan.json").write_text(
|
(path / "plan.json").write_text(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
dict(
|
dict(
|
||||||
source_manifest=manifest,
|
source_manifest=manifest,
|
||||||
collision="MRT",
|
collision="MRT",
|
||||||
|
observation_mode=observation_mode,
|
||||||
bounds_root_edge=list(r.BOUNDS),
|
bounds_root_edge=list(r.BOUNDS),
|
||||||
runner_sha256=r.runner_hash(),
|
runner_sha256=r.runner_hash(),
|
||||||
)
|
)
|
||||||
@@ -183,6 +190,7 @@ def pilot_fixture(path):
|
|||||||
dict(
|
dict(
|
||||||
case=case,
|
case=case,
|
||||||
collision="MRT",
|
collision="MRT",
|
||||||
|
observation_mode=observation_mode,
|
||||||
mode="pilot",
|
mode="pilot",
|
||||||
status="pilot_complete",
|
status="pilot_complete",
|
||||||
healthy=True,
|
healthy=True,
|
||||||
@@ -199,6 +207,7 @@ def pilot_fixture(path):
|
|||||||
dict(
|
dict(
|
||||||
case=case,
|
case=case,
|
||||||
collision="MRT",
|
collision="MRT",
|
||||||
|
observation_mode=observation_mode,
|
||||||
mode="pilot",
|
mode="pilot",
|
||||||
step=interval,
|
step=interval,
|
||||||
runner_sha256=r.runner_hash(),
|
runner_sha256=r.runner_hash(),
|
||||||
@@ -215,7 +224,7 @@ def test_pilot_validation_and_calibration():
|
|||||||
with TemporaryDirectory() as tmp:
|
with TemporaryDirectory() as tmp:
|
||||||
path = Path(tmp)
|
path = Path(tmp)
|
||||||
manifest = pilot_fixture(path)
|
manifest = pilot_fixture(path)
|
||||||
assert r.verify_pilot(path, manifest, "MRT") == 3606.0
|
assert r.verify_pilot(path, manifest, "MRT", "window") == 3606.0
|
||||||
|
|
||||||
|
|
||||||
def test_reject_malformed_pilot_receipts():
|
def test_reject_malformed_pilot_receipts():
|
||||||
@@ -245,7 +254,7 @@ def test_reject_malformed_pilot_receipts():
|
|||||||
mutate(bad)
|
mutate(bad)
|
||||||
receipt.write_text(json.dumps(bad))
|
receipt.write_text(json.dumps(bad))
|
||||||
with unittest.TestCase().assertRaises(ValueError):
|
with unittest.TestCase().assertRaises(ValueError):
|
||||||
r.verify_pilot(path, manifest, "MRT")
|
r.verify_pilot(path, manifest, "MRT", "window")
|
||||||
# Exact reviewer regression: previously accepted NaN endpoint.
|
# Exact reviewer regression: previously accepted NaN endpoint.
|
||||||
receipt.write_text(
|
receipt.write_text(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
@@ -257,11 +266,11 @@ def test_reject_malformed_pilot_receipts():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
with unittest.TestCase().assertRaises(ValueError):
|
with unittest.TestCase().assertRaises(ValueError):
|
||||||
r.verify_pilot(path, manifest, "MRT")
|
r.verify_pilot(path, manifest, "MRT", "window")
|
||||||
receipt.write_text(json.dumps(valid))
|
receipt.write_text(json.dumps(valid))
|
||||||
(path / "uniform/ready.json").write_text("{}")
|
(path / "uniform/ready.json").write_text("{}")
|
||||||
with unittest.TestCase().assertRaises(ValueError):
|
with unittest.TestCase().assertRaises(ValueError):
|
||||||
r.verify_pilot(path, manifest, "MRT")
|
r.verify_pilot(path, manifest, "MRT", "window")
|
||||||
|
|
||||||
|
|
||||||
def test_strict_finite_json_and_deadline():
|
def test_strict_finite_json_and_deadline():
|
||||||
@@ -323,7 +332,7 @@ def test_reject_collision_receipts():
|
|||||||
record["collision"] = invalid
|
record["collision"] = invalid
|
||||||
receipt.write_text(json.dumps(record))
|
receipt.write_text(json.dumps(record))
|
||||||
with unittest.TestCase().assertRaises(ValueError):
|
with unittest.TestCase().assertRaises(ValueError):
|
||||||
r.verify_pilot(path, manifest, "MRT")
|
r.verify_pilot(path, manifest, "MRT", "window")
|
||||||
|
|
||||||
|
|
||||||
def test_record_actual_checkout_separately():
|
def test_record_actual_checkout_separately():
|
||||||
@@ -332,7 +341,114 @@ def test_record_actual_checkout_separately():
|
|||||||
actual = checkout_provenance(r.DEFAULT_SOURCE)
|
actual = checkout_provenance(r.DEFAULT_SOURCE)
|
||||||
assert len(actual["checkout_revision"]) == 40
|
assert len(actual["checkout_revision"]) == 40
|
||||||
assert isinstance(actual["checkout_dirty"], bool)
|
assert isinstance(actual["checkout_dirty"], bool)
|
||||||
assert r.verify_source(r.DEFAULT_SOURCE, "MRT")["production_origin_commit"].startswith("3ea131e")
|
assert r.verify_source(r.DEFAULT_SOURCE, "MRT", "window")["production_origin_commit"].startswith("d930")
|
||||||
|
|
||||||
|
|
||||||
|
def test_window_plan_preserves_physics():
|
||||||
|
for collision in ("SRT", "MRT"):
|
||||||
|
baseline = r.plan(h, collision)
|
||||||
|
window = r.plan(h, collision, "window")
|
||||||
|
assert baseline.pop("observation_mode") == "last_base_step"
|
||||||
|
assert window.pop("observation_mode") == "window"
|
||||||
|
assert baseline == window
|
||||||
|
assert r.verify_source(r.DEFAULT_SOURCE, collision, "window")["observation_mode"] == "window"
|
||||||
|
with unittest.TestCase().assertRaises(ValueError):
|
||||||
|
r.verify_source(r.DEFAULT_SOURCE, "MRT", "unknown")
|
||||||
|
|
||||||
|
|
||||||
|
def test_reject_observation_mode_receipts():
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
|
||||||
|
for mode, other in (("window", "last_base_step"), ("last_base_step", "window")):
|
||||||
|
with TemporaryDirectory() as tmp:
|
||||||
|
path = Path(tmp)
|
||||||
|
manifest = pilot_fixture(path, mode)
|
||||||
|
assert r.verify_pilot(path, manifest, "MRT", mode) == 3606.0
|
||||||
|
with unittest.TestCase().assertRaises(ValueError):
|
||||||
|
r.verify_pilot(path, manifest, "MRT", other)
|
||||||
|
for rel in ("plan.json", "uniform/summary.json", "refined/summary.json",
|
||||||
|
"uniform/ready.json", "refined/ready.json"):
|
||||||
|
for invalid in (other, None):
|
||||||
|
with TemporaryDirectory() as tmp:
|
||||||
|
path = Path(tmp)
|
||||||
|
manifest = pilot_fixture(path, mode)
|
||||||
|
receipt = path / rel
|
||||||
|
record = json.loads(receipt.read_text())
|
||||||
|
if invalid is None:
|
||||||
|
record.pop("observation_mode")
|
||||||
|
else:
|
||||||
|
record["observation_mode"] = invalid
|
||||||
|
receipt.write_text(json.dumps(record))
|
||||||
|
with unittest.TestCase().assertRaises(ValueError):
|
||||||
|
r.verify_pilot(path, manifest, "MRT", mode)
|
||||||
|
|
||||||
|
|
||||||
|
class ExchangeFixture:
|
||||||
|
"""Synthetic interval ledger for orchestration tests, not a solver or GPU result."""
|
||||||
|
def __init__(self):
|
||||||
|
self.step_count = 11
|
||||||
|
self.events = []
|
||||||
|
self.begin = None
|
||||||
|
self.override = {}
|
||||||
|
|
||||||
|
def start_exchange_window(self):
|
||||||
|
self.begin = self.step_count
|
||||||
|
self.events.append(("start", self.step_count))
|
||||||
|
|
||||||
|
def step(self, n):
|
||||||
|
self.events.append(("step", n))
|
||||||
|
self.step_count += n
|
||||||
|
|
||||||
|
def result(self, start, window):
|
||||||
|
from CelerisLab.lbm.raw_exchange import summarize_exchange
|
||||||
|
|
||||||
|
total = sum(range(start + 1, self.step_count + 1))
|
||||||
|
result = summarize_exchange([[total, -2*total, 0., 0.]], [0], [False],
|
||||||
|
body_id=0, level=1, h=.5, time_end=self.step_count, window=window,
|
||||||
|
reference_center=(80.5, 81.),
|
||||||
|
**({"duration": self.step_count-start} if window == "window" else {}))
|
||||||
|
result.update(self.override)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def read_exchange_window(self, body_id, *, level):
|
||||||
|
assert body_id == 0 and level == 1
|
||||||
|
self.events.append(("read_window", self.step_count))
|
||||||
|
return self.result(self.begin, "window")
|
||||||
|
|
||||||
|
def read_raw_exchange(self, body_id, *, level, window):
|
||||||
|
assert body_id == 0 and level == 1 and window == "last_base_step"
|
||||||
|
self.events.append(("read_raw", self.step_count))
|
||||||
|
return self.result(self.step_count-1, window)
|
||||||
|
|
||||||
|
|
||||||
|
def test_window_interval_impulse_sampling_and_units():
|
||||||
|
base, window = ExchangeFixture(), ExchangeFixture()
|
||||||
|
for n in (80, 2000, 3): # Pilot/dense, early full, and final partial interval.
|
||||||
|
begin = base.step_count
|
||||||
|
a = r.advance_refined_interval(base, n, float("inf"), "last_base_step")
|
||||||
|
w = r.advance_refined_interval(window, n, float("inf"), "window")
|
||||||
|
np.testing.assert_array_equal(w, a)
|
||||||
|
expected = sum(range(begin+1, begin+n+1))
|
||||||
|
np.testing.assert_array_equal(w, [expected, -2*expected])
|
||||||
|
den = .5 * r.SPEED**2 * 40
|
||||||
|
np.testing.assert_array_equal(w/n/den, a/n/den)
|
||||||
|
assert window.step_count == base.step_count == begin+n
|
||||||
|
assert window.events[-3:] == [("start", begin), ("step", n), ("read_window", begin+n)]
|
||||||
|
assert (begin+n/2)*r.SPEED/40 == (window.step_count-n/2)*r.SPEED/40
|
||||||
|
assert not any(event[0] == "read_raw" for event in window.events)
|
||||||
|
|
||||||
|
|
||||||
|
def test_window_contract_rejection():
|
||||||
|
for key, value in (("units", "local"), ("window", "last_base_step"),
|
||||||
|
("sample_count", 2), ("time_start", 0), ("time_end", 0), ("dt", 1.)):
|
||||||
|
backend = ExchangeFixture()
|
||||||
|
backend.override[key] = value
|
||||||
|
with unittest.TestCase().assertRaisesRegex(RuntimeError, "window force"):
|
||||||
|
r.advance_refined_interval(backend, 80, float("inf"), "window")
|
||||||
|
backend = ExchangeFixture()
|
||||||
|
with unittest.TestCase().assertRaises(TimeoutError):
|
||||||
|
r.advance_refined_interval(backend, 80, 0, "window")
|
||||||
|
assert not backend.events
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
"""Direct-current-header regression; historical candidate manifests stay frozen."""
|
||||||
|
|
||||||
|
import importlib.util
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
HELPERS = ROOT / "tests/validation/les"
|
||||||
|
sys.path.insert(0, str(HELPERS))
|
||||||
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
"smagorinsky_oracle", HELPERS / "test_candidate.py"
|
||||||
|
)
|
||||||
|
oracle = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(oracle)
|
||||||
|
HEADER = Path("src/CelerisLab/lbm/kernels/operators/turbulence_smag.cuh")
|
||||||
|
DESCRIPTORS = Path("src/CelerisLab/lbm/kernels/core/descriptors.cuh")
|
||||||
|
|
||||||
|
|
||||||
|
class SmagorinskyNormalization(unittest.TestCase):
|
||||||
|
def test_current_header_matches_independent_tensor_oracle(self):
|
||||||
|
with TemporaryDirectory() as directory:
|
||||||
|
build_dir = Path(directory)
|
||||||
|
for dim in (2, 3):
|
||||||
|
for cs in (0.0, 0.16):
|
||||||
|
# Compile directly against this checkout, not saved candidate headers.
|
||||||
|
closed = oracle.build(
|
||||||
|
ROOT.parent, ROOT.name, dim, cs, 1, 3, build_dir
|
||||||
|
)
|
||||||
|
converged = oracle.build(
|
||||||
|
ROOT.parent, ROOT.name, dim, cs, 0, 200, build_dir
|
||||||
|
)
|
||||||
|
for rho in (0.7, 1.0, 1.3):
|
||||||
|
for tau0 in (0.56, 0.8):
|
||||||
|
for kind, magnitude in (
|
||||||
|
("equilibrium", 0.0),
|
||||||
|
("shear", -0.02),
|
||||||
|
("shear", 0.02),
|
||||||
|
("extension", -0.02),
|
||||||
|
("extension", 0.02),
|
||||||
|
):
|
||||||
|
stress = oracle.tensor(
|
||||||
|
dim, kind, magnitude * rho, 0, dim - 1
|
||||||
|
)
|
||||||
|
f, eq = oracle.state(dim, rho, stress)
|
||||||
|
expected = 1 / oracle.standard_tau(
|
||||||
|
tau0, cs, oracle.norm(stress), rho
|
||||||
|
)
|
||||||
|
with self.subTest(
|
||||||
|
dim=dim,
|
||||||
|
cs=cs,
|
||||||
|
rho=rho,
|
||||||
|
tau=tau0,
|
||||||
|
kind=kind,
|
||||||
|
sign=magnitude,
|
||||||
|
):
|
||||||
|
self.assertAlmostEqual(
|
||||||
|
closed(f, eq, rho, tau0), expected, delta=3e-6
|
||||||
|
)
|
||||||
|
self.assertAlmostEqual(
|
||||||
|
converged(f, eq, rho, tau0),
|
||||||
|
expected,
|
||||||
|
delta=3e-6,
|
||||||
|
)
|
||||||
|
if cs == 0:
|
||||||
|
f, eq = oracle.state(
|
||||||
|
dim, 1.0, oracle.tensor(dim, "equilibrium", 0.0)
|
||||||
|
)
|
||||||
|
self.assertAlmostEqual(
|
||||||
|
closed(f, eq, 1.0, 0.50001), 1.99, delta=3e-6
|
||||||
|
)
|
||||||
|
self.assertAlmostEqual(
|
||||||
|
closed(f, eq, 1.0, 200.0), 0.01, delta=3e-6
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_removing_sqrt_two_is_detected(self):
|
||||||
|
with TemporaryDirectory() as directory:
|
||||||
|
root = Path(directory)
|
||||||
|
for relative in (HEADER, DESCRIPTORS):
|
||||||
|
target = root / "old_convention" / relative
|
||||||
|
target.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
shutil.copyfile(ROOT / relative, target)
|
||||||
|
target = root / "old_convention" / HEADER
|
||||||
|
text = target.read_text()
|
||||||
|
factor = "18.0f * sqrtf(2.0f) * smag_const_sq"
|
||||||
|
self.assertEqual(text.count(factor), 2)
|
||||||
|
target.write_text(text.replace(factor, "18.0f * smag_const_sq"))
|
||||||
|
for dim in (2, 3):
|
||||||
|
old = oracle.build(root, "old_convention", dim, 0.16, 1, 3, root)
|
||||||
|
stress = oracle.tensor(dim, "shear", 0.02)
|
||||||
|
f, eq = oracle.state(dim, 1.0, stress)
|
||||||
|
expected = 1 / oracle.standard_tau(0.8, 0.16, oracle.norm(stress), 1.0)
|
||||||
|
self.assertGreater(abs(old(f, eq, 1.0, 0.8) - expected), 1e-3)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"base_commit": "8403956a9afc0b0bb89265cec374392013d89016",
|
||||||
|
"production_origin_commit": "8403956a9afc0b0bb89265cec374392013d89016",
|
||||||
|
"source_experiment": "Explicit dev8403956 uniform SRT LES experiment; historical 9805383/5465832 receipts remain historical. Corrected permits only the reviewed normalization header.",
|
||||||
|
"sources": {
|
||||||
|
"src/CelerisLab/__init__.py": "21cc469bd6e970a1f9ff5970c8eea4602065e41fc881854759ee565ee55c10c6",
|
||||||
|
"src/CelerisLab/body/__init__.py": "e4e0e8f0769a94428d5b02fac790443997556cfc5515a5f1ed1595d2c694d69d",
|
||||||
|
"src/CelerisLab/body/action_smoother.py": "b1a23ee6bbd4850b172cb8738c5c3546ee465a54189e6af9d8044f023d4687dc",
|
||||||
|
"src/CelerisLab/body/coupling/__init__.py": "c931f7eb318d48408c3e2febcc6917c88c8dcc1697cbf4329b1f340d94c35763",
|
||||||
|
"src/CelerisLab/body/coupling/soa_packer.py": "8ec26fd55ef74801bbd5ab6bd3d0a7dabc750cbd498aaac2ca4c61a0108ad3c9",
|
||||||
|
"src/CelerisLab/body/ddf_patch.py": "60fcfb7441e73bf290bcff41ca3a83da3e7ddad765d7247464e8f02e3043b4e2",
|
||||||
|
"src/CelerisLab/body/geometry/__init__.py": "ada88980ab672959aca9aa3a4c4aade3219524b2ab68110cd2a2f41e3e0ca90a",
|
||||||
|
"src/CelerisLab/body/geometry/base.py": "cceca14361ca2f34d34a3e43730e1a79b8ca81be00f0dd62e884db32b479419f",
|
||||||
|
"src/CelerisLab/body/geometry/circle.py": "7605ca7c21103f1d801ac73ab8dd18dffbdac425b2dee7b8858b283628a9e436",
|
||||||
|
"src/CelerisLab/body/jets.py": "4104c24af4651f4bb4f8d8fd36fb6d88f41c6e4469822f36e22e74c9ede31dac",
|
||||||
|
"src/CelerisLab/body/manager.py": "01b653d25bd9b4333379c8bfd12383596b686d2029f2e91b1c91b618540ec6b3",
|
||||||
|
"src/CelerisLab/body/objects.py": "8e63cee8faa9cc6243bcff428be628dfad73a02a9a3b8ece7d78c0a63406a08d",
|
||||||
|
"src/CelerisLab/body/preprocess/__init__.py": "dfd9d58bc07f626ab23a70053e31b88a6d9165d2e4c76a4e9f48abe674d3d2ec",
|
||||||
|
"src/CelerisLab/body/preprocess/flag_overlay.py": "831fc9e9736b758847759a085ff133eb49ec91318ace4fda76f85960138ee300",
|
||||||
|
"src/CelerisLab/body/registry.py": "fbb7327780adbdc6da15ebdb799980daf32df22ee974af0893d7409f177bbb68",
|
||||||
|
"src/CelerisLab/body/sync_plan.py": "3a15bfe9ebeb91482dbfc68850761ef39c872cc12d2efc795babd0c01e392323",
|
||||||
|
"src/CelerisLab/common/__init__.py": "d4dbde78bc97fccc9eabac9abae8f0f15c112c10ff8e9b45bd9401d4723df1ef",
|
||||||
|
"src/CelerisLab/common/_types.py": "aad2ff1a9033d4fd68783ad7123afb47201ddc58785cb6dc0246947037072a5f",
|
||||||
|
"src/CelerisLab/common/checkpoint.py": "b2f960aecd5ac27a3a7130b809ffad4709c44d522edef0359ab952654625410b",
|
||||||
|
"src/CelerisLab/common/pathline.py": "a1b6efcc0a076d0f1dc8d49a595779426d7d5626b00072a59bac710ff02ad046",
|
||||||
|
"src/CelerisLab/common/preprocess.py": "7fc78a08857cf8e98519500b094a1d896af189b6b15658ff9b388ed51bed4515",
|
||||||
|
"src/CelerisLab/common/render.py": "0e055476257eb2bcd11e733766e52195de02f8fad228f570a3511a7c831bdc29",
|
||||||
|
"src/CelerisLab/common/streakline/__init__.py": "13ff1cfa416fdd721a08a659e76b5a5a99b8d3201add10a83b7b0bc654bc1eec",
|
||||||
|
"src/CelerisLab/common/streakline/_config.py": "a9185ef68e9c7b5d5a1dc0b04a28341e2ad91d13c145a7c106636a878cf0a605",
|
||||||
|
"src/CelerisLab/common/streakline/_integrate.py": "3fbd4368b2c8d0e7fda40dc65aac5df02b085008b4c68acd83cb7ae45d33a13b",
|
||||||
|
"src/CelerisLab/common/streakline/_render.py": "236cd637414ee318c4d66f9aed32110d8dc42a100d65fde06172f7cd0ba62c65",
|
||||||
|
"src/CelerisLab/common/streakline/_streakline.py": "1a3e08daa706b5f83cdeb337e9a945a36ddf7583c40af1d0bb9d825ac954df37",
|
||||||
|
"src/CelerisLab/config.py": "2f1bba7515f5bc08cb3a8d140bcafe7fa0689e01b3b06494697bb2956a71530e",
|
||||||
|
"src/CelerisLab/configs/CONFIG.md": "41cafdbe525366c08aa9d0416ea026ccf0026ba7123b8a9b65f968a80d928e3a",
|
||||||
|
"src/CelerisLab/configs/config_body.json": "055f261f0828ca1d4f2bb694bd15b72bbcabe31d552326208f28e37f761adab1",
|
||||||
|
"src/CelerisLab/configs/config_lbm.json": "17e4311f1f250c6ece59177a8b6ff856b69a016c7c10267e774b030a0a390865",
|
||||||
|
"src/CelerisLab/configs/config_lbm_flume_mrt_zouhe.json": "8f593321db05a563a42931603a228d61cbcba06dfbe113262d5cd0ad93c0fe79",
|
||||||
|
"src/CelerisLab/configs/config_lbm_flume_trt_regularized.json": "f4bba8e6a4339fc3c4eb14f6e2f57c4b22993c73703c773d853edfbe34736e56",
|
||||||
|
"src/CelerisLab/configs/config_lbm_three_cylinder_triangle.json": "eeb8e7149dbe4aa6b3a9562802735aa950750dfbe2d972a0727e788573afa817",
|
||||||
|
"src/CelerisLab/cuda/__init__.py": "0d01dff9f0399c8baba822aab5ca0122a135f011008ed8a499ebd9f7e5b06aea",
|
||||||
|
"src/CelerisLab/cuda/compiler_v2.py": "c4cc3ec4445c8d75e6a253dd87963877117a722bc73b9d4811806fc6045d08c1",
|
||||||
|
"src/CelerisLab/cuda/context.py": "013dd4ec6d01d2fbd11afdfb103eac6a273bd9f798d663d761b851eeb27885e9",
|
||||||
|
"src/CelerisLab/cuda/obs_layout.py": "5ffb2c3aeeaaaaeb64f2cd8febfbcf4ad9919e5414020ad753cfade0683b21c2",
|
||||||
|
"src/CelerisLab/lbm/__init__.py": "7f60fb3aaae81501b510d08c2fedff44fcb05657260eb10b6f5cc91e7204306b",
|
||||||
|
"src/CelerisLab/lbm/block_stepper.py": "00b313daddc6e63d8ab8423c9190ca7e92ad291de20a2f6b80eb53e3f2d85ec7",
|
||||||
|
"src/CelerisLab/lbm/blocks.py": "1e644c5719993f418185ad4a10b6950a30636fc912befd9eab41ff48b4cf85cd",
|
||||||
|
"src/CelerisLab/lbm/channel.py": "40d0354e5dc97bcdb7e7b5c1e7f9303a109b7134d8a3af88b8ff4cd75ab5a095",
|
||||||
|
"src/CelerisLab/lbm/curved_links.py": "b6957fa13d13f864dba4f7364e93a39905d062dbb3ee9b3f5191add81fff0732",
|
||||||
|
"src/CelerisLab/lbm/descriptors.py": "c9f025dfc14da43b989047b84cc22bd05d5cc92c9ec695c1da68fdfb788e3f2b",
|
||||||
|
"src/CelerisLab/lbm/equilibrium.py": "2fb2f2bb7ff326d23abce80fc2a4c0907b17740ea3e29fe6ae079c5044783826",
|
||||||
|
"src/CelerisLab/lbm/field.py": "0e727eacc3706add4d8d15c418e9b631050871f831698d3ac689dd5f2c701b9b",
|
||||||
|
"src/CelerisLab/lbm/hierarchy.py": "f234975074f6b6d289d573ff6ea6832feae0e27cb04f80b37fe81792b13a12e7",
|
||||||
|
"src/CelerisLab/lbm/initializers.py": "dacf9586963e862d6d0a98ef1a066036be6f91e9d423720661d8ef2c1fb2df6a",
|
||||||
|
"src/CelerisLab/lbm/kernels/blocks.cu": "2fa894b20a29f006911ac3e3aad0793cc4aaf9ccd7a67d01c6320a0836b1d8ef",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/bounce_back.cuh": "aba3748c564ed91b161d268ef8b737b7c7be96a823063d201f3da684dd845233",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/curved_boundary.cuh": "aeb16bfd483514fb03e15a2fed437d673c3b8b2fe68ab83edf4244ef593878ea",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/esopull_curved_helpers.cuh": "b9b474bc4edaff05681c5443235472d04072d0d775fc0eb9c5967faef52b0258",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/ibm_kernels.cuh": "e6909b547dc8d64cdd8a76a90660243a8f5fee535caa161b52b4dd8b7c29934b",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/channel_stabilized.cuh": "efe077afcbb6b731256a987c2fd79a1dbc470c902f87070d60421ea6cb13d4e2",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/common.cuh": "59b38a89439878e00de7de16b9c7b03feff443fcc5a421593f7d2536dcbb7ab8",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/equilibrium.cuh": "f0964c811b2c41a5aaa1c6d99c490b06e850c634eb8749f1f05ef61f93c2de1d",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/regularized.cuh": "943d4a571818bacb89c70bccfaac202691121e3e385803ce6309123a0a03ddaf",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/zou_he_local.cuh": "e73e66b853b1e4e0e30d8f4185d832aa414ce670a1813ce2b5459f2887f71f89",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet_outlet.cuh": "de8b213a6da42c2e5e9f8966199fc66ea4541b85144a90f3f5dbad3c6ab63b97",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/outlet/pressure_neq.cuh": "c8b2adc66d12fe602076ddc9693c5c208711fcaddb58aa9a31401a269f51c4c4",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/planar_velocity.cuh": "501b2759d0e2e4280cb6fdd127d66a50fa89f6de48fc2cae9a7eafb11ae90bed",
|
||||||
|
"src/CelerisLab/lbm/kernels/config.h": "7d1124125e0b354558297934460e64c760fb68cdd7bf6d01a1238bb2eaab8c37",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_grid.h": "1db3e030ebdc116cd7f02362d1fd077daac55e8f0b4329f6285948c224d3ca5d",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_method.h": "4374e04a130f90f97d17cc20c40d2f9ea0ed0dd8603817d07f215d02266e247c",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_objects.h": "db793af052c756561a190a3ff2cb93ee5fe28462ee4f97c6af80882b4dc8b072",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_obs.h": "c11e2249359145b5c4cbaaf0487506fa77c1f4b82c7c169ddc574aa0babcd727",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_physics.h": "8ac0990b168e1058588676cc05c80df8634cfd671dbc92a89246c3c372d83a4e",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/descriptors.cuh": "8440bc14857da9007982650f828a23608eec9f7cc4bf772e8c8dc1239cb45356",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/flags.cuh": "0025705f24710330d9d9195f713879bfb650a85a3449baef0e196b831af104ab",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/layout.cuh": "1fbd820021c89ac3efcde24145996cb0147769e607e498e61f308ed3e0b13706",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/obs.cuh": "b742b77c9f61e1f020fe9922c3838ae9d855e17b381154958b58f10a22938922",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/params.cuh": "6e18bf730d936d940e3d85452f0714a2eaae31bf41002f9fd520ec5b372878dd",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/precision.cuh": "849df14b4cce50af52399e4b8f3e997196f3ae5f1163f68e28df3e6b2507a8c4",
|
||||||
|
"src/CelerisLab/lbm/kernels/kernel_v2.cu": "c7bd3fb705b77261ba2441c52a24a7e6a7865c165cba088a1b75201c4d29c408",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/collision_mrt.cuh": "aee444eb60c47a3fd518dca975d1af05425a0818a0ec6c3fb3f6150f60c2cb44",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/collision_srt.cuh": "6b7ff842f392c8f853d2d1a97cc69bfe50f21283f73e659404da07cf6c95f5e1",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/collision_trt.cuh": "9725b9840b9ad8b4ec7be61ff5d06d3151e86d1a87585c13f2fbf934d0d2c5f6",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/forcing_guo.cuh": "969a430c1af03f32e3bd0df95d805e64f56334717c44dd4ba208ba503062a24b",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/helpers.cuh": "0b3a4d95d7d19f5fec09e5423b8f4cc99f8a226b541967425967330da5a051ec",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/macro.cuh": "2be20eb2b7d7f5522daaad7f4b57b1ff8cdf883efe4a67846a96783b2fe846a3",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/turbulence_smag.cuh": "ff7f000297ee0817e255ad9fcb6a13b647e3ddd5b206518d35f38d2895a9f501",
|
||||||
|
"src/CelerisLab/lbm/kernels/refinement.cu": "b45aad9c022cecb64f7e968ec3cae2d8385a3cc430ee409700c404a3f4dd8cf8",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/aux_kernels.cu": "578a5b20a157241ee678547059abb1372dd5a589ad06bb2c15b987eb01ca1013",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/block_channel.cu": "ee8a31398b8e5233d977c816e6b8e060c1eb2ec71320e594226dbca55593c0d0",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/curved_double.cu": "bfa7a1df1e939020314d49755045f7a85fe4a19cc1c68dbe62653c66c5e7c2b3",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/esopull_macro.cu": "c73116020ca217ede1e4de27c8269c31f9d91e33433ac8252a21e9b14187c50f",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/esopull_sync.cu": "c0ff3e72900c3ab89a05dd03684e96d3b740cf1672d565727fc2af165933d087",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/init_flow.cu": "305be3bb12fc0d039acec1701baabcf0e8a35e683c49c34f2af8ca9867d2b29c",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/one_step_double.cu": "f9f8242b38e8e0cf8425b75e2b0215bc15363c62eaa0fb43c761b8e0931bfdc9",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/one_step_esopull.cu": "aa223b2744ae6c9125673df311a96ce588032c1ba58bebb11fd33ecb990f8ed4",
|
||||||
|
"src/CelerisLab/lbm/kernels/streaming/esopull_semantic_helpers.cuh": "dd5a9091628b079efd97e53fd49e52d09dcee88529235db77a5648e02937af6e",
|
||||||
|
"src/CelerisLab/lbm/kernels/streaming/esopull_single_buffer.cuh": "77ed4ab9a0ebc5ff62a91a7c39066ef395391ae36e9040a69fb2bd8b1626dc79",
|
||||||
|
"src/CelerisLab/lbm/kernels/streaming/pull_double_buffer.cuh": "b65d741ed78b7b62f99531ba0c0ce1936663d8dc9640e7d7d16c707f1baf6549",
|
||||||
|
"src/CelerisLab/lbm/population_storage.py": "a6a86c29c52c892edfe4802fb773c387212e3f4cc86708d80e154986ddf88044",
|
||||||
|
"src/CelerisLab/lbm/raw_exchange.py": "9031a196006a0f74dee4028e6f3bb673bc19ef7959f9f04dde9e01f93293aeb3",
|
||||||
|
"src/CelerisLab/lbm/refinement.py": "100d5e46ac894f6008b61364cdad5d37c2ca7ed949d8d71405572d6366526417",
|
||||||
|
"src/CelerisLab/lbm/refinement_stepper.py": "b6b835cf97f5aa045045bb4a47cfde34b89929d3872be410cb155727dfca2d33",
|
||||||
|
"src/CelerisLab/lbm/refinement_tables.py": "6eea593aaf791a2c644f1c74df0a41f6f5e62a2fce9feae76e19cf84b615607a",
|
||||||
|
"src/CelerisLab/lbm/stepper.py": "0dcb7cd7ae87e33e3dc67a38b6aa43042fbe673e37d9ad165342ee1d695933ce",
|
||||||
|
"src/CelerisLab/lbm/synchronized_remap.py": "7400fc4beaffd4649d6a9c524d38ce5fd6fa7eeb32eb5332e4030a4b6648f197",
|
||||||
|
"src/CelerisLab/simulation.py": "0a03904dc6de88667d7af699005a289adf8b09f0976cb0d099b041f4830a8f4c"
|
||||||
|
},
|
||||||
|
"candidate_header_sha256": "a3db46c2e7d27530b2d1436e65cdbed0b72cc7e047bfbeef2a640877271b51aa"
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
{
|
||||||
|
"commit": "a233c9032487a6006e950d1e327079b00466c410",
|
||||||
|
"production_origin_commit": "d9303234795fccf8591ba6274dfc544a84d956ff",
|
||||||
|
"observation_mode": "window",
|
||||||
|
"supported_collisions": [
|
||||||
|
"SRT",
|
||||||
|
"MRT"
|
||||||
|
],
|
||||||
|
"sha256": {
|
||||||
|
"src/CelerisLab/__init__.py": "21cc469bd6e970a1f9ff5970c8eea4602065e41fc881854759ee565ee55c10c6",
|
||||||
|
"src/CelerisLab/body/__init__.py": "e4e0e8f0769a94428d5b02fac790443997556cfc5515a5f1ed1595d2c694d69d",
|
||||||
|
"src/CelerisLab/body/action_smoother.py": "b1a23ee6bbd4850b172cb8738c5c3546ee465a54189e6af9d8044f023d4687dc",
|
||||||
|
"src/CelerisLab/body/coupling/__init__.py": "c931f7eb318d48408c3e2febcc6917c88c8dcc1697cbf4329b1f340d94c35763",
|
||||||
|
"src/CelerisLab/body/coupling/soa_packer.py": "8ec26fd55ef74801bbd5ab6bd3d0a7dabc750cbd498aaac2ca4c61a0108ad3c9",
|
||||||
|
"src/CelerisLab/body/ddf_patch.py": "60fcfb7441e73bf290bcff41ca3a83da3e7ddad765d7247464e8f02e3043b4e2",
|
||||||
|
"src/CelerisLab/body/geometry/__init__.py": "ada88980ab672959aca9aa3a4c4aade3219524b2ab68110cd2a2f41e3e0ca90a",
|
||||||
|
"src/CelerisLab/body/geometry/base.py": "cceca14361ca2f34d34a3e43730e1a79b8ca81be00f0dd62e884db32b479419f",
|
||||||
|
"src/CelerisLab/body/geometry/circle.py": "7605ca7c21103f1d801ac73ab8dd18dffbdac425b2dee7b8858b283628a9e436",
|
||||||
|
"src/CelerisLab/body/jets.py": "4104c24af4651f4bb4f8d8fd36fb6d88f41c6e4469822f36e22e74c9ede31dac",
|
||||||
|
"src/CelerisLab/body/manager.py": "01b653d25bd9b4333379c8bfd12383596b686d2029f2e91b1c91b618540ec6b3",
|
||||||
|
"src/CelerisLab/body/objects.py": "8e63cee8faa9cc6243bcff428be628dfad73a02a9a3b8ece7d78c0a63406a08d",
|
||||||
|
"src/CelerisLab/body/preprocess/__init__.py": "dfd9d58bc07f626ab23a70053e31b88a6d9165d2e4c76a4e9f48abe674d3d2ec",
|
||||||
|
"src/CelerisLab/body/preprocess/flag_overlay.py": "831fc9e9736b758847759a085ff133eb49ec91318ace4fda76f85960138ee300",
|
||||||
|
"src/CelerisLab/body/registry.py": "fbb7327780adbdc6da15ebdb799980daf32df22ee974af0893d7409f177bbb68",
|
||||||
|
"src/CelerisLab/body/sync_plan.py": "3a15bfe9ebeb91482dbfc68850761ef39c872cc12d2efc795babd0c01e392323",
|
||||||
|
"src/CelerisLab/common/__init__.py": "d4dbde78bc97fccc9eabac9abae8f0f15c112c10ff8e9b45bd9401d4723df1ef",
|
||||||
|
"src/CelerisLab/common/_types.py": "aad2ff1a9033d4fd68783ad7123afb47201ddc58785cb6dc0246947037072a5f",
|
||||||
|
"src/CelerisLab/common/checkpoint.py": "b2f960aecd5ac27a3a7130b809ffad4709c44d522edef0359ab952654625410b",
|
||||||
|
"src/CelerisLab/common/pathline.py": "a1b6efcc0a076d0f1dc8d49a595779426d7d5626b00072a59bac710ff02ad046",
|
||||||
|
"src/CelerisLab/common/preprocess.py": "7fc78a08857cf8e98519500b094a1d896af189b6b15658ff9b388ed51bed4515",
|
||||||
|
"src/CelerisLab/common/render.py": "0e055476257eb2bcd11e733766e52195de02f8fad228f570a3511a7c831bdc29",
|
||||||
|
"src/CelerisLab/common/streakline/__init__.py": "13ff1cfa416fdd721a08a659e76b5a5a99b8d3201add10a83b7b0bc654bc1eec",
|
||||||
|
"src/CelerisLab/common/streakline/_config.py": "a9185ef68e9c7b5d5a1dc0b04a28341e2ad91d13c145a7c106636a878cf0a605",
|
||||||
|
"src/CelerisLab/common/streakline/_integrate.py": "3fbd4368b2c8d0e7fda40dc65aac5df02b085008b4c68acd83cb7ae45d33a13b",
|
||||||
|
"src/CelerisLab/common/streakline/_render.py": "236cd637414ee318c4d66f9aed32110d8dc42a100d65fde06172f7cd0ba62c65",
|
||||||
|
"src/CelerisLab/common/streakline/_streakline.py": "1a3e08daa706b5f83cdeb337e9a945a36ddf7583c40af1d0bb9d825ac954df37",
|
||||||
|
"src/CelerisLab/config.py": "2f1bba7515f5bc08cb3a8d140bcafe7fa0689e01b3b06494697bb2956a71530e",
|
||||||
|
"src/CelerisLab/configs/CONFIG.md": "41cafdbe525366c08aa9d0416ea026ccf0026ba7123b8a9b65f968a80d928e3a",
|
||||||
|
"src/CelerisLab/configs/config_body.json": "055f261f0828ca1d4f2bb694bd15b72bbcabe31d552326208f28e37f761adab1",
|
||||||
|
"src/CelerisLab/configs/config_lbm.json": "17e4311f1f250c6ece59177a8b6ff856b69a016c7c10267e774b030a0a390865",
|
||||||
|
"src/CelerisLab/configs/config_lbm_flume_mrt_zouhe.json": "8f593321db05a563a42931603a228d61cbcba06dfbe113262d5cd0ad93c0fe79",
|
||||||
|
"src/CelerisLab/configs/config_lbm_flume_trt_regularized.json": "f4bba8e6a4339fc3c4eb14f6e2f57c4b22993c73703c773d853edfbe34736e56",
|
||||||
|
"src/CelerisLab/configs/config_lbm_three_cylinder_triangle.json": "eeb8e7149dbe4aa6b3a9562802735aa950750dfbe2d972a0727e788573afa817",
|
||||||
|
"src/CelerisLab/cuda/__init__.py": "0d01dff9f0399c8baba822aab5ca0122a135f011008ed8a499ebd9f7e5b06aea",
|
||||||
|
"src/CelerisLab/cuda/compiler_v2.py": "c4cc3ec4445c8d75e6a253dd87963877117a722bc73b9d4811806fc6045d08c1",
|
||||||
|
"src/CelerisLab/cuda/context.py": "013dd4ec6d01d2fbd11afdfb103eac6a273bd9f798d663d761b851eeb27885e9",
|
||||||
|
"src/CelerisLab/cuda/obs_layout.py": "5ffb2c3aeeaaaaeb64f2cd8febfbcf4ad9919e5414020ad753cfade0683b21c2",
|
||||||
|
"src/CelerisLab/lbm/__init__.py": "7f60fb3aaae81501b510d08c2fedff44fcb05657260eb10b6f5cc91e7204306b",
|
||||||
|
"src/CelerisLab/lbm/block_stepper.py": "00b313daddc6e63d8ab8423c9190ca7e92ad291de20a2f6b80eb53e3f2d85ec7",
|
||||||
|
"src/CelerisLab/lbm/blocks.py": "1e644c5719993f418185ad4a10b6950a30636fc912befd9eab41ff48b4cf85cd",
|
||||||
|
"src/CelerisLab/lbm/channel.py": "40d0354e5dc97bcdb7e7b5c1e7f9303a109b7134d8a3af88b8ff4cd75ab5a095",
|
||||||
|
"src/CelerisLab/lbm/curved_links.py": "b6957fa13d13f864dba4f7364e93a39905d062dbb3ee9b3f5191add81fff0732",
|
||||||
|
"src/CelerisLab/lbm/descriptors.py": "c9f025dfc14da43b989047b84cc22bd05d5cc92c9ec695c1da68fdfb788e3f2b",
|
||||||
|
"src/CelerisLab/lbm/equilibrium.py": "2fb2f2bb7ff326d23abce80fc2a4c0907b17740ea3e29fe6ae079c5044783826",
|
||||||
|
"src/CelerisLab/lbm/field.py": "0e727eacc3706add4d8d15c418e9b631050871f831698d3ac689dd5f2c701b9b",
|
||||||
|
"src/CelerisLab/lbm/hierarchy.py": "f234975074f6b6d289d573ff6ea6832feae0e27cb04f80b37fe81792b13a12e7",
|
||||||
|
"src/CelerisLab/lbm/initializers.py": "dacf9586963e862d6d0a98ef1a066036be6f91e9d423720661d8ef2c1fb2df6a",
|
||||||
|
"src/CelerisLab/lbm/kernels/blocks.cu": "2fa894b20a29f006911ac3e3aad0793cc4aaf9ccd7a67d01c6320a0836b1d8ef",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/bounce_back.cuh": "aba3748c564ed91b161d268ef8b737b7c7be96a823063d201f3da684dd845233",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/curved_boundary.cuh": "aeb16bfd483514fb03e15a2fed437d673c3b8b2fe68ab83edf4244ef593878ea",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/esopull_curved_helpers.cuh": "b9b474bc4edaff05681c5443235472d04072d0d775fc0eb9c5967faef52b0258",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/ibm_kernels.cuh": "e6909b547dc8d64cdd8a76a90660243a8f5fee535caa161b52b4dd8b7c29934b",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/channel_stabilized.cuh": "efe077afcbb6b731256a987c2fd79a1dbc470c902f87070d60421ea6cb13d4e2",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/common.cuh": "59b38a89439878e00de7de16b9c7b03feff443fcc5a421593f7d2536dcbb7ab8",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/equilibrium.cuh": "f0964c811b2c41a5aaa1c6d99c490b06e850c634eb8749f1f05ef61f93c2de1d",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/regularized.cuh": "943d4a571818bacb89c70bccfaac202691121e3e385803ce6309123a0a03ddaf",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet/zou_he_local.cuh": "e73e66b853b1e4e0e30d8f4185d832aa414ce670a1813ce2b5459f2887f71f89",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/inlet_outlet.cuh": "de8b213a6da42c2e5e9f8966199fc66ea4541b85144a90f3f5dbad3c6ab63b97",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/outlet/pressure_neq.cuh": "c8b2adc66d12fe602076ddc9693c5c208711fcaddb58aa9a31401a269f51c4c4",
|
||||||
|
"src/CelerisLab/lbm/kernels/boundary/planar_velocity.cuh": "501b2759d0e2e4280cb6fdd127d66a50fa89f6de48fc2cae9a7eafb11ae90bed",
|
||||||
|
"src/CelerisLab/lbm/kernels/config.h": "7d1124125e0b354558297934460e64c760fb68cdd7bf6d01a1238bb2eaab8c37",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_grid.h": "1db3e030ebdc116cd7f02362d1fd077daac55e8f0b4329f6285948c224d3ca5d",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_method.h": "4374e04a130f90f97d17cc20c40d2f9ea0ed0dd8603817d07f215d02266e247c",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_objects.h": "db793af052c756561a190a3ff2cb93ee5fe28462ee4f97c6af80882b4dc8b072",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_obs.h": "c11e2249359145b5c4cbaaf0487506fa77c1f4b82c7c169ddc574aa0babcd727",
|
||||||
|
"src/CelerisLab/lbm/kernels/config/config_physics.h": "8ac0990b168e1058588676cc05c80df8634cfd671dbc92a89246c3c372d83a4e",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/descriptors.cuh": "8440bc14857da9007982650f828a23608eec9f7cc4bf772e8c8dc1239cb45356",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/flags.cuh": "0025705f24710330d9d9195f713879bfb650a85a3449baef0e196b831af104ab",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/layout.cuh": "1fbd820021c89ac3efcde24145996cb0147769e607e498e61f308ed3e0b13706",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/obs.cuh": "b742b77c9f61e1f020fe9922c3838ae9d855e17b381154958b58f10a22938922",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/params.cuh": "6e18bf730d936d940e3d85452f0714a2eaae31bf41002f9fd520ec5b372878dd",
|
||||||
|
"src/CelerisLab/lbm/kernels/core/precision.cuh": "849df14b4cce50af52399e4b8f3e997196f3ae5f1163f68e28df3e6b2507a8c4",
|
||||||
|
"src/CelerisLab/lbm/kernels/kernel_v2.cu": "c7bd3fb705b77261ba2441c52a24a7e6a7865c165cba088a1b75201c4d29c408",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/collision_mrt.cuh": "aee444eb60c47a3fd518dca975d1af05425a0818a0ec6c3fb3f6150f60c2cb44",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/collision_srt.cuh": "6b7ff842f392c8f853d2d1a97cc69bfe50f21283f73e659404da07cf6c95f5e1",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/collision_trt.cuh": "9725b9840b9ad8b4ec7be61ff5d06d3151e86d1a87585c13f2fbf934d0d2c5f6",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/forcing_guo.cuh": "969a430c1af03f32e3bd0df95d805e64f56334717c44dd4ba208ba503062a24b",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/helpers.cuh": "0b3a4d95d7d19f5fec09e5423b8f4cc99f8a226b541967425967330da5a051ec",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/macro.cuh": "2be20eb2b7d7f5522daaad7f4b57b1ff8cdf883efe4a67846a96783b2fe846a3",
|
||||||
|
"src/CelerisLab/lbm/kernels/operators/turbulence_smag.cuh": "ff7f000297ee0817e255ad9fcb6a13b647e3ddd5b206518d35f38d2895a9f501",
|
||||||
|
"src/CelerisLab/lbm/kernels/refinement.cu": "b45aad9c022cecb64f7e968ec3cae2d8385a3cc430ee409700c404a3f4dd8cf8",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/aux_kernels.cu": "578a5b20a157241ee678547059abb1372dd5a589ad06bb2c15b987eb01ca1013",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/block_channel.cu": "ee8a31398b8e5233d977c816e6b8e060c1eb2ec71320e594226dbca55593c0d0",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/curved_double.cu": "bfa7a1df1e939020314d49755045f7a85fe4a19cc1c68dbe62653c66c5e7c2b3",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/esopull_macro.cu": "c73116020ca217ede1e4de27c8269c31f9d91e33433ac8252a21e9b14187c50f",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/esopull_sync.cu": "c0ff3e72900c3ab89a05dd03684e96d3b740cf1672d565727fc2af165933d087",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/init_flow.cu": "305be3bb12fc0d039acec1701baabcf0e8a35e683c49c34f2af8ca9867d2b29c",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/one_step_double.cu": "f9f8242b38e8e0cf8425b75e2b0215bc15363c62eaa0fb43c761b8e0931bfdc9",
|
||||||
|
"src/CelerisLab/lbm/kernels/step/one_step_esopull.cu": "aa223b2744ae6c9125673df311a96ce588032c1ba58bebb11fd33ecb990f8ed4",
|
||||||
|
"src/CelerisLab/lbm/kernels/streaming/esopull_semantic_helpers.cuh": "dd5a9091628b079efd97e53fd49e52d09dcee88529235db77a5648e02937af6e",
|
||||||
|
"src/CelerisLab/lbm/kernels/streaming/esopull_single_buffer.cuh": "77ed4ab9a0ebc5ff62a91a7c39066ef395391ae36e9040a69fb2bd8b1626dc79",
|
||||||
|
"src/CelerisLab/lbm/kernels/streaming/pull_double_buffer.cuh": "b65d741ed78b7b62f99531ba0c0ce1936663d8dc9640e7d7d16c707f1baf6549",
|
||||||
|
"src/CelerisLab/lbm/population_storage.py": "a6a86c29c52c892edfe4802fb773c387212e3f4cc86708d80e154986ddf88044",
|
||||||
|
"src/CelerisLab/lbm/raw_exchange.py": "9031a196006a0f74dee4028e6f3bb673bc19ef7959f9f04dde9e01f93293aeb3",
|
||||||
|
"src/CelerisLab/lbm/refinement.py": "100d5e46ac894f6008b61364cdad5d37c2ca7ed949d8d71405572d6366526417",
|
||||||
|
"src/CelerisLab/lbm/refinement_stepper.py": "b6b835cf97f5aa045045bb4a47cfde34b89929d3872be410cb155727dfca2d33",
|
||||||
|
"src/CelerisLab/lbm/refinement_tables.py": "6eea593aaf791a2c644f1c74df0a41f6f5e62a2fce9feae76e19cf84b615607a",
|
||||||
|
"src/CelerisLab/lbm/stepper.py": "0dcb7cd7ae87e33e3dc67a38b6aa43042fbe673e37d9ad165342ee1d695933ce",
|
||||||
|
"src/CelerisLab/lbm/synchronized_remap.py": "7400fc4beaffd4649d6a9c524d38ce5fd6fa7eeb32eb5332e4030a4b6648f197",
|
||||||
|
"src/CelerisLab/simulation.py": "0a03904dc6de88667d7af699005a289adf8b09f0976cb0d099b041f4830a8f4c",
|
||||||
|
"tests/validation/data/dfg_re100/reference_cycle.json": "073d1bda1629697efebad95667bfe80598e217d708dbffd7d5f6c6999379c55f",
|
||||||
|
"tests/validation/periodic.py": "a2212c0e2705126327a5019e9cafe64eeca398da1b75061ff23630c9843697a6",
|
||||||
|
"tests/validation/re100_helpers.py": "289c6e01075ff361573f862b90cfd61e5980c9a8efcbc78aef69979b4004fd60",
|
||||||
|
"tests/validation/source_provenance.py": "6dfe8f2d819dba0e240ba761d31162a5033685d492d09db75eb2b8aaab3a5a4c"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
"""Opt-in, frozen N64 space-time GPU trajectory; no convergence certification."""
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import resource
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[3]
|
||||||
|
sys.path.insert(0, str(ROOT/'src'))
|
||||||
|
sys.path.insert(0, str(Path(__file__).parents[1]/'taylor_green'))
|
||||||
|
from CelerisLab.config import LBMConfig
|
||||||
|
import oracle as tg
|
||||||
|
import spacetime_gpu as gpu
|
||||||
|
ref = gpu.ref
|
||||||
|
|
||||||
|
CPU_SHA = '180eef90a1c3f43113fe18cc54981ee4723cfc0cc2724334907ff188022fa770'
|
||||||
|
UNIFORM_SHA = '01e7415ae39456f2de7f0c3d331afb971c49d19353b43038650e32e80737f1e7'
|
||||||
|
CUDA_SHA = 'c47869688f7ac2ec93411c0af233887fe8b77405838299e4ae52c8963fd97fe4'
|
||||||
|
TABLE_SHA = 'f2e62038dc620c5a10bb61d51a88be2afd80488f2f9f4a10c2677cfbe11009cf'
|
||||||
|
STEPS = (256, 512, 768, 1024)
|
||||||
|
TIMES = (.12, .24, .36, .48)
|
||||||
|
FACTORS = dict(velocity_l2=.8, pressure_l2=1., energy_relative=1.)
|
||||||
|
LIMITS = dict(velocity_l2=.05, pressure_l2=.15, energy_relative=.05, mass_relative=1e-5)
|
||||||
|
HEALTH = ('boundary_pre_nonfinite', 'boundary_pre_nonpositive', 'boundary_stored_nonfinite',
|
||||||
|
'boundary_stored_nonpositive', 'physical_population_nonfinite', 'physical_population_nonpositive')
|
||||||
|
|
||||||
|
|
||||||
|
def sha(path):
|
||||||
|
return hashlib.sha256(Path(path).read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def load_references(cpu_path, uniform_path):
|
||||||
|
for path, expected in ((cpu_path, CPU_SHA), (uniform_path, UNIFORM_SHA)):
|
||||||
|
if sha(path) != expected:
|
||||||
|
raise ValueError(f'pinned reference receipt differs: {path}')
|
||||||
|
cpu, uniform = [json.loads(Path(p).read_text()) for p in (cpu_path, uniform_path)]
|
||||||
|
assert cpu['completed'] and cpu['experimental_pass'] and not cpu['source']['dirty']
|
||||||
|
assert cpu['source']['commit'] == '07879bc52bfef8d95503146c55d3823c8b6f8d0a'
|
||||||
|
assert [r['mode'] for r in cpu['runs']] == ['constant_ivp', 'spacetime']
|
||||||
|
assert all(tuple(row['tstar'] for row in r['rows']) == TIMES for r in cpu['runs'])
|
||||||
|
assert uniform['completed'] and not uniform['source']['dirty']
|
||||||
|
assert uniform['source']['revision'] == '9805383f9c50d867e8555471baf5dbda8333a652'
|
||||||
|
assert (uniform['n'], uniform['depth'], uniform['viscosity']) == (64, 1, .0192)
|
||||||
|
assert uniform['limits'] == tg.LIMITS == LIMITS
|
||||||
|
return cpu, uniform
|
||||||
|
|
||||||
|
|
||||||
|
def total(state, maps):
|
||||||
|
arrays = [a.astype(np.float64) for a in (state.coarse_f, state.fine_f)]
|
||||||
|
return ref.cpu.MOMENTS.T @ ref.directional(ref.cpu.State(*arrays), maps)
|
||||||
|
|
||||||
|
|
||||||
|
def warm_and_reset(run, initial, check_cap):
|
||||||
|
"""Time 32 synchronized intervals, then restore exact uploaded arrival F."""
|
||||||
|
run.initialize(initial)
|
||||||
|
before = run.download()
|
||||||
|
started = time.monotonic()
|
||||||
|
for _ in range(32):
|
||||||
|
check_cap()
|
||||||
|
run.step(audit=False)
|
||||||
|
seconds = time.monotonic()-started
|
||||||
|
warm_health = run.health_counts.tolist()
|
||||||
|
run.initialize(initial)
|
||||||
|
after = run.download()
|
||||||
|
for a, b in zip((before.coarse_f, before.fine_f), (after.coarse_f, after.fine_f)):
|
||||||
|
np.testing.assert_array_equal(a, b)
|
||||||
|
if run.step_count != 0 or after.tick != 0 or run.health_counts.any():
|
||||||
|
raise AssertionError('warm-up reset did not restore tick/counters')
|
||||||
|
return after, dict(intervals=32, seconds=seconds, estimated_1024_seconds=32*seconds,
|
||||||
|
health_counts=warm_health, reset_verified=True)
|
||||||
|
|
||||||
|
|
||||||
|
def assess(rows, cpu, uniform, health_counts):
|
||||||
|
if tuple(row['tstar'] for row in rows) != TIMES:
|
||||||
|
raise ValueError('four frozen sample times required')
|
||||||
|
worst = {key: max(row[key] for row in rows) for key in LIMITS}
|
||||||
|
campaign = {key: all(np.isfinite(row[key]) and 0 <= row[key] <= limit for row in rows)
|
||||||
|
for key, limit in LIMITS.items()}
|
||||||
|
campaign['population_health'] = not any(health_counts)
|
||||||
|
campaign['sampled_positive_finite'] = all(
|
||||||
|
np.isfinite(row[key]) and row[key] > 0 for row in rows
|
||||||
|
for key in ('minimum_population', 'minimum_boundary_pre', 'minimum_boundary_stored'))
|
||||||
|
baseline, candidate = cpu['runs']
|
||||||
|
thresholds = {key: factor*baseline['worst'][key] for key, factor in FACTORS.items()}
|
||||||
|
experimental = {key: all(np.isfinite(row[key]) and row[key] >= 0 for row in rows)
|
||||||
|
and worst[key] <= threshold for key, threshold in thresholds.items()}
|
||||||
|
differences = []
|
||||||
|
for actual, expected in zip(rows, candidate['rows']):
|
||||||
|
delta = {}
|
||||||
|
for key, value in expected.items():
|
||||||
|
d = np.asarray(actual[key])-np.asarray(value)
|
||||||
|
delta[key] = dict(cpu=value, signed=d.tolist(), absolute=np.abs(d).tolist())
|
||||||
|
differences.append(dict(tstar=actual['tstar'], fields=delta))
|
||||||
|
historical_worst = max(row['pressure_l2'] for row in uniform['rows'] if row['tstar'] > 0)
|
||||||
|
historical_limit = max(2*historical_worst, .02)
|
||||||
|
assert historical_limit == .024506347612699403
|
||||||
|
return dict(worst=worst, campaign_checks=campaign, campaign_pass=all(campaign.values()),
|
||||||
|
experimental_thresholds=thresholds, experimental_checks=experimental,
|
||||||
|
experimental_pass=all(experimental.values()),
|
||||||
|
gpu_minus_cpu=dict(status='descriptive_only_no_equivalence_tolerance', rows=differences),
|
||||||
|
historical_pressure_gate=dict(status='historical_shifted_FP32_uniform_vs_unshifted_FP32_candidate',
|
||||||
|
matched_storage=False, uniform_worst=historical_worst, threshold=historical_limit,
|
||||||
|
candidate_worst=worst['pressure_l2'], passed=worst['pressure_l2'] <= historical_limit))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('--gpu-admitted', action='store_true')
|
||||||
|
parser.add_argument('--cpu-receipt', type=Path, required=True)
|
||||||
|
parser.add_argument('--uniform-receipt', type=Path, required=True)
|
||||||
|
parser.add_argument('--output', type=Path, required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
if not args.gpu_admitted or not os.environ.get('CUDA_VISIBLE_DEVICES'):
|
||||||
|
parser.error('explicit --gpu-admitted and CUDA_VISIBLE_DEVICES required')
|
||||||
|
if args.output.exists():
|
||||||
|
parser.error('output exists; preserve evidence and choose a new path')
|
||||||
|
cpu, uniform = load_references(args.cpu_receipt, args.uniform_receipt)
|
||||||
|
gpu.check_sources()
|
||||||
|
if sha(Path(gpu.__file__).with_suffix('.cu')) != CUDA_SHA:
|
||||||
|
raise RuntimeError('reviewed CUDA source changed')
|
||||||
|
source = dict(commit=subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT, text=True).strip(),
|
||||||
|
dirty=bool(subprocess.check_output(['git', 'status', '--porcelain'], cwd=ROOT, text=True)),
|
||||||
|
hashes={p.name: sha(p) for p in (Path(__file__), Path(gpu.__file__), Path(gpu.__file__).with_suffix('.cu'),
|
||||||
|
Path(__file__).with_name('test_spacetime_gpu.py'))},
|
||||||
|
reference_hashes=gpu.PINS, numpy=np.__version__, checkout=str(ROOT))
|
||||||
|
if source['dirty']:
|
||||||
|
raise RuntimeError('clean committed checkout required')
|
||||||
|
started = time.monotonic()
|
||||||
|
report = dict(scope='N64 experimental space-time GPU; no grid-convergence qualification',
|
||||||
|
completed=False, passed=False, source=source, rows=[], health_counts=[0]*6, health_labels=HEALTH,
|
||||||
|
setup=dict(n=64, bounds=[8,8,56,48], re_L=100, U=.03, viscosity=.0192, tau=[.5576,.6152],
|
||||||
|
phase='arrival_f', storage='unshifted_FP32', collision='SRT', interval_count=1024,
|
||||||
|
initialization='same physical FP64 equilibrium as CPU, rounded to FP32 on upload',
|
||||||
|
cpu_storage='FP64', sample_steps=STEPS, sample_times=TIMES),
|
||||||
|
references=dict(cpu_receipt_sha256=CPU_SHA, cpu_source=cpu['source'],
|
||||||
|
cpu_archive_drive_id='197F9nwDOGf_YROK1a46YpVvNrSldnH_w',
|
||||||
|
cpu_archive_sha256='850ddce3f5203ef38e76e5153e718a9b92e137d1fc388ba7cd12f5d47eab83b4',
|
||||||
|
uniform_receipt_sha256=UNIFORM_SHA, uniform_source=uniform['source'],
|
||||||
|
uniform_storage='historical_shifted_FP32'),
|
||||||
|
frozen_screen=dict(campaign_limits=LIMITS, experimental_factors=FACTORS,
|
||||||
|
gpu_cpu_equivalence_tolerance=None, historical_pressure_threshold=.024506347612699403),
|
||||||
|
boundary_budget_status='not_measured', max_directional_residual=None,
|
||||||
|
minima_scope='initial and four sampled physical arrival states; boundary minima at four samples',
|
||||||
|
limits=dict(seconds=180., peak_rss_mib=512.), cuda_visible_devices=os.environ['CUDA_VISIBLE_DEVICES'])
|
||||||
|
run = context = None
|
||||||
|
phase = 'setup'
|
||||||
|
|
||||||
|
def save():
|
||||||
|
report['resources'] = dict(seconds=time.monotonic()-started,
|
||||||
|
peak_rss_mib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024,
|
||||||
|
device_allocations_bytes=None if run is None else run.device_bytes,
|
||||||
|
device_memory_scope='owner allocations; excludes compiler, driver and context')
|
||||||
|
if run is not None:
|
||||||
|
report['health_counts'] = run.health_counts.tolist()
|
||||||
|
report['completed_intervals'] = run.step_count
|
||||||
|
ref.write_receipt(args.output, report)
|
||||||
|
|
||||||
|
def check_cap():
|
||||||
|
if time.monotonic()-started > 180 or resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024 > 512:
|
||||||
|
raise RuntimeError('frozen resource cap exceeded')
|
||||||
|
|
||||||
|
save()
|
||||||
|
try:
|
||||||
|
from CelerisLab.cuda.context import CudaContext
|
||||||
|
context = CudaContext(0)
|
||||||
|
config = LBMConfig(nx=64, ny=64, viscosity=.0192, velocity=0., ddf_shifting=False)
|
||||||
|
run = gpu.SpaceTimeGPU(config, (8,8,56,48), context=context)
|
||||||
|
report.update(device=context.name, sm_arch=context.sm_arch, build_metadata=run.build_metadata,
|
||||||
|
table_sha256=gpu.table_hash(run.tables))
|
||||||
|
if report['table_sha256'] != TABLE_SHA:
|
||||||
|
raise RuntimeError('frozen coordinate tables changed')
|
||||||
|
initial = ref.cpu.State(tg.initial((64,64),0,64,.0192), tg.initial((128,128),1,64,.0192))
|
||||||
|
phase = 'warm_reset'
|
||||||
|
initial, report['warmup'] = warm_and_reset(run, initial, check_cap)
|
||||||
|
maps = run.plan.maps
|
||||||
|
masks = (maps.coarse_active, maps.fine_active)
|
||||||
|
arrays = (initial.coarse_f, initial.fine_f)
|
||||||
|
mass0 = tg.metrics(arrays, masks, 0, 64, .0192)['mass']
|
||||||
|
moment0 = total(initial, maps)
|
||||||
|
report['initial'] = dict(mass=mass0, momentum=moment0[1:].tolist(),
|
||||||
|
minimum_population=min(float(a[:,m].min()) for a,m in zip(arrays,masks)))
|
||||||
|
save()
|
||||||
|
check_cap()
|
||||||
|
phase = 'trajectory'
|
||||||
|
trajectory_started = time.monotonic()
|
||||||
|
for step in range(1,1025):
|
||||||
|
check_cap()
|
||||||
|
run.step(audit=False)
|
||||||
|
if step in STEPS:
|
||||||
|
state = run.download()
|
||||||
|
if state.tick != 2*step:
|
||||||
|
raise AssertionError('sample is not synchronized arrival state')
|
||||||
|
arrays = (state.coarse_f, state.fine_f)
|
||||||
|
row = tg.metrics(arrays, masks, step, 64, .0192, mass0)
|
||||||
|
row.update(step=step, momentum_change=(total(state,maps)-moment0)[1:].tolist(),
|
||||||
|
mass_change=row['mass']-mass0,
|
||||||
|
minimum_population=min(float(a[:,m].min()) for a,m in zip(arrays,masks)))
|
||||||
|
with context.activate():
|
||||||
|
row['minimum_boundary_pre'] = float(run.read(run.pre,(len(run.plan.groups),4),np.float64).min())
|
||||||
|
row['minimum_boundary_stored'] = float(run.read(run.h,(len(run.plan.groups),4)).min())
|
||||||
|
if not all(np.isfinite(value).all() for value in row.values()):
|
||||||
|
report['failed_sample'] = {key: repr(value) for key,value in row.items()}
|
||||||
|
raise FloatingPointError('nonfinite sample diagnostic')
|
||||||
|
report['rows'].append(row)
|
||||||
|
save()
|
||||||
|
print(json.dumps(row, allow_nan=False), flush=True)
|
||||||
|
report['trajectory_seconds'] = time.monotonic()-trajectory_started
|
||||||
|
check_cap()
|
||||||
|
report.update(assess(report['rows'], cpu, uniform, run.health_counts))
|
||||||
|
report['completed'] = True
|
||||||
|
report['passed'] = report['campaign_pass'] and report['experimental_pass']
|
||||||
|
except Exception as exc:
|
||||||
|
report['failure'] = dict(phase=phase, error=repr(exc))
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
# Preserve the primary failure and every completed sample even if cleanup fails.
|
||||||
|
for owner in (run, context):
|
||||||
|
if owner is not None:
|
||||||
|
try:
|
||||||
|
owner.close()
|
||||||
|
except Exception as exc:
|
||||||
|
report.setdefault('cleanup_errors', []).append(repr(exc))
|
||||||
|
report['passed'] = False
|
||||||
|
save()
|
||||||
|
return 0 if report['passed'] else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
raise SystemExit(main())
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
// Test-only arrival-f space-time coupling. No production scheduler changes.
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "core/precision.cuh"
|
||||||
|
#include "core/descriptors.cuh"
|
||||||
|
#include "core/layout.cuh"
|
||||||
|
#include "operators/macro.cuh"
|
||||||
|
#include "operators/collision_srt.cuh"
|
||||||
|
#include "streaming/pull_double_buffer.cuh"
|
||||||
|
|
||||||
|
#if DIM != 2 || NQ != 9 || COLLISION_MODEL != 0 || STORE_PRECISION != 0 || USE_DDF_SHIFTING || USE_LES || STREAMING_MODEL != 0
|
||||||
|
#error "Space-time experiment requires unshifted FP32 D2Q9 SRT double buffers without LES"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__device__ __forceinline__ void collide(float* f, float omega) {
|
||||||
|
float rho, ux, uy, feq[NQ];
|
||||||
|
compute_rho_u(f, rho, ux, uy);
|
||||||
|
compute_feq(rho, ux, uy, feq);
|
||||||
|
collide_srt_no_force(f, feq, omega);
|
||||||
|
}
|
||||||
|
|
||||||
|
__device__ __forceinline__ void health(float value, unsigned int* counts) {
|
||||||
|
if (!isfinite(value)) atomicAdd(counts + 4, 1u);
|
||||||
|
if (value <= 0.0f) atomicAdd(counts + 5, 1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __global__ void CoarseStart(
|
||||||
|
const float* coarse, const float* fine, float* out, float omega,
|
||||||
|
unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1,
|
||||||
|
unsigned int* counts)
|
||||||
|
{
|
||||||
|
unsigned int x, y; unsigned long k;
|
||||||
|
index_from_thread(x, y, k);
|
||||||
|
if (x >= NX || y >= NY) return;
|
||||||
|
const bool covered = x >= x0 && x < x1 && y >= y0 && y < y1;
|
||||||
|
float f[NQ];
|
||||||
|
for (unsigned int q = 0; q < NQ; ++q) {
|
||||||
|
const unsigned long s = q * 4ul * TOTAL_CELLS + 2ul * y * (2u * NX) + 2u * x;
|
||||||
|
f[q] = covered ? 0.25f * (fine[s] + fine[s+1] + fine[s+2u*NX] + fine[s+2u*NX+1])
|
||||||
|
: coarse[index_f(k, q)];
|
||||||
|
}
|
||||||
|
collide(f, omega);
|
||||||
|
for (int q = 0; q < NQ; ++q) if (!covered) health(f[q], counts);
|
||||||
|
stream_pull_store(k, f, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __global__ void Collide(
|
||||||
|
const float* in, float* out, const unsigned char* active, float omega,
|
||||||
|
unsigned int* counts)
|
||||||
|
{
|
||||||
|
unsigned int x, y; unsigned long k;
|
||||||
|
index_from_thread(x, y, k);
|
||||||
|
if (x >= NX || y >= NY) return;
|
||||||
|
float f[NQ];
|
||||||
|
if (active == nullptr || active[k]) {
|
||||||
|
for (int q = 0; q < NQ; ++q) f[q] = in[index_f(k, q)];
|
||||||
|
collide(f, omega);
|
||||||
|
if (active != nullptr) for (int q = 0; q < NQ; ++q) health(f[q], counts);
|
||||||
|
} else {
|
||||||
|
for (int q = 0; q < NQ; ++q) f[q] = NAN;
|
||||||
|
}
|
||||||
|
stream_pull_store(k, f, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __global__ void Pull(
|
||||||
|
const float* in, float* out, const unsigned char* active, unsigned int* counts)
|
||||||
|
{
|
||||||
|
unsigned int x, y; unsigned long k;
|
||||||
|
index_from_thread(x, y, k);
|
||||||
|
if (x >= NX || y >= NY) return;
|
||||||
|
float f[NQ];
|
||||||
|
if (active == nullptr || active[k]) {
|
||||||
|
unsigned long j[NQ];
|
||||||
|
compute_neighbors(x, y, j);
|
||||||
|
stream_pull_load(k, f, in, j);
|
||||||
|
if (active != nullptr) for (int q = 0; q < NQ; ++q) health(f[q], counts);
|
||||||
|
} else {
|
||||||
|
for (int q = 0; q < NQ; ++q) f[q] = NAN;
|
||||||
|
}
|
||||||
|
stream_pull_store(k, f, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __global__ void Interpolate(
|
||||||
|
const float* g0, const float* gp, const uint32_t* samples,
|
||||||
|
const uint32_t* origins, const int* sizes, const double* weights,
|
||||||
|
double* pre, float* h, unsigned int groups, unsigned int frozen,
|
||||||
|
unsigned int* counts)
|
||||||
|
{
|
||||||
|
unsigned int group = blockIdx.x * blockDim.x + threadIdx.x;
|
||||||
|
if (group >= groups) return;
|
||||||
|
const int size = sizes[group];
|
||||||
|
for (int child = 0; child < 4; ++child) {
|
||||||
|
double value = frozen ? (double)g0[origins[group]] : 0.0;
|
||||||
|
if (!frozen) for (int j = 0; j < size; ++j) {
|
||||||
|
const float* source = j < size/2 ? g0 : gp;
|
||||||
|
value += weights[(4u*group+child)*10u+j] * (double)source[samples[10u*group+j]];
|
||||||
|
}
|
||||||
|
const float stored = __double2float_rn(value);
|
||||||
|
pre[4u*group+child] = value;
|
||||||
|
h[4u*group+child] = stored;
|
||||||
|
if (!isfinite(value)) atomicAdd(counts, 1u);
|
||||||
|
if (value <= 0.0) atomicAdd(counts+1, 1u);
|
||||||
|
if (!isfinite(stored)) atomicAdd(counts+2, 1u);
|
||||||
|
if (stored <= 0.0f) atomicAdd(counts+3, 1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __global__ void Inject(
|
||||||
|
float* fine, const float* h, const uint32_t* rows, unsigned int count,
|
||||||
|
unsigned int omit_first)
|
||||||
|
{
|
||||||
|
unsigned int row = blockIdx.x * blockDim.x + threadIdx.x;
|
||||||
|
if (row >= count || (omit_first && row == 0)) return;
|
||||||
|
fine[rows[2u*row]] = h[rows[2u*row+1]];
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __global__ void Register(
|
||||||
|
const float* predicted, const float* fine, const float* h,
|
||||||
|
const uint32_t* targets, const uint32_t* sources, const int* times,
|
||||||
|
double* registers, unsigned int count, int substep, int mutation)
|
||||||
|
{
|
||||||
|
unsigned int row = blockIdx.x * blockDim.x + threadIdx.x;
|
||||||
|
if (row >= count) return;
|
||||||
|
double value = substep == 0 ? -(double)predicted[targets[row]] : registers[row];
|
||||||
|
for (int j = 0; j < 4; ++j) {
|
||||||
|
const unsigned int slot = 4u*row+j;
|
||||||
|
const int when = times[slot];
|
||||||
|
if (when != substep && !(substep == 0 && when == -1)) continue;
|
||||||
|
if ((mutation == 1 && when == -1) || (mutation == 2 && when == 0)
|
||||||
|
|| (mutation == 3 && when == 1)) continue;
|
||||||
|
value += 0.25 * (double)(when == -1 ? h[sources[slot]] : fine[sources[slot]]);
|
||||||
|
}
|
||||||
|
registers[row] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __global__ void ApplyRegisters(
|
||||||
|
float* predicted, const double* registers, const uint32_t* targets,
|
||||||
|
unsigned int count, unsigned int* counts)
|
||||||
|
{
|
||||||
|
unsigned int row = blockIdx.x * blockDim.x + threadIdx.x;
|
||||||
|
if (row >= count) return;
|
||||||
|
const unsigned int slot = targets[row];
|
||||||
|
predicted[slot] = __double2float_rn((double)predicted[slot] + registers[row]);
|
||||||
|
health(predicted[slot], counts);
|
||||||
|
}
|
||||||
@@ -0,0 +1,319 @@
|
|||||||
|
"""Test-only arrival-f GPU owner; CUDA compilation/execution requires admission."""
|
||||||
|
from dataclasses import replace
|
||||||
|
import hashlib
|
||||||
|
from numbers import Integral
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import spacetime_reference as ref
|
||||||
|
|
||||||
|
PINS = {"spacetime_reference.py": "1fe13242b9a41062a1227db4a6f9b695165aefab7f4c0b3b2adff0c9023552bf",
|
||||||
|
"cpu_reference.py": "bba2a06a9f6517b32079ffff15e4060d8c3b7ed35f16ca134e1877226c9e4e1e",
|
||||||
|
"../taylor_green/oracle.py": "83e4d7425d45538278e9fb181af450a36358bd9a5ed6be57ff611dd9ae5eb35b"}
|
||||||
|
|
||||||
|
|
||||||
|
def check_sources():
|
||||||
|
for name, expected in PINS.items():
|
||||||
|
if hashlib.sha256((Path(__file__).parent/name).read_bytes()).hexdigest() != expected:
|
||||||
|
raise RuntimeError(f"reference source changed: {name}")
|
||||||
|
|
||||||
|
|
||||||
|
def validate_config(config):
|
||||||
|
cfg = replace(config)
|
||||||
|
cfg.validate()
|
||||||
|
if (cfg.nx != cfg.ny or not 8 <= cfg.nx <= 64 or cfg.nz != 1
|
||||||
|
or cfg.collision != "SRT" or not cfg.is_d2q9
|
||||||
|
or cfg.streaming != "double_buffer" or cfg.store_precision != "FP32"
|
||||||
|
or cfg.data_type != "FP32" or cfg.ddf_shifting or cfg.les_enabled
|
||||||
|
or cfg.velocity != 0 or cfg.wall_slot_width or cfg.wall_normal_velocity):
|
||||||
|
raise ValueError("experiment requires periodic unforced square N8..64, unshifted FP32 D2Q9/SRT")
|
||||||
|
fine = replace(cfg, nx=2*cfg.nx, ny=2*cfg.ny, viscosity=2*cfg.viscosity)
|
||||||
|
fine.validate()
|
||||||
|
return cfg, fine
|
||||||
|
|
||||||
|
|
||||||
|
def pack_plan(plan):
|
||||||
|
"""Pack reviewed coordinate events; no production transfer builder imports."""
|
||||||
|
n, nf = plan.n, plan.nf
|
||||||
|
groups, receivers = plan.groups, plan.receivers
|
||||||
|
data = dict(samples=np.zeros((len(groups), 10), np.uint32),
|
||||||
|
origins=np.empty(len(groups), np.uint32), sizes=np.empty(len(groups), np.int32),
|
||||||
|
weights=np.zeros((len(groups), 4, 10), np.float64),
|
||||||
|
targets=(receivers[:, 0]*n*n+receivers[:, 1]).astype(np.uint32))
|
||||||
|
lookup = {tuple(row): i for i, row in enumerate(receivers)}
|
||||||
|
packets = [[] for _ in receivers]; incoming = [[], []]
|
||||||
|
for i, g in enumerate(groups):
|
||||||
|
size = len(g.samples)
|
||||||
|
if size not in (6, 10):
|
||||||
|
raise ValueError("unexpected interpolation stencil")
|
||||||
|
data['samples'][i, :size] = g.q*n*n+g.samples
|
||||||
|
data['origins'][i] = g.q*n*n+g.source
|
||||||
|
data['sizes'][i] = size
|
||||||
|
data['weights'][i, :, :size] = g.weights
|
||||||
|
for k, event in enumerate(g.events):
|
||||||
|
if event is None:
|
||||||
|
packets[lookup[(g.q, g.receiver)]].append((-1, 4*i+k))
|
||||||
|
else:
|
||||||
|
m, slot = event
|
||||||
|
incoming[m].append((g.q*nf*nf+slot, 4*i+k))
|
||||||
|
for m, outgoing in enumerate(plan.outgoing):
|
||||||
|
for q, source, target in outgoing:
|
||||||
|
packets[lookup[(int(q), int(target))]].append((m, int(q*nf*nf+source)))
|
||||||
|
if any(len(row) != 4 or len(set(row)) != 4 for row in packets):
|
||||||
|
raise ValueError("each receiver needs four distinct quarter-packets")
|
||||||
|
if len({packet for row in packets for packet in row}) != 4*len(receivers):
|
||||||
|
raise ValueError("packet has multiple receiver owners")
|
||||||
|
data['times'] = np.array([[t for t, _ in row] for row in packets], np.int32)
|
||||||
|
data['sources'] = np.array([[s for _, s in row] for row in packets], np.uint32)
|
||||||
|
for m, rows in enumerate(incoming):
|
||||||
|
data[f'incoming{m}'] = np.array(rows, np.uint32)
|
||||||
|
if len({slot for slot, _ in rows}) != len(rows):
|
||||||
|
raise ValueError("duplicate incoming writer")
|
||||||
|
return {key: np.ascontiguousarray(value) for key, value in data.items()}
|
||||||
|
|
||||||
|
|
||||||
|
def table_hash(data):
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
for key, value in sorted(data.items()):
|
||||||
|
digest.update(f"{key}:{value.dtype}:{value.shape}".encode()+value.tobytes())
|
||||||
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def rounding_ledger(plan, tables, before, after, g0, predicted, fine_phases, pre, h, registers):
|
||||||
|
"""Audit actual stored FP32 phases; never call a missing packet 'rounding'."""
|
||||||
|
maps, n = plan.maps, plan.n
|
||||||
|
f64 = lambda a: np.asarray(a, dtype=np.float64)
|
||||||
|
collision = (f64(g0[:, maps.coarse_active])-f64(before.coarse_f[:, maps.coarse_active])).sum(axis=1)
|
||||||
|
for f, g in fine_phases:
|
||||||
|
collision += .25*(f64(g[:, maps.fine_active])-f64(f[:, maps.fine_active])).sum(axis=1)
|
||||||
|
np.testing.assert_array_equal(h, pre.astype(np.float32))
|
||||||
|
origins = f64(g0).ravel()[tables['origins']]
|
||||||
|
np.testing.assert_allclose(pre.mean(axis=1), origins, rtol=0, atol=2e-14)
|
||||||
|
group = np.bincount(tables['origins']//(n*n), weights=f64(h).mean(axis=1)-origins, minlength=9)
|
||||||
|
packet = np.empty(tables['times'].shape, np.float64)
|
||||||
|
for when, source in ((-1, h), (0, fine_phases[0][1]), (1, fine_phases[1][1])):
|
||||||
|
mask = tables['times'] == when
|
||||||
|
packet[mask] = f64(source).ravel()[tables['sources'][mask]]
|
||||||
|
p = f64(predicted).ravel()[tables['targets']]
|
||||||
|
ideal = -p + .25*packet.sum(axis=1)
|
||||||
|
reg_error = registers-ideal
|
||||||
|
bound = 16*np.finfo(float).eps*(abs(p)+.25*abs(packet).sum(axis=1))
|
||||||
|
if np.any(abs(reg_error) > bound):
|
||||||
|
raise AssertionError("receiver packet register mismatch (not roundoff)")
|
||||||
|
actual = after.coarse_f.ravel()[tables['targets']]
|
||||||
|
np.testing.assert_array_equal(actual, (p+registers).astype(np.float32))
|
||||||
|
q = tables['targets']//(n*n)
|
||||||
|
store_error = np.bincount(q, weights=f64(actual)-(p+registers), minlength=9)
|
||||||
|
register_error = np.bincount(q, weights=reg_error, minlength=9)
|
||||||
|
# directional() must sum converted arrays, not accumulate in FP32.
|
||||||
|
total = lambda s: ref.directional(ref.cpu.State(f64(s.coarse_f), f64(s.fine_f)), maps)
|
||||||
|
raw = total(after)-total(before)-collision
|
||||||
|
unexplained = raw-group-store_error-register_error
|
||||||
|
limit = float(64*np.finfo(float).eps*total(before).sum())
|
||||||
|
np.testing.assert_allclose(unexplained, 0, rtol=0, atol=limit)
|
||||||
|
return dict(raw=raw.tolist(), physical_collision=collision.tolist(),
|
||||||
|
child_rounding=group.tolist(), receiver_rounding=store_error.tolist(),
|
||||||
|
register_rounding=register_error.tolist(), unexplained=unexplained.tolist(),
|
||||||
|
unexplained_bound=limit, minimum_pre=float(pre.min()), minimum_stored=float(h.min()))
|
||||||
|
|
||||||
|
|
||||||
|
class SpaceTimeGPU:
|
||||||
|
"""Caller-owned context, one stream, explicit synchronized arrival state."""
|
||||||
|
def __init__(self, config, bounds, *, context, mode='spacetime', identity=False):
|
||||||
|
check_sources()
|
||||||
|
self.configs = validate_config(config)
|
||||||
|
if mode not in ('spacetime', 'frozen') or type(identity) is not bool:
|
||||||
|
raise ValueError("unsupported interpolation or debug collision mode")
|
||||||
|
self.bounds = tuple(bounds)
|
||||||
|
if len(self.bounds) != 4 or any(isinstance(v, bool) or not isinstance(v, Integral) for v in self.bounds):
|
||||||
|
raise ValueError("rectangle bounds must be four integers")
|
||||||
|
self.plan = ref.Plan(config.nx, self.bounds)
|
||||||
|
self.tables = pack_plan(self.plan)
|
||||||
|
self.ctx, self.mode, self.identity = context, mode, identity
|
||||||
|
self.allocations, self.modules, self.build_metadata = [], [], []
|
||||||
|
self.status, self.step_count, self.device_bytes = 'new', 0, 0
|
||||||
|
self.health_counts = np.zeros(6, np.uint64)
|
||||||
|
import pycuda.driver as cuda
|
||||||
|
from CelerisLab.cuda import compiler_v2 as compiler
|
||||||
|
root = Path(__file__).resolve().parents[3]
|
||||||
|
if Path(compiler._KERNEL_DIR).resolve() != root/'src/CelerisLab/lbm/kernels':
|
||||||
|
raise RuntimeError("wrong production kernel checkout")
|
||||||
|
self.cuda = cuda
|
||||||
|
with context.activate():
|
||||||
|
self.stream = cuda.Stream()
|
||||||
|
try:
|
||||||
|
source = Path(__file__).with_suffix('.cu')
|
||||||
|
for cfg in self.configs:
|
||||||
|
build = compiler.generate_config(cfg)
|
||||||
|
try:
|
||||||
|
Path(build, source.name).write_bytes(source.read_bytes())
|
||||||
|
ptx = compiler.compile_kernel(context.sm_arch, source=source.name, build_dir=build)
|
||||||
|
self.modules.append(compiler.load_module(ptx))
|
||||||
|
import json
|
||||||
|
metadata = json.loads(Path(ptx+'.json').read_text())
|
||||||
|
metadata['test_entry_sha256'] = hashlib.sha256(source.read_bytes()).hexdigest()
|
||||||
|
self.build_metadata.append(metadata)
|
||||||
|
finally:
|
||||||
|
compiler.cleanup_build_dir(build)
|
||||||
|
self.device_tables = {key: self.upload(value) for key, value in self.tables.items()}
|
||||||
|
self.active = self.upload(self.plan.maps.fine_active.astype(np.uint8))
|
||||||
|
self.coarse = [self.allocate(9*config.nx**2*4) for _ in range(4)]
|
||||||
|
self.fine = [self.allocate(9*(2*config.nx)**2*4) for _ in range(3)]
|
||||||
|
self.pre = self.allocate(len(self.plan.groups)*4*8)
|
||||||
|
self.h = self.allocate(len(self.plan.groups)*4*4)
|
||||||
|
self.registers = self.allocate(len(self.plan.receivers)*8)
|
||||||
|
self.counts = self.allocate(6*4)
|
||||||
|
except BaseException:
|
||||||
|
try:
|
||||||
|
self.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
raise
|
||||||
|
|
||||||
|
def allocate(self, size):
|
||||||
|
pointer = self.cuda.mem_alloc(size)
|
||||||
|
self.allocations.append(pointer); self.device_bytes += size
|
||||||
|
return pointer
|
||||||
|
|
||||||
|
def upload(self, array):
|
||||||
|
pointer = self.allocate(array.nbytes)
|
||||||
|
self.cuda.memcpy_htod(pointer, array)
|
||||||
|
return pointer
|
||||||
|
|
||||||
|
def read(self, pointer, shape, dtype=np.float32):
|
||||||
|
self.stream.synchronize()
|
||||||
|
out = np.empty(shape, dtype)
|
||||||
|
self.cuda.memcpy_dtoh(out, pointer)
|
||||||
|
return out
|
||||||
|
|
||||||
|
def launch(self, level, name, *args, count=None):
|
||||||
|
cfg = self.configs[level]
|
||||||
|
nt = cfg.threads_per_block
|
||||||
|
grid = ((cfg.nx+nt-1)//nt, cfg.ny) if count is None else ((count+nt-1)//nt, 1)
|
||||||
|
self.modules[level].get_function(name)(*args, block=(nt,1,1), grid=grid, stream=self.stream)
|
||||||
|
|
||||||
|
def initialize(self, state):
|
||||||
|
if (self.status not in ('new', 'ready') or state.phase != 'arrival_f'
|
||||||
|
or isinstance(state.tick, bool) or not isinstance(state.tick, Integral) or state.tick != 0):
|
||||||
|
raise ValueError("initial synchronized arrival state with tick=0 required")
|
||||||
|
arrays = [np.array(a, dtype=np.float32, copy=True, order='C') for a in (state.coarse_f,state.fine_f)]
|
||||||
|
for a, mask in zip(arrays, (self.plan.maps.coarse_active,self.plan.maps.fine_active)):
|
||||||
|
if a.shape != (9,*mask.shape) or not np.isfinite(a[:,mask]).all() or (a[:,mask] <= 0).any():
|
||||||
|
raise ValueError("positive finite leaf populations and exact shapes required")
|
||||||
|
a[:,~mask] = np.nan
|
||||||
|
with self.ctx.activate():
|
||||||
|
try:
|
||||||
|
self.cuda.memcpy_htod(self.coarse[0], arrays[0])
|
||||||
|
self.cuda.memcpy_htod(self.fine[0], arrays[1])
|
||||||
|
except BaseException:
|
||||||
|
self.status = 'failed'
|
||||||
|
raise
|
||||||
|
self.status, self.step_count = 'ready', 0
|
||||||
|
self.health_counts.fill(0)
|
||||||
|
|
||||||
|
def download(self):
|
||||||
|
if self.status != 'ready':
|
||||||
|
raise RuntimeError(f"GPU owner is {self.status}")
|
||||||
|
try:
|
||||||
|
with self.ctx.activate():
|
||||||
|
arrays = [self.read(self.coarse[0], (9,self.plan.n,self.plan.n)),
|
||||||
|
self.read(self.fine[0], (9,self.plan.nf,self.plan.nf))]
|
||||||
|
except BaseException:
|
||||||
|
self.status = 'failed'
|
||||||
|
raise
|
||||||
|
for a, mask in zip(arrays, (self.plan.maps.coarse_active,self.plan.maps.fine_active)):
|
||||||
|
a[:,~mask] = np.nan
|
||||||
|
return ref.cpu.State(*arrays, tick=2*self.step_count)
|
||||||
|
|
||||||
|
def step(self, *, mutation=0, audit=True):
|
||||||
|
"""One interval; audit=False skips only host ledger snapshots, never health checks."""
|
||||||
|
if (self.status != 'ready' or type(mutation) is not int or mutation not in range(5)
|
||||||
|
or type(audit) is not bool or (mutation and not audit)):
|
||||||
|
raise RuntimeError("ready owner and known test mutation required")
|
||||||
|
before = self.download() if audit else None
|
||||||
|
n, nf, t = self.plan.n, self.plan.nf, self.device_tables
|
||||||
|
ng, nr = len(self.plan.groups), len(self.plan.receivers)
|
||||||
|
u32, null = np.uint32, np.uintp(0)
|
||||||
|
omega = [np.float32(0 if self.identity else cfg.omega) for cfg in self.configs]
|
||||||
|
with self.ctx.activate():
|
||||||
|
try:
|
||||||
|
self.status = 'advancing'
|
||||||
|
self.cuda.memset_d32_async(self.counts, 0, 6, self.stream)
|
||||||
|
fc, g0, predicted, gp = self.coarse
|
||||||
|
self.launch(0, 'CoarseStart', fc,self.fine[0],g0,omega[0],
|
||||||
|
*(u32(v) for v in self.bounds),self.counts)
|
||||||
|
self.launch(0, 'Pull', g0,predicted,null,self.counts)
|
||||||
|
self.launch(0, 'Collide', predicted,gp,null,omega[0],self.counts)
|
||||||
|
self.launch(0, 'Interpolate', g0,gp,t['samples'],t['origins'],t['sizes'],t['weights'],
|
||||||
|
self.pre,self.h,u32(ng),u32(self.mode=='frozen'),self.counts,count=ng)
|
||||||
|
if audit:
|
||||||
|
coarse_g = self.read(g0,(9,n,n)); prediction = self.read(predicted,(9,n,n))
|
||||||
|
fine_phases = []
|
||||||
|
for m in (0,1):
|
||||||
|
f, out, g = self.fine
|
||||||
|
if audit:
|
||||||
|
old_f = self.read(f,(9,nf,nf))
|
||||||
|
self.launch(1, 'Collide', f,g,self.active,omega[1],self.counts)
|
||||||
|
if audit:
|
||||||
|
fine_phases.append((old_f,self.read(g,(9,nf,nf))))
|
||||||
|
self.launch(0, 'Register', predicted,g,self.h,t['targets'],t['sources'],t['times'],
|
||||||
|
self.registers,u32(nr),np.int32(m),np.int32(mutation),count=nr)
|
||||||
|
rows = self.tables[f'incoming{m}']
|
||||||
|
self.launch(1, 'Inject', g,self.h,t[f'incoming{m}'],u32(len(rows)),u32(mutation==4),count=len(rows))
|
||||||
|
self.launch(1, 'Pull', g,out,self.active,self.counts)
|
||||||
|
self.fine[0], self.fine[1] = out, f
|
||||||
|
self.launch(0, 'ApplyRegisters', predicted,self.registers,t['targets'],u32(nr),self.counts,count=nr)
|
||||||
|
counts = self.read(self.counts,(6,),np.uint32)
|
||||||
|
self.health_counts += counts.astype(np.uint64)
|
||||||
|
if counts.any():
|
||||||
|
raise AssertionError(f"boundary/leaf health failed: {counts.tolist()}")
|
||||||
|
ledger = dict(boundary_budget_status='not_measured',unexplained=None)
|
||||||
|
if audit:
|
||||||
|
coarse_after = self.read(predicted,(9,n,n))
|
||||||
|
coarse_after[:,~self.plan.maps.coarse_active] = np.nan
|
||||||
|
after = ref.cpu.State(coarse_after,self.read(self.fine[0],(9,nf,nf)),tick=2*(self.step_count+1))
|
||||||
|
ledger = rounding_ledger(self.plan,self.tables,before,after,coarse_g,prediction,fine_phases,
|
||||||
|
self.read(self.pre,(ng,4),np.float64),self.read(self.h,(ng,4)),
|
||||||
|
self.read(self.registers,(nr,),np.float64))
|
||||||
|
ledger['boundary_budget_status'] = 'measured'
|
||||||
|
ledger['health_counts'] = counts.tolist()
|
||||||
|
self.coarse[0], self.coarse[2] = predicted, fc
|
||||||
|
self.step_count += 1
|
||||||
|
self.status = 'ready'
|
||||||
|
return ledger
|
||||||
|
except BaseException:
|
||||||
|
self.status = 'failed'
|
||||||
|
raise
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.status == 'closed':
|
||||||
|
return
|
||||||
|
with self.ctx.activate():
|
||||||
|
error = None
|
||||||
|
try:
|
||||||
|
self.stream.synchronize()
|
||||||
|
except Exception as exc:
|
||||||
|
error = exc
|
||||||
|
failed = []
|
||||||
|
for pointer in self.allocations:
|
||||||
|
try:
|
||||||
|
pointer.free()
|
||||||
|
except Exception as exc:
|
||||||
|
error = error or exc
|
||||||
|
failed.append(pointer)
|
||||||
|
self.allocations = failed
|
||||||
|
self.status = 'cleanup_failed' if failed else 'closed'
|
||||||
|
if not failed:
|
||||||
|
self.modules.clear()
|
||||||
|
if error:
|
||||||
|
raise error
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, kind, value, traceback):
|
||||||
|
try:
|
||||||
|
self.close()
|
||||||
|
except Exception:
|
||||||
|
if kind is None:
|
||||||
|
raise
|
||||||
@@ -0,0 +1,334 @@
|
|||||||
|
"""Experimental FP64 BVP coupling: one periodic rectangle, D2Q9, ratio two.
|
||||||
|
|
||||||
|
Guzik et al., https://www.osti.gov/servlets/purl/1226215, sections 3.2--3.5.
|
||||||
|
Coordinate-generated stream events; CPUREF collision only, no production imports.
|
||||||
|
This is a mathematical prototype, not a certified accuracy implementation.
|
||||||
|
"""
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from functools import lru_cache
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import resource
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import cpu_reference as cpu
|
||||||
|
|
||||||
|
|
||||||
|
class Spec(cpu.Spec):
|
||||||
|
@property
|
||||||
|
def n_fine(self):
|
||||||
|
return 2 * self.n_coarse
|
||||||
|
|
||||||
|
|
||||||
|
def geometry(n, bounds):
|
||||||
|
x0, y0, x1, y1 = bounds
|
||||||
|
if not (2 <= x0 < x1 <= n - 2 and 2 <= y0 < y1 <= n - 2):
|
||||||
|
raise ValueError("one interior rectangle with two coarse cells of clearance required")
|
||||||
|
y, x = np.indices((n, n))
|
||||||
|
covered = (x >= x0) & (x < x1) & (y >= y0) & (y < y1)
|
||||||
|
y, x = np.indices((2*n, 2*n))
|
||||||
|
active = (x >= 2*x0) & (x < 2*x1) & (y >= 2*y0) & (y < 2*y1)
|
||||||
|
inner = (x >= 2*x0-2) & (x < 2*x1+2) & (y >= 2*y0-2) & (y < 2*y1+2) & ~active
|
||||||
|
rows, links = [], []
|
||||||
|
for ky, kx in zip(*np.nonzero(~covered)):
|
||||||
|
for q, (cy, cx) in enumerate(zip(cpu.CY, cpu.CX)):
|
||||||
|
if any(active[2*ky+dy-cy, 2*kx+dx-cx]
|
||||||
|
for dy in (0, 1) for dx in (0, 1)
|
||||||
|
if 0 <= 2*ky+dy-cy < 2*n and 0 <= 2*kx+dx-cx < 2*n):
|
||||||
|
rows.append((q, ky, kx))
|
||||||
|
sy, sx = (ky-cy) % n, (kx-cx) % n
|
||||||
|
if not covered[sy, sx]:
|
||||||
|
links.append(cpu.CornerLink(f"{kx}_{ky}_{q}", q, (sx, sy), (kx, ky)))
|
||||||
|
kind = np.where(active, 0, np.where(inner, 1, 2))
|
||||||
|
return cpu.Maps(~covered, covered, active, inner, kind == 2, kind,
|
||||||
|
np.arange(2*n)//2, (np.arange(2*n)+.5)/2,
|
||||||
|
np.array(rows, dtype=int), tuple(links))
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(None)
|
||||||
|
def interpolation(kind, points):
|
||||||
|
"""Return data coordinates, evaluation matrix, and constrained coefficient map."""
|
||||||
|
if kind == "face":
|
||||||
|
samples = np.array([(s, t) for t in (0., 1.) for s in (-1., 0., 1.)])
|
||||||
|
a = np.array([[1, s, t, s*t] for s, t in samples])
|
||||||
|
e = np.array([[1, s, t, s*t] for s, t in points])
|
||||||
|
b = e.mean(axis=0, keepdims=True)
|
||||||
|
d = np.zeros((1, 6)); d[0, 1] = 1
|
||||||
|
else:
|
||||||
|
cross = ((0, 0), (-1, 0), (1, 0), (0, -1), (0, 1))
|
||||||
|
samples = np.array([(x, y, t) for t in (0., 1.) for x, y in cross])
|
||||||
|
a = np.array([[1, x, y, t] for x, y, t in samples])
|
||||||
|
e = np.array([[1, x, y, t] for x, y, t in points])
|
||||||
|
b = np.stack((e.mean(axis=0), [0, 0, 0, 1]))
|
||||||
|
d = np.zeros((2, 10)); d[0, 0] = 1; d[1, 0] = -1; d[1, 5] = 1
|
||||||
|
kkt = np.block([[a.T @ a, b.T], [b, np.zeros((len(b), len(b)))]])
|
||||||
|
coeff = np.linalg.solve(kkt, np.vstack((a.T, d)))[:4]
|
||||||
|
if not np.allclose(b @ coeff, d, rtol=0, atol=2e-14):
|
||||||
|
raise AssertionError("invalid constrained interpolation matrix")
|
||||||
|
return samples, a, e, coeff
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Group:
|
||||||
|
q: int
|
||||||
|
source: int
|
||||||
|
receiver: int
|
||||||
|
kind: str
|
||||||
|
points: tuple
|
||||||
|
samples: np.ndarray
|
||||||
|
weights: np.ndarray
|
||||||
|
events: tuple # (substep, fine ghost slot), or None for a leftover
|
||||||
|
|
||||||
|
|
||||||
|
class Plan:
|
||||||
|
def __init__(self, n, bounds):
|
||||||
|
self.n, self.nf = n, 2*n
|
||||||
|
self.maps = geometry(n, bounds)
|
||||||
|
active = self.maps.fine_active
|
||||||
|
lo, hi = np.array(bounds[1::-1]), np.array(bounds[3:1:-1])
|
||||||
|
self.groups = []
|
||||||
|
for iy, ix in zip(*np.nonzero(self.maps.coarse_active)):
|
||||||
|
origin = np.array((iy, ix))
|
||||||
|
for q in range(1, 9):
|
||||||
|
c = np.array((cpu.CY[q], cpu.CX[q]))
|
||||||
|
starts = [2*origin + (dy, dx) for dy in (0, 1) for dx in (0, 1)]
|
||||||
|
events = []
|
||||||
|
for p in starts:
|
||||||
|
event = None
|
||||||
|
for m in (0, 1):
|
||||||
|
old, new = p+m*c, p+(m+1)*c
|
||||||
|
inside = lambda z: bool(np.all(z >= 0) and np.all(z < 2*n) and active[tuple(z)])
|
||||||
|
if not inside(old) and inside(new):
|
||||||
|
event = (m, int(old[0]*2*n+old[1]))
|
||||||
|
break
|
||||||
|
events.append(event)
|
||||||
|
if all(event is None for event in events):
|
||||||
|
continue
|
||||||
|
axes = [j for j in range(2) if origin[j] < lo[j] or origin[j] >= hi[j]]
|
||||||
|
kind = "corner" if len(axes) == 2 else "face"
|
||||||
|
points = []
|
||||||
|
for p in starts:
|
||||||
|
x = (p+.5)/2
|
||||||
|
times = [(float(lo[j] if c[j] > 0 else hi[j])-x[j])/c[j] for j in axes]
|
||||||
|
time = max(times)
|
||||||
|
offset = x+c*time-(origin+.5+c*.5)
|
||||||
|
points.append((float(offset[1]), float(offset[0]), float(time-.5))
|
||||||
|
if kind == "corner" else (float(offset[1-axes[0]]), float(time-.5)))
|
||||||
|
points = tuple(points)
|
||||||
|
samples, _, e, coeff = interpolation(kind, points)
|
||||||
|
indices = []
|
||||||
|
for row in samples:
|
||||||
|
shift = np.array((row[1], row[0]), dtype=int) if kind == "corner" else np.eye(2, dtype=int)[1-axes[0]]*int(row[0])
|
||||||
|
pos = (origin+shift) % n
|
||||||
|
indices.append(int(pos[0]*n+pos[1]))
|
||||||
|
target = (origin+c) % n
|
||||||
|
self.groups.append(Group(q, int(iy*n+ix), int(target[0]*n+target[1]), kind,
|
||||||
|
points, np.array(indices), e @ coeff, tuple(events)))
|
||||||
|
self.outgoing = []
|
||||||
|
# m is zero-based: a substep-0 exit travels two fine spacings by
|
||||||
|
# synchronization; a substep-1 exit travels one.
|
||||||
|
for m in (0, 1):
|
||||||
|
records = []
|
||||||
|
for q in range(1, 9):
|
||||||
|
c = np.array((cpu.CY[q], cpu.CX[q]))
|
||||||
|
for y, x in zip(*np.nonzero(active)):
|
||||||
|
p = np.array((y, x)); endpoint = p+c
|
||||||
|
if not active[tuple(endpoint)]:
|
||||||
|
target = (p+(2-m)*c)//2
|
||||||
|
assert self.maps.coarse_active[tuple(target)]
|
||||||
|
records.append((q, int(y*2*n+x), int(target[0]*n+target[1])))
|
||||||
|
self.outgoing.append(np.array(records, dtype=int))
|
||||||
|
incoming = [(m, g.q, slot) for g in self.groups for event in g.events
|
||||||
|
if event is not None for m, slot in [event]]
|
||||||
|
assert len(incoming) == len(set(incoming)), "duplicate incoming writer"
|
||||||
|
expected = {(m, int(q), int((y-cpu.CY[q])*2*n+x-cpu.CX[q]))
|
||||||
|
for m in (0, 1) for q in range(1, 9)
|
||||||
|
for y, x in zip(*np.nonzero(active)) if not active[y-cpu.CY[q], x-cpu.CX[q]]}
|
||||||
|
assert set(incoming) == expected, "incoming coverage mismatch"
|
||||||
|
receivers = {(int(q), int(target)) for out in self.outgoing for q, _, target in out}
|
||||||
|
receivers |= {(g.q, g.receiver) for g in self.groups if None in g.events}
|
||||||
|
assert receivers == {(int(q), int(y*n+x)) for q, y, x in self.maps.coalesce}
|
||||||
|
self.receivers = np.array(sorted(receivers), dtype=int)
|
||||||
|
|
||||||
|
|
||||||
|
def directional(state, maps):
|
||||||
|
return state.coarse_f[:, maps.coarse_active].sum(axis=1) + .25*state.fine_f[:, maps.fine_active].sum(axis=1)
|
||||||
|
|
||||||
|
|
||||||
|
def advance(spec, plan, state, mode="spacetime", mutation=None):
|
||||||
|
"""One arrival-to-arrival interval. 'frozen' disables space AND time variation."""
|
||||||
|
if mode not in ("frozen", "spacetime"):
|
||||||
|
raise ValueError(mode)
|
||||||
|
n, nf, maps = plan.n, plan.nf, plan.maps
|
||||||
|
if state.phase != "arrival_f" or state.tick % 2:
|
||||||
|
raise ValueError("synchronized arrival state required")
|
||||||
|
fc, ff = state.coarse_f.copy(), state.fine_f.copy()
|
||||||
|
covered_mean = ff.reshape(9, n, 2, n, 2).mean(axis=(2, 4))
|
||||||
|
fc[:, maps.coarse_covered] = covered_mean[:, maps.coarse_covered]
|
||||||
|
all_cells = np.ones((n, n), dtype=bool)
|
||||||
|
def collide(f, mask, tau):
|
||||||
|
return cpu._collide(spec, f, np.isfinite(f), tau, mask, np.zeros(mask.shape, dtype=int))
|
||||||
|
gc = collide(fc, all_cells, spec.tau_coarse)
|
||||||
|
collision = (gc[:, maps.coarse_active]-fc[:, maps.coarse_active]).sum(axis=1)
|
||||||
|
predicted = cpu._stream_periodic(gc)
|
||||||
|
gp = collide(predicted, all_cells, spec.tau_coarse) if mode == "spacetime" else gc
|
||||||
|
registers = np.zeros((9, n*n))
|
||||||
|
q, target = plan.receivers.T
|
||||||
|
registers[q, target] = -predicted.reshape(9, -1)[q, target]
|
||||||
|
incoming = [[], []]
|
||||||
|
group_error = 0.
|
||||||
|
min_boundary = float("inf")
|
||||||
|
negative_boundary = nonfinite_boundary = 0
|
||||||
|
dropped = False
|
||||||
|
for group in plan.groups:
|
||||||
|
q = group.q
|
||||||
|
count = len(group.samples)//2
|
||||||
|
data = np.concatenate((gc.reshape(9, -1)[q, group.samples[:count]], gp.reshape(9, -1)[q, group.samples[count:]]))
|
||||||
|
value = (group.weights @ data if mode == "spacetime"
|
||||||
|
else np.full(4, gc.reshape(9, -1)[q, group.source]))
|
||||||
|
min_boundary = min(min_boundary, float(value.min()))
|
||||||
|
negative_boundary += int(np.count_nonzero(value < 0))
|
||||||
|
nonfinite_boundary += int(np.count_nonzero(~np.isfinite(value)))
|
||||||
|
group_error = max(group_error, abs(value.mean()-gc.reshape(9, -1)[q, group.source]))
|
||||||
|
for k, event in enumerate(group.events):
|
||||||
|
if event is None:
|
||||||
|
if mutation == "omit_leftover" and not dropped:
|
||||||
|
dropped = True
|
||||||
|
else:
|
||||||
|
registers[q, group.receiver] += .25*value[k]
|
||||||
|
else:
|
||||||
|
m, slot = event
|
||||||
|
incoming[m].append((q, slot, value[k]))
|
||||||
|
for m in (0, 1):
|
||||||
|
gf = collide(ff, maps.fine_active, spec.tau_fine)
|
||||||
|
collision += .25*(gf[:, maps.fine_active]-ff[:, maps.fine_active]).sum(axis=1)
|
||||||
|
out = plan.outgoing[m]
|
||||||
|
if mutation != f"omit_outgoing_{m}":
|
||||||
|
np.add.at(registers, (out[:, 0], out[:, 2]), .25*gf.reshape(9, -1)[out[:, 0], out[:, 1]])
|
||||||
|
for q, slot, value in incoming[m]:
|
||||||
|
gf.reshape(9, -1)[q, slot] = value
|
||||||
|
fresh = np.full_like(ff, np.nan)
|
||||||
|
for q in range(9):
|
||||||
|
moved = cpu._shift(gf[q], int(cpu.CY[q]), int(cpu.CX[q]), np.nan)
|
||||||
|
fresh[q, maps.fine_active] = moved[maps.fine_active]
|
||||||
|
if not np.isfinite(fresh[:, maps.fine_active]).all():
|
||||||
|
raise AssertionError("invalid fine incoming population")
|
||||||
|
ff = fresh
|
||||||
|
final_c = predicted + registers.reshape(9, n, n)
|
||||||
|
final_c[:, maps.coarse_covered] = np.nan
|
||||||
|
final = cpu.State(final_c, ff, tick=state.tick+2)
|
||||||
|
residual = directional(final, maps)-directional(state, maps)-collision
|
||||||
|
minimum = min(float(final_c[:, maps.coarse_active].min()), float(ff[:, maps.fine_active].min()))
|
||||||
|
return final, dict(directional_residual=residual, collision=collision,
|
||||||
|
group_error=group_error, min_boundary=min_boundary, min_population=minimum,
|
||||||
|
negative_boundary_count=negative_boundary, nonfinite_boundary_count=nonfinite_boundary)
|
||||||
|
|
||||||
|
|
||||||
|
def write_receipt(path, result):
|
||||||
|
"""Normalize NumPy scalars at the JSON boundary; reject other unknown types."""
|
||||||
|
def scalar(value):
|
||||||
|
if isinstance(value, np.generic):
|
||||||
|
return value.item()
|
||||||
|
raise TypeError(f"Object of type {type(value).__name__} is not JSON serializable")
|
||||||
|
path.write_text(json.dumps(result, indent=2, allow_nan=False, default=scalar)+"\n")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--n64", action="store_true", help="explicitly run the frozen 1024-interval experiment")
|
||||||
|
parser.add_argument("--output", type=Path, required=True)
|
||||||
|
parser.add_argument("--max-seconds",type=float,default=180.,help="wall-time cap, including plan generation")
|
||||||
|
parser.add_argument("--max-rss-mib",type=float,default=256.,help="Linux peak-RSS screening cap")
|
||||||
|
args = parser.parse_args()
|
||||||
|
if not args.n64:
|
||||||
|
parser.error("full trajectory requires --n64")
|
||||||
|
if args.output.exists():
|
||||||
|
parser.error("output exists; preserve prior evidence and choose a new path")
|
||||||
|
if not (np.isfinite(args.max_seconds) and args.max_seconds>0 and np.isfinite(args.max_rss_mib) and args.max_rss_mib>0):
|
||||||
|
parser.error("positive finite resource caps required")
|
||||||
|
started = time.monotonic()
|
||||||
|
sys.path.insert(0, str(Path(__file__).parents[1]/"taylor_green"))
|
||||||
|
import oracle as tg
|
||||||
|
plan = Plan(64, (8, 8, 56, 48))
|
||||||
|
spec = Spec(n_coarse=64, patch_lo=8, halo=16, tau_coarse=.5576, tau_fine=.6152, collision="srt")
|
||||||
|
arrays = [tg.initial((64,64), 0, 64, .0192), tg.initial((128,128), 1, 64, .0192)]
|
||||||
|
for a, mask in zip(arrays, (plan.maps.coarse_active, plan.maps.fine_active)):
|
||||||
|
a[:, ~mask] = np.nan
|
||||||
|
initial = cpu.State(*arrays)
|
||||||
|
mass0 = tg.metrics(arrays, (plan.maps.coarse_active, plan.maps.fine_active), 0, 64, .0192)["mass"]
|
||||||
|
metrics = ("velocity_l2", "pressure_l2", "energy_relative")
|
||||||
|
frozen_baseline = dict(zip(metrics, (.01131134574353476, .03592961319244149, .012514764591008386)))
|
||||||
|
budget_bound = float(64*np.finfo(float).eps*mass0)
|
||||||
|
root = Path(__file__).resolve().parents[3]
|
||||||
|
source = dict(commit=subprocess.check_output(["git", "rev-parse", "HEAD"],cwd=root,text=True).strip(),
|
||||||
|
dirty=bool(subprocess.check_output(["git","status","--porcelain"],cwd=root,text=True)),
|
||||||
|
hashes={p.name:hashlib.sha256(p.read_bytes()).hexdigest()
|
||||||
|
for p in (Path(__file__),Path(cpu.__file__),Path(tg.__file__))},numpy=np.__version__)
|
||||||
|
result = dict(scope="experimental CPU FP64; no GPU/accuracy certification", source=source,
|
||||||
|
screen=dict(velocity_factor=.8, pressure_factor=1., energy_factor=1.,
|
||||||
|
directional_step_bound=budget_bound, mass_relative=1e-11,
|
||||||
|
momentum_absolute=1e-9, baseline_metric_atol=1e-10),
|
||||||
|
limits=dict(seconds=args.max_seconds,rss_mib=args.max_rss_mib),runs=[],completed=False)
|
||||||
|
def save():
|
||||||
|
result["resources"] = dict(seconds=time.monotonic()-started,peak_rss_mib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024)
|
||||||
|
write_receipt(args.output, result)
|
||||||
|
save()
|
||||||
|
try:
|
||||||
|
for mode in ("constant_ivp", "spacetime"):
|
||||||
|
measured = mode == "spacetime"
|
||||||
|
state = initial; record = dict(mode=mode,rows=[],
|
||||||
|
boundary_budget_status="measured" if measured else "not_measured",
|
||||||
|
max_directional_residual=0. if measured else None,
|
||||||
|
minimum_boundary=None,negative_boundary_count=0 if measured else None,
|
||||||
|
nonfinite_boundary_count=0 if measured else None)
|
||||||
|
result["runs"].append(record)
|
||||||
|
for k in range(1, 1025):
|
||||||
|
if time.monotonic()-started>args.max_seconds or resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024>args.max_rss_mib:
|
||||||
|
raise RuntimeError("experiment resource cap exceeded")
|
||||||
|
if mode == "constant_ivp":
|
||||||
|
state,_ = cpu.advance_coarse_once(spec,plan.maps,state)
|
||||||
|
else:
|
||||||
|
state,diagnostic = advance(spec,plan,state)
|
||||||
|
error = float(np.max(np.abs(diagnostic["directional_residual"])))
|
||||||
|
record["max_directional_residual"] = max(record["max_directional_residual"],error)
|
||||||
|
if np.isfinite(diagnostic["min_boundary"]):
|
||||||
|
record["minimum_boundary"] = (diagnostic["min_boundary"] if record["minimum_boundary"] is None else min(record["minimum_boundary"],diagnostic["min_boundary"]))
|
||||||
|
for name in ("negative_boundary_count","nonfinite_boundary_count"):
|
||||||
|
record[name] += diagnostic[name]
|
||||||
|
if (not np.isfinite(error) or error>budget_bound or diagnostic["group_error"]>2e-14
|
||||||
|
or diagnostic["negative_boundary_count"] or diagnostic["nonfinite_boundary_count"]
|
||||||
|
or not np.isfinite(diagnostic["min_boundary"]) or diagnostic["min_boundary"]<=0
|
||||||
|
or not np.isfinite(diagnostic["min_population"]) or diagnostic["min_population"]<=0):
|
||||||
|
record["failed_diagnostic"] = {name: repr(value) for name,value in diagnostic.items()}
|
||||||
|
raise AssertionError("candidate directional/health invariant failed")
|
||||||
|
if k in (256,512,768,1024):
|
||||||
|
row = tg.metrics((state.coarse_f,state.fine_f),(plan.maps.coarse_active,plan.maps.fine_active),k,64,.0192,mass0)
|
||||||
|
row["momentum_change"] = (cpu.MOMENTS.T@(directional(state,plan.maps)-directional(initial,plan.maps)))[1:].tolist()
|
||||||
|
record["rows"].append(row)
|
||||||
|
save(); print(mode,k,json.dumps(row),flush=True)
|
||||||
|
record["worst"] = {key:max(row[key] for row in record["rows"]) for key in metrics}
|
||||||
|
if mode == "constant_ivp":
|
||||||
|
for key,value in frozen_baseline.items():
|
||||||
|
if abs(record["worst"][key]-value)>1e-10:
|
||||||
|
raise AssertionError(f"frozen baseline mismatch: {key}")
|
||||||
|
baseline,candidate = result["runs"]
|
||||||
|
result["checks"] = {key:candidate["worst"][key]<=factor*baseline["worst"][key]
|
||||||
|
for key,factor in zip(metrics,(.8,1.,1.))}
|
||||||
|
result["checks"]["mass_momentum"] = all(row["mass_relative"]<=1e-11 and max(map(abs,row["momentum_change"]))<=1e-9 for row in candidate["rows"])
|
||||||
|
result["completed"] = True
|
||||||
|
result["experimental_pass"] = all(result["checks"].values())
|
||||||
|
save()
|
||||||
|
return 0 if result["experimental_pass"] else 1
|
||||||
|
except Exception as exc:
|
||||||
|
result["failure"] = dict(mode=mode,step=k,error=repr(exc))
|
||||||
|
save()
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main())
|
||||||
@@ -7,6 +7,7 @@ At most eight coarse steps per case. No files, plots or flow arrays are saved.
|
|||||||
import hashlib
|
import hashlib
|
||||||
import importlib.util
|
import importlib.util
|
||||||
from contextlib import nullcontext
|
from contextlib import nullcontext
|
||||||
|
from dataclasses import replace
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import resource
|
import resource
|
||||||
import sys
|
import sys
|
||||||
@@ -21,7 +22,7 @@ import CelerisLab
|
|||||||
from CelerisLab.config import LBMConfig
|
from CelerisLab.config import LBMConfig
|
||||||
from CelerisLab.cuda import compiler_v2 as compiler
|
from CelerisLab.cuda import compiler_v2 as compiler
|
||||||
from CelerisLab.cuda.context import CudaContext
|
from CelerisLab.cuda.context import CudaContext
|
||||||
from CelerisLab.lbm.refinement_stepper import PeriodicPatchStepper
|
from CelerisLab.lbm.refinement_stepper import FixedPatchStepper, PeriodicPatchStepper
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[3]
|
ROOT = Path(__file__).resolve().parents[3]
|
||||||
POP_ATOL = 3e-6
|
POP_ATOL = 3e-6
|
||||||
@@ -60,6 +61,69 @@ def global_array(module, name, shape):
|
|||||||
|
|
||||||
|
|
||||||
class CoupledGPU(unittest.TestCase):
|
class CoupledGPU(unittest.TestCase):
|
||||||
|
def test_actual_tg_rates_one_interval(self):
|
||||||
|
"""Algebraic rate/phase check, not a new physical Taylor--Green benchmark.
|
||||||
|
|
||||||
|
The N64/Re100 TG rates are exercised on the existing small patch with
|
||||||
|
a nonequilibrium state. One interval checks g=C(f), including the
|
||||||
|
shifted blocked path; no accuracy gate or production source changes.
|
||||||
|
"""
|
||||||
|
self.assertEqual(Path(CelerisLab.__file__).resolve(), ROOT / "src/CelerisLab/__init__.py")
|
||||||
|
self.assertEqual(Path(compiler._KERNEL_DIR).resolve(), ROOT / "src/CelerisLab/lbm/kernels")
|
||||||
|
spec = replace(ref.make_spec(collision="srt"),
|
||||||
|
tau_coarse=.5576, tau_fine=.6152)
|
||||||
|
maps = ref.build_maps(spec)
|
||||||
|
state = ref.make_state(spec, velocity=(.03, -.02))
|
||||||
|
rng = np.random.default_rng(1)
|
||||||
|
state = ref.State(*(a * (1 + 1e-3 * rng.standard_normal(a.shape))
|
||||||
|
for a in (state.coarse_f, state.fine_f)))
|
||||||
|
initial = postcollision(state, spec, maps)
|
||||||
|
next_state, _ = ref.advance_coarse_once(spec, maps, state)
|
||||||
|
expected = postcollision(next_state, spec, maps)
|
||||||
|
arrivals = (next_state.coarse_f, next_state.fine_f)
|
||||||
|
|
||||||
|
cases = (("dense_unshifted", False, {}),
|
||||||
|
("blocked_shifted", True,
|
||||||
|
dict(base_block=(4, 4), fine_block=(6, 6))))
|
||||||
|
with CudaContext(0) as context:
|
||||||
|
for label, shifted, storage in cases:
|
||||||
|
with self.subTest(storage=label):
|
||||||
|
cfg = LBMConfig(nx=16, ny=16, viscosity=.0192,
|
||||||
|
ddf_shifting=shifted)
|
||||||
|
with FixedPatchStepper(cfg, (4, 4, 12, 12), context=context,
|
||||||
|
**storage) as backend:
|
||||||
|
self.assertAlmostEqual(backend.patch.tau_coarse, spec.tau_coarse)
|
||||||
|
self.assertAlmostEqual(backend.patch.tau_fine, spec.tau_fine)
|
||||||
|
self.assertEqual(tuple(level.shape for level in backend._levels),
|
||||||
|
((9, 16, 16), (9, 24, 24)))
|
||||||
|
# Physical FP64 g is encoded by initialize before FP32 rounding.
|
||||||
|
backend.initialize(*initial)
|
||||||
|
before = totals(backend.download(), maps)
|
||||||
|
backend.step(1)
|
||||||
|
actual = backend.download()
|
||||||
|
self.assertEqual(backend.step_count, 1)
|
||||||
|
backend.patch.check_synchronization(
|
||||||
|
1, next_state.tick, phase="postcollision_g")
|
||||||
|
for got, want, arrival in zip(actual, expected, arrivals):
|
||||||
|
np.testing.assert_array_equal(np.isnan(got), np.isnan(want))
|
||||||
|
np.testing.assert_allclose(got, want, rtol=0, atol=POP_ATOL,
|
||||||
|
equal_nan=True)
|
||||||
|
# A raw arrival-f comparison must fail on BOTH levels.
|
||||||
|
# Equilibrium-only data would make this control vacuous.
|
||||||
|
with self.assertRaises(AssertionError):
|
||||||
|
np.testing.assert_allclose(got, arrival, rtol=0,
|
||||||
|
atol=POP_ATOL, equal_nan=True)
|
||||||
|
np.testing.assert_allclose(totals(actual, maps), before,
|
||||||
|
rtol=0, atol=MOMENT_ATOL)
|
||||||
|
np.testing.assert_allclose(totals(actual, maps),
|
||||||
|
totals(expected, maps),
|
||||||
|
rtol=0, atol=MOMENT_ATOL)
|
||||||
|
error = max(float(np.nanmax(np.abs(a - e)))
|
||||||
|
for a, e in zip(actual, expected))
|
||||||
|
print(f"actual-TG-rate algebraic check: {label} steps=1 "
|
||||||
|
f"tau=.5576/.6152 max_population={error:.9g}; "
|
||||||
|
"wrong-phase controls PASS", flush=True)
|
||||||
|
|
||||||
def test_cleanup_attempts_every_allocation(self):
|
def test_cleanup_attempts_every_allocation(self):
|
||||||
backend = PeriodicPatchStepper.__new__(PeriodicPatchStepper)
|
backend = PeriodicPatchStepper.__new__(PeriodicPatchStepper)
|
||||||
backend.ctx = Mock(activate=nullcontext)
|
backend.ctx = Mock(activate=nullcontext)
|
||||||
|
|||||||
@@ -0,0 +1,346 @@
|
|||||||
|
"""Explicit host-only checks or admitted tiny GPU audit; never a long trajectory."""
|
||||||
|
import argparse
|
||||||
|
from contextlib import nullcontext
|
||||||
|
from dataclasses import replace
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
from types import SimpleNamespace
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import Mock
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[3]
|
||||||
|
sys.path.insert(0, str(ROOT/'src'))
|
||||||
|
from CelerisLab.config import LBMConfig
|
||||||
|
import spacetime_gpu as gpu
|
||||||
|
import run_spacetime_gpu_n64 as trajectory
|
||||||
|
ref = gpu.ref
|
||||||
|
RECORDS = []
|
||||||
|
REPORT = None
|
||||||
|
OUTPUT = None
|
||||||
|
GPU_ADMITTED = False
|
||||||
|
|
||||||
|
|
||||||
|
def record(value):
|
||||||
|
RECORDS.append(value)
|
||||||
|
if OUTPUT is not None:
|
||||||
|
ref.write_receipt(OUTPUT,REPORT)
|
||||||
|
|
||||||
|
|
||||||
|
def config(n):
|
||||||
|
return LBMConfig(nx=n,ny=n,viscosity=.0192,velocity=0.,ddf_shifting=False)
|
||||||
|
|
||||||
|
|
||||||
|
def initial(plan, tagged=True):
|
||||||
|
arrays = []
|
||||||
|
for n, mask in ((plan.n,plan.maps.coarse_active),(plan.nf,plan.maps.fine_active)):
|
||||||
|
a = np.broadcast_to(ref.cpu.W[:,None,None], (9,n,n)).copy()
|
||||||
|
if tagged:
|
||||||
|
a *= 1+1e-3*np.random.default_rng(n).standard_normal(a.shape)
|
||||||
|
a[:,~mask] = np.nan
|
||||||
|
arrays.append(a)
|
||||||
|
return ref.cpu.State(*arrays)
|
||||||
|
|
||||||
|
|
||||||
|
class Host(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.plan = ref.Plan(12,(3,3,9,8))
|
||||||
|
|
||||||
|
def test_pins_and_supported_config(self):
|
||||||
|
gpu.check_sources()
|
||||||
|
for n in (12,16,64):
|
||||||
|
c,f = gpu.validate_config(config(n))
|
||||||
|
self.assertAlmostEqual(c.omega,1/.5576)
|
||||||
|
self.assertAlmostEqual(f.omega,1/.6152)
|
||||||
|
for change in (dict(ddf_shifting=True),dict(collision='TRT'),dict(nx=128,ny=128),
|
||||||
|
dict(ny=16),dict(les_enabled=True),dict(velocity=.03)):
|
||||||
|
with self.subTest(change=change), self.assertRaises(ValueError):
|
||||||
|
gpu.validate_config(replace(config(12),**change))
|
||||||
|
|
||||||
|
def test_packed_weights_and_packet_ownership(self):
|
||||||
|
for plan in (self.plan,ref.Plan(16,(4,5,11,12))):
|
||||||
|
t = gpu.pack_plan(plan)
|
||||||
|
self.assertEqual(t['sources'].shape,(len(plan.receivers),4))
|
||||||
|
self.assertEqual(np.count_nonzero(t['times']==-1),24)
|
||||||
|
self.assertEqual(gpu.table_hash(t),gpu.table_hash(gpu.pack_plan(plan)))
|
||||||
|
for i,g in enumerate(plan.groups):
|
||||||
|
np.testing.assert_array_equal(t['weights'][i,:,:len(g.samples)],g.weights)
|
||||||
|
np.testing.assert_allclose(t['weights'][i].sum(axis=1),1,rtol=0,atol=2e-14)
|
||||||
|
np.testing.assert_array_equal(t['samples'][i,:len(g.samples)],g.q*plan.n**2+g.samples)
|
||||||
|
for m in (0,1):
|
||||||
|
self.assertEqual(len(t[f'incoming{m}']),len(plan.outgoing[m]))
|
||||||
|
|
||||||
|
def test_duplicate_writer_is_rejected(self):
|
||||||
|
plan = self.plan
|
||||||
|
groups = list(plan.groups)
|
||||||
|
a,b = next((i,k) for i,g in enumerate(groups) for k,e in enumerate(g.events) if e is not None)
|
||||||
|
event = groups[a].events[b]
|
||||||
|
other = next(i for i,g in enumerate(groups) if i!=a and g.q==groups[a].q and event[0] in [e[0] for e in g.events if e])
|
||||||
|
events = list(groups[other].events)
|
||||||
|
k = next(k for k,e in enumerate(events) if e is not None and e[0]==event[0])
|
||||||
|
events[k] = event; groups[other] = replace(groups[other],events=tuple(events))
|
||||||
|
fake = SimpleNamespace(n=plan.n,nf=plan.nf,groups=groups,receivers=plan.receivers,outgoing=plan.outgoing)
|
||||||
|
with self.assertRaisesRegex(ValueError,'duplicate incoming'):
|
||||||
|
gpu.pack_plan(fake)
|
||||||
|
|
||||||
|
def test_rest_ledger_and_missing_packet_discrimination(self):
|
||||||
|
p,t = self.plan,gpu.pack_plan(self.plan)
|
||||||
|
state = initial(p,False)
|
||||||
|
state = ref.cpu.State(state.coarse_f.astype(np.float32),state.fine_f.astype(np.float32))
|
||||||
|
g0 = np.broadcast_to(ref.cpu.W.astype(np.float32)[:,None,None],(9,p.n,p.n)).copy()
|
||||||
|
pre = np.repeat(g0.ravel()[t['origins'],None].astype(float),4,axis=1)
|
||||||
|
h = pre.astype(np.float32); registers = np.zeros(len(p.receivers))
|
||||||
|
phases = [(state.fine_f,state.fine_f)]*2
|
||||||
|
args = (p,t,state,state,g0,g0,phases,pre,h)
|
||||||
|
ledger = gpu.rounding_ledger(*args,registers)
|
||||||
|
self.assertEqual(max(map(abs,ledger['unexplained'])),0)
|
||||||
|
registers[0] = .01
|
||||||
|
with self.assertRaisesRegex(AssertionError,'register mismatch'):
|
||||||
|
gpu.rounding_ledger(*args,registers)
|
||||||
|
|
||||||
|
def test_second_substep_characteristic_donor(self):
|
||||||
|
p = ref.Plan(16,(4,4,12,12)); t = gpu.pack_plan(p)
|
||||||
|
row = t['incoming1'][t['incoming1'][:,0]==5*32*32+10*32+7][0]
|
||||||
|
self.assertEqual(t['origins'][row[1]//4],5*16*16+4*16+3)
|
||||||
|
|
||||||
|
def test_failed_free_remains_retryable(self):
|
||||||
|
run=gpu.SpaceTimeGPU.__new__(gpu.SpaceTimeGPU)
|
||||||
|
run.ctx=SimpleNamespace(activate=nullcontext); run.stream=Mock()
|
||||||
|
first,second=Mock(),Mock(); first.free.side_effect=[RuntimeError('free failed'),None]
|
||||||
|
run.allocations=[first,second]; run.modules=[]; run.status='ready'
|
||||||
|
with self.assertRaisesRegex(RuntimeError,'free failed'):
|
||||||
|
run.close()
|
||||||
|
self.assertEqual(run.allocations,[first]); self.assertEqual(run.status,'cleanup_failed')
|
||||||
|
run.close()
|
||||||
|
self.assertEqual(run.status,'closed'); self.assertEqual(run.allocations,[])
|
||||||
|
second.free.assert_called_once()
|
||||||
|
|
||||||
|
def test_unmeasured_schedule_and_health_failure(self):
|
||||||
|
run=gpu.SpaceTimeGPU.__new__(gpu.SpaceTimeGPU)
|
||||||
|
run.status='ready'; run.step_count=0; run.identity=False; run.mode='spacetime'
|
||||||
|
run.ctx=SimpleNamespace(activate=nullcontext); run.cuda=Mock(); run.stream=Mock()
|
||||||
|
run.plan=self.plan; run.bounds=(3,3,9,8)
|
||||||
|
run.configs=gpu.validate_config(config(12)); run.coarse=list('abcd'); run.fine=list('efg')
|
||||||
|
run.tables=gpu.pack_plan(self.plan); run.device_tables={key:key for key in run.tables}
|
||||||
|
run.active='active'; run.pre='pre'; run.h='h'; run.registers='registers'; run.counts='counts'
|
||||||
|
run.health_counts=np.zeros(6,np.uint64)
|
||||||
|
run.launch=Mock(); run.read=Mock(return_value=np.zeros(6,np.uint32)); run.download=Mock()
|
||||||
|
names=['CoarseStart','Pull','Collide','Interpolate','Collide','Register','Inject','Pull',
|
||||||
|
'Collide','Register','Inject','Pull','ApplyRegisters']
|
||||||
|
for _ in range(2):
|
||||||
|
result=run.step(audit=False)
|
||||||
|
self.assertEqual(result['boundary_budget_status'],'not_measured')
|
||||||
|
self.assertIsNone(result['unexplained'])
|
||||||
|
self.assertEqual([call.args[1] for call in run.launch.call_args_list],names*2)
|
||||||
|
self.assertEqual(run.read.call_count,2); run.download.assert_not_called()
|
||||||
|
self.assertEqual(run.step_count,2); self.assertEqual(run.coarse,list('abcd'))
|
||||||
|
run.read.return_value=np.array([0,0,0,0,1,0],np.uint32)
|
||||||
|
with self.assertRaisesRegex(AssertionError,'health failed'):
|
||||||
|
run.step(audit=False)
|
||||||
|
self.assertEqual(run.status,'failed'); self.assertEqual(run.step_count,2)
|
||||||
|
self.assertEqual(run.health_counts.tolist(),[0,0,0,0,1,0])
|
||||||
|
|
||||||
|
def test_warmup_resets_arrivals_and_counters(self):
|
||||||
|
class Fake:
|
||||||
|
def initialize(self,state):
|
||||||
|
self.state=ref.cpu.State(state.coarse_f.copy(),state.fine_f.copy())
|
||||||
|
self.step_count=0; self.health_counts=np.zeros(6,np.uint64)
|
||||||
|
def download(self):
|
||||||
|
return ref.cpu.State(self.state.coarse_f.copy(),self.state.fine_f.copy(),tick=2*self.step_count)
|
||||||
|
def step(self,*,audit):
|
||||||
|
assert audit is False
|
||||||
|
self.step_count+=1; self.state.coarse_f[:]+=1e-4
|
||||||
|
fake=Fake(); check=Mock(); state=initial(self.plan)
|
||||||
|
actual,warm=trajectory.warm_and_reset(fake,state,check)
|
||||||
|
np.testing.assert_array_equal(actual.coarse_f,state.coarse_f)
|
||||||
|
self.assertEqual(check.call_count,32); self.assertEqual(fake.step_count,0)
|
||||||
|
self.assertTrue(warm['reset_verified']); self.assertEqual(warm['intervals'],32)
|
||||||
|
|
||||||
|
def test_trajectory_screens_differences_and_json(self):
|
||||||
|
rows=[dict(tstar=t,velocity_l2=np.float64(.01),pressure_l2=.03,energy_relative=.01,
|
||||||
|
mass_relative=1e-7,momentum_change=[1e-6,-2e-6],minimum_population=.02,
|
||||||
|
minimum_boundary_pre=.02,minimum_boundary_stored=.02) for t in trajectory.TIMES]
|
||||||
|
cpu=dict(runs=[dict(worst=dict(velocity_l2=.02,pressure_l2=.04,energy_relative=.02)),
|
||||||
|
dict(rows=[dict(tstar=t,velocity_l2=.009,momentum_change=[0.,0.]) for t in trajectory.TIMES])])
|
||||||
|
uniform=dict(rows=[dict(tstar=.12,pressure_l2=.012253173806349701)])
|
||||||
|
result=trajectory.assess(rows,cpu,uniform,[0]*6)
|
||||||
|
self.assertTrue(result['campaign_pass']); self.assertTrue(result['experimental_pass'])
|
||||||
|
self.assertFalse(result['historical_pressure_gate']['passed'])
|
||||||
|
self.assertFalse(result['historical_pressure_gate']['matched_storage'])
|
||||||
|
self.assertAlmostEqual(result['gpu_minus_cpu']['rows'][0]['fields']['velocity_l2']['signed'],.001)
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
path=Path(directory)/'receipt.json'
|
||||||
|
ref.write_receipt(path,dict(completed=True,**result))
|
||||||
|
self.assertTrue(json.loads(path.read_text())['completed'])
|
||||||
|
rows[0]['velocity_l2']=.06
|
||||||
|
failed=trajectory.assess(rows,cpu,uniform,[0,1,0,0,0,0])
|
||||||
|
ref.write_receipt(path,dict(completed=True,**failed))
|
||||||
|
saved=json.loads(path.read_text())
|
||||||
|
self.assertFalse(saved['campaign_pass']); self.assertFalse(saved['experimental_pass'])
|
||||||
|
for invalid in (float('nan'),-.01):
|
||||||
|
rows[0]['velocity_l2']=.01; rows[-1]['velocity_l2']=invalid
|
||||||
|
failed=trajectory.assess(rows,cpu,uniform,[0]*6)
|
||||||
|
self.assertFalse(failed['campaign_pass']); self.assertFalse(failed['experimental_pass'])
|
||||||
|
path.write_text('changed reference')
|
||||||
|
with self.assertRaisesRegex(ValueError,'pinned reference'):
|
||||||
|
trajectory.load_references(path,path)
|
||||||
|
|
||||||
|
|
||||||
|
class Device(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
if not GPU_ADMITTED:
|
||||||
|
raise unittest.SkipTest('CUDA compilation/execution requires explicit tiny-job admission')
|
||||||
|
from CelerisLab.cuda.context import CudaContext
|
||||||
|
cls.context = CudaContext(0)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.context.close()
|
||||||
|
|
||||||
|
def test_tiny_equivalence_budgets_and_phase(self):
|
||||||
|
for mode,identity in (('spacetime',False),('spacetime',True),('frozen',False),('frozen',True)):
|
||||||
|
with self.subTest(mode=mode,identity=identity), gpu.SpaceTimeGPU(
|
||||||
|
config(12),(3,3,9,8),context=self.context,mode=mode,identity=identity) as run:
|
||||||
|
spec = ref.Spec(n_coarse=12,patch_lo=1,halo=2,tau_coarse=.5576,tau_fine=.6152,
|
||||||
|
collision='identity' if identity else 'srt')
|
||||||
|
for tagged,steps in ((False,2),(True,8)):
|
||||||
|
expected = initial(run.plan,tagged); run.initialize(expected)
|
||||||
|
before = run.download()
|
||||||
|
for k in range(1,steps+1):
|
||||||
|
expected,_ = ref.advance(spec,run.plan,expected,mode)
|
||||||
|
ledger = run.step(); actual = run.download()
|
||||||
|
self.assertEqual(actual.tick,2*k); self.assertEqual(run.step_count,k)
|
||||||
|
for a,b in zip((actual.coarse_f,actual.fine_f),(expected.coarse_f,expected.fine_f)):
|
||||||
|
np.testing.assert_array_equal(np.isnan(a),np.isnan(b))
|
||||||
|
np.testing.assert_allclose(a,b,rtol=0,atol=3e-6,equal_nan=True)
|
||||||
|
total = lambda s: ref.cpu.MOMENTS.T @ ref.directional(
|
||||||
|
ref.cpu.State(s.coarse_f.astype(float),s.fine_f.astype(float)),run.plan.maps)
|
||||||
|
np.testing.assert_allclose(total(actual),total(before),rtol=0,atol=2e-4)
|
||||||
|
if tagged and not identity and k==1:
|
||||||
|
for a,b,tau,mask in zip((actual.coarse_f,actual.fine_f),
|
||||||
|
(expected.coarse_f,expected.fine_f),(.5576,.6152),
|
||||||
|
(run.plan.maps.coarse_active,run.plan.maps.fine_active)):
|
||||||
|
wrong = ref.cpu._collide(spec,b,np.isfinite(b),tau,mask,np.zeros(mask.shape,int))
|
||||||
|
self.assertGreater(float(np.nanmax(abs(a-wrong))),3e-6)
|
||||||
|
if k in (1,2,8):
|
||||||
|
record(dict(case='tiny',mode=mode,identity=identity,tagged=tagged,
|
||||||
|
step=k,device_bytes=run.device_bytes,ledger=ledger))
|
||||||
|
|
||||||
|
def test_omitted_packets_and_ghosts_fail(self):
|
||||||
|
for mutation in (1,2,3,4):
|
||||||
|
with self.subTest(mutation=mutation), gpu.SpaceTimeGPU(
|
||||||
|
config(12),(3,3,9,8),context=self.context) as run:
|
||||||
|
run.initialize(initial(run.plan))
|
||||||
|
with self.assertRaises(AssertionError):
|
||||||
|
run.step(mutation=mutation)
|
||||||
|
self.assertEqual(run.step_count,0)
|
||||||
|
self.assertEqual(run.status,'failed')
|
||||||
|
with self.assertRaises(RuntimeError):
|
||||||
|
run.download()
|
||||||
|
|
||||||
|
def test_frozen_donor_trap(self):
|
||||||
|
with gpu.SpaceTimeGPU(config(16),(4,4,12,12),context=self.context,mode='frozen',identity=True) as run:
|
||||||
|
state = initial(run.plan,False)
|
||||||
|
state.coarse_f[5,4,3]=1.; state.coarse_f[5,5,3]=2.
|
||||||
|
run.initialize(state); run.step()
|
||||||
|
self.assertEqual(run.download().fine_f[5,11,8],1.)
|
||||||
|
# Deliberately negative boundary data are reported and remain unclipped.
|
||||||
|
with self.context.activate():
|
||||||
|
data=np.full((9,16,16),-.01,np.float32)
|
||||||
|
run.cuda.memcpy_htod(run.coarse[1],data); run.cuda.memcpy_htod(run.coarse[3],data)
|
||||||
|
run.cuda.memset_d32_async(run.counts,0,6,run.stream)
|
||||||
|
t=run.device_tables; ng=len(run.plan.groups)
|
||||||
|
run.launch(0,'Interpolate',run.coarse[1],run.coarse[3],t['samples'],t['origins'],
|
||||||
|
t['sizes'],t['weights'],run.pre,run.h,np.uint32(ng),np.uint32(0),run.counts,count=ng)
|
||||||
|
counts=run.read(run.counts,(6,),np.uint32)
|
||||||
|
self.assertEqual(counts[1],4*ng); self.assertEqual(counts[3],4*ng)
|
||||||
|
self.assertTrue((run.read(run.h,(ng,4))<0).all())
|
||||||
|
|
||||||
|
def test_n64_one_interval_only(self):
|
||||||
|
sys.path.insert(0,str(Path(__file__).parents[1]/'taylor_green'))
|
||||||
|
import oracle as tg
|
||||||
|
with gpu.SpaceTimeGPU(config(64),(8,8,56,48),context=self.context) as run:
|
||||||
|
arrays = [tg.initial((64,64),0,64,.0192),tg.initial((128,128),1,64,.0192)]
|
||||||
|
for a,mask in zip(arrays,(run.plan.maps.coarse_active,run.plan.maps.fine_active)):
|
||||||
|
a[:,~mask]=np.nan
|
||||||
|
state = ref.cpu.State(*arrays); run.initialize(state)
|
||||||
|
spec = ref.Spec(n_coarse=64,patch_lo=8,halo=16,tau_coarse=.5576,tau_fine=.6152,collision='srt')
|
||||||
|
expected,_ = ref.advance(spec,run.plan,state)
|
||||||
|
started=time.monotonic(); ledger=run.step(); seconds=time.monotonic()-started
|
||||||
|
actual=run.download()
|
||||||
|
errors=[]
|
||||||
|
for a,b in zip((actual.coarse_f,actual.fine_f),(expected.coarse_f,expected.fine_f)):
|
||||||
|
np.testing.assert_array_equal(np.isnan(a),np.isnan(b))
|
||||||
|
np.testing.assert_allclose(a,b,rtol=0,atol=3e-6,equal_nan=True)
|
||||||
|
errors.append(float(np.nanmax(abs(a-b))))
|
||||||
|
record(dict(case='N64_one_interval',errors=errors,ledger=ledger,seconds=seconds,
|
||||||
|
device_bytes=run.device_bytes,table_sha256=gpu.table_hash(run.tables),
|
||||||
|
build_metadata=run.build_metadata,device=self.context.name))
|
||||||
|
|
||||||
|
def test_unmeasured_path_and_warm_reset(self):
|
||||||
|
with gpu.SpaceTimeGPU(config(12),(3,3,9,8),context=self.context) as run:
|
||||||
|
state=initial(run.plan)
|
||||||
|
run.initialize(state)
|
||||||
|
for _ in range(2):
|
||||||
|
run.step()
|
||||||
|
expected=run.download()
|
||||||
|
run.initialize(state)
|
||||||
|
for _ in range(2):
|
||||||
|
result=run.step(audit=False)
|
||||||
|
self.assertEqual(result['boundary_budget_status'],'not_measured')
|
||||||
|
actual=run.download()
|
||||||
|
for a,b in zip((actual.coarse_f,actual.fine_f),(expected.coarse_f,expected.fine_f)):
|
||||||
|
np.testing.assert_array_equal(a,b)
|
||||||
|
reset,warm=trajectory.warm_and_reset(run,state,lambda:None)
|
||||||
|
for a,b in zip((reset.coarse_f,reset.fine_f),(state.coarse_f,state.fine_f)):
|
||||||
|
np.testing.assert_array_equal(a,b.astype(np.float32))
|
||||||
|
record(dict(case='unmeasured_bitwise_and_reset',warmup=warm,health_counts=run.health_counts.tolist()))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global REPORT,OUTPUT,GPU_ADMITTED
|
||||||
|
parser=argparse.ArgumentParser(description=__doc__)
|
||||||
|
mode=parser.add_mutually_exclusive_group(required=True)
|
||||||
|
mode.add_argument('--host-only',action='store_true')
|
||||||
|
mode.add_argument('--gpu-admitted',action='store_true')
|
||||||
|
parser.add_argument('--output',type=Path)
|
||||||
|
args=parser.parse_args()
|
||||||
|
GPU_ADMITTED=args.gpu_admitted
|
||||||
|
if args.gpu_admitted and (not os.environ.get('CUDA_VISIBLE_DEVICES') or args.output is None):
|
||||||
|
parser.error('GPU job requires explicit CUDA_VISIBLE_DEVICES and --output')
|
||||||
|
if args.output is not None and args.output.exists():
|
||||||
|
parser.error('output exists; retain evidence and choose a new path')
|
||||||
|
started=time.monotonic()
|
||||||
|
report=dict(scope='tiny GPU equivalence and rounding audit; no long trajectory',completed=False,
|
||||||
|
requested_mode='admitted_tiny_gpu' if args.gpu_admitted else 'host_only',
|
||||||
|
commit=subprocess.check_output(['git','rev-parse','HEAD'],cwd=ROOT,text=True).strip(),
|
||||||
|
dirty=bool(subprocess.check_output(['git','status','--porcelain'],cwd=ROOT,text=True)),
|
||||||
|
hashes={p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in
|
||||||
|
(Path(__file__),Path(gpu.__file__),Path(gpu.__file__).with_suffix('.cu'))},
|
||||||
|
reference_hashes=gpu.PINS,cuda_visible_devices=os.environ.get('CUDA_VISIBLE_DEVICES'),records=RECORDS)
|
||||||
|
REPORT,OUTPUT=report,args.output
|
||||||
|
if args.output:
|
||||||
|
ref.write_receipt(args.output,report)
|
||||||
|
suite=unittest.TestLoader().loadTestsFromTestCase(Host)
|
||||||
|
if args.gpu_admitted:
|
||||||
|
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(Device))
|
||||||
|
result=unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
|
report.update(completed=True,passed=result.wasSuccessful(),tests=result.testsRun,
|
||||||
|
failures=[dict(test=str(test),error=error) for test,error in result.failures+result.errors],
|
||||||
|
seconds=time.monotonic()-started)
|
||||||
|
if args.output:
|
||||||
|
ref.write_receipt(args.output,report)
|
||||||
|
return 0 if result.wasSuccessful() else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
raise SystemExit(main())
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
"""Tiny CPU algebra/event tests; no full trajectory or GPU execution."""
|
||||||
|
from dataclasses import replace
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
import numpy as np
|
||||||
|
import spacetime_reference as st
|
||||||
|
|
||||||
|
|
||||||
|
class SpaceTime(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.plan = st.Plan(12, (3, 3, 9, 8))
|
||||||
|
cls.spec = st.Spec(n_coarse=12, patch_lo=1, halo=2,
|
||||||
|
tau_coarse=.5576, tau_fine=.6152, collision="srt")
|
||||||
|
|
||||||
|
def state(self, tagged=False):
|
||||||
|
arrays = []
|
||||||
|
for n, mask in ((12,self.plan.maps.coarse_active),(24,self.plan.maps.fine_active)):
|
||||||
|
q, y, x = np.indices((9,n,n))
|
||||||
|
a = np.broadcast_to(st.cpu.W[:,None,None], (9,n,n)).copy()
|
||||||
|
if tagged:
|
||||||
|
a *= 1+1e-3*np.random.default_rng(n).normal(size=a.shape)
|
||||||
|
a[:,~mask] = np.nan
|
||||||
|
arrays.append(a)
|
||||||
|
return st.cpu.State(*arrays)
|
||||||
|
|
||||||
|
def test_events_and_corner_leftovers(self):
|
||||||
|
groups = [g for g in self.plan.groups if None in g.events]
|
||||||
|
self.assertEqual(len(groups), 8)
|
||||||
|
self.assertTrue(all(g.events.count(None)==3 for g in groups))
|
||||||
|
for m in (0,1):
|
||||||
|
events = list(map(tuple,self.plan.outgoing[m]))
|
||||||
|
self.assertEqual(len(events),len(set(events)))
|
||||||
|
st.Plan(16,(4,5,11,12))
|
||||||
|
|
||||||
|
def test_interpolation(self):
|
||||||
|
for g in self.plan.groups:
|
||||||
|
samples, a, e, coeff = st.interpolation(g.kind,g.points)
|
||||||
|
np.testing.assert_allclose(g.weights@np.ones(len(samples)),1,rtol=0,atol=2e-14)
|
||||||
|
np.testing.assert_allclose(g.weights.mean(axis=0), np.eye(len(samples))[1 if g.kind=='face' else 0],rtol=0,atol=2e-14)
|
||||||
|
if g.kind=='face':
|
||||||
|
beta=np.array([1.,.03,.02,0.])
|
||||||
|
else:
|
||||||
|
cx,cy=st.cpu.CX[g.q],st.cpu.CY[g.q]
|
||||||
|
beta=np.array([1.,.03,.02,-cx*.03-cy*.02])
|
||||||
|
steady=a@np.array([1.,.03,.02,0.])
|
||||||
|
self.assertLess(abs((coeff@steady)[3]),2e-14)
|
||||||
|
np.testing.assert_allclose(g.weights@(a@beta),e@beta,rtol=0,atol=2e-14)
|
||||||
|
|
||||||
|
def test_rest(self):
|
||||||
|
initial=self.state()
|
||||||
|
final,d=st.advance(self.spec,self.plan,initial)
|
||||||
|
for a,b in zip((initial.coarse_f,initial.fine_f),(final.coarse_f,final.fine_f)):
|
||||||
|
np.testing.assert_allclose(a,b,rtol=0,atol=2e-14,equal_nan=True)
|
||||||
|
|
||||||
|
def test_frozen_recovers_ivp(self):
|
||||||
|
for collision in ('identity','srt'):
|
||||||
|
spec=replace(self.spec,collision=collision)
|
||||||
|
a=b=self.state(True)
|
||||||
|
for _ in range(2):
|
||||||
|
a,_=st.advance(spec,self.plan,a,'frozen')
|
||||||
|
b,_=st.cpu.advance_coarse_once(spec,self.plan.maps,b)
|
||||||
|
for aa,bb in zip((a.coarse_f,a.fine_f),(b.coarse_f,b.fine_f)):
|
||||||
|
np.testing.assert_allclose(aa,bb,rtol=0,atol=2e-14,equal_nan=True)
|
||||||
|
|
||||||
|
def test_second_substep_uses_characteristic_origin(self):
|
||||||
|
# Review counterexample in (x,y): ghost (7,10), m=1 traces back
|
||||||
|
# to (6,9), parent (3,4), not its current parent (3,5).
|
||||||
|
plan=st.Plan(16,(4,4,12,12))
|
||||||
|
owners=[g for g in plan.groups if g.q==5 and (1,10*32+7) in g.events]
|
||||||
|
self.assertEqual(len(owners),1)
|
||||||
|
self.assertEqual(owners[0].source,4*16+3)
|
||||||
|
spec=st.Spec(n_coarse=16,patch_lo=2,halo=4,collision='identity')
|
||||||
|
arrays=[]
|
||||||
|
for n,mask in ((16,plan.maps.coarse_active),(32,plan.maps.fine_active)):
|
||||||
|
a=np.broadcast_to(st.cpu.W[:,None,None],(9,n,n)).copy()
|
||||||
|
a[:,~mask]=np.nan
|
||||||
|
arrays.append(a)
|
||||||
|
arrays[0][5,4,3]=1.; arrays[0][5,5,3]=2.
|
||||||
|
final,_=st.advance(spec,plan,st.cpu.State(*arrays),'frozen')
|
||||||
|
self.assertEqual(final.fine_f[5,11,8],1.)
|
||||||
|
self.assertNotEqual(final.fine_f[5,11,8],arrays[0][5,5,3])
|
||||||
|
|
||||||
|
def test_corner_affine_tradeoff_is_explicit(self):
|
||||||
|
group=next(g for g in self.plan.groups if g.kind=='corner')
|
||||||
|
_,a,e,coeff=st.interpolation(group.kind,group.points)
|
||||||
|
linear_x=np.array([0.,1.,0.,0.])
|
||||||
|
# The two paper constraints are consistent. Arbitrary affine exactness
|
||||||
|
# is the incompatible additional demand.
|
||||||
|
self.assertEqual(abs(float((e@linear_x).mean())),.125)
|
||||||
|
fitted=coeff@(a@linear_x)
|
||||||
|
self.assertLess(abs(fitted[3]),2e-14)
|
||||||
|
self.assertLess(abs(float((e@fitted).mean())),2e-14)
|
||||||
|
self.assertGreater(np.max(np.abs(e@fitted-e@linear_x)),.01)
|
||||||
|
|
||||||
|
def test_directional_budgets(self):
|
||||||
|
for collision in ('identity','srt'):
|
||||||
|
spec=replace(self.spec,collision=collision)
|
||||||
|
a=self.state(True)
|
||||||
|
for _ in range(2):
|
||||||
|
a,d=st.advance(spec,self.plan,a)
|
||||||
|
np.testing.assert_allclose(d['directional_residual'],0,rtol=0,atol=2e-12)
|
||||||
|
self.assertLess(d['group_error'],2e-14)
|
||||||
|
|
||||||
|
def test_missing_packets_fail(self):
|
||||||
|
for mutation in ('omit_leftover','omit_outgoing_0','omit_outgoing_1'):
|
||||||
|
_,d=st.advance(self.spec,self.plan,self.state(True),mutation=mutation)
|
||||||
|
self.assertGreater(np.max(np.abs(d['directional_residual'])),1e-5)
|
||||||
|
|
||||||
|
def test_negative_interpolation_is_reported_not_clipped(self):
|
||||||
|
initial=self.state()
|
||||||
|
group=self.plan.groups[0]
|
||||||
|
initial.coarse_f.reshape(9,-1)[group.q,group.source]=-.01
|
||||||
|
spec=replace(self.spec,collision='identity')
|
||||||
|
_,d=st.advance(spec,self.plan,initial,'frozen')
|
||||||
|
self.assertGreaterEqual(d['negative_boundary_count'],4)
|
||||||
|
self.assertEqual(d['min_boundary'],-.01)
|
||||||
|
self.assertEqual(d['nonfinite_boundary_count'],0)
|
||||||
|
|
||||||
|
|
||||||
|
class Receipts(unittest.TestCase):
|
||||||
|
def test_completed_and_failed_screen_receipts(self):
|
||||||
|
for passed in (True, False):
|
||||||
|
with self.subTest(passed=passed), tempfile.TemporaryDirectory() as directory:
|
||||||
|
# Same NumPy comparison type produced by the final metric screen.
|
||||||
|
checks = {'velocity_l2': np.float64(.5 if passed else 1.) <= .8,
|
||||||
|
'mass_momentum': True}
|
||||||
|
self.assertIsInstance(checks['velocity_l2'], np.bool_)
|
||||||
|
result = dict(completed=True, checks=checks,
|
||||||
|
experimental_pass=all(checks.values()),
|
||||||
|
runs=[dict(rows=[dict(step=np.int64(1024),
|
||||||
|
mass_relative=np.float32(0.))])])
|
||||||
|
path = Path(directory)/'receipt.json'
|
||||||
|
st.write_receipt(path, result)
|
||||||
|
saved = json.loads(path.read_text())
|
||||||
|
self.assertIs(saved['completed'], True)
|
||||||
|
self.assertIs(saved['experimental_pass'], passed)
|
||||||
|
self.assertIs(saved['checks']['velocity_l2'], passed)
|
||||||
|
self.assertEqual(saved['runs'][0]['rows'][0],
|
||||||
|
dict(step=1024, mass_relative=0.))
|
||||||
|
|
||||||
|
def test_receipts_still_reject_nonfinite_and_unknown_values(self):
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
path = Path(directory)/'receipt.json'
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
st.write_receipt(path, {'invalid': np.float32('nan')})
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
st.write_receipt(path, {'invalid': object()})
|
||||||
|
self.assertFalse(path.exists())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
unittest.main(verbosity=2)
|
||||||
@@ -45,7 +45,7 @@ def config(h, diameter, collision="SRT"):
|
|||||||
return cfg, body, p
|
return cfg, body, p
|
||||||
|
|
||||||
|
|
||||||
def plan(h, collision="SRT"):
|
def plan(h, collision="SRT", observation_mode="last_base_step"):
|
||||||
_, _, c = config(h, 40, collision)
|
_, _, c = config(h, 40, collision)
|
||||||
_, _, f = config(h, 80, collision)
|
_, _, f = config(h, 80, collision)
|
||||||
x0, y0, x1, y1 = BOUNDS
|
x0, y0, x1, y1 = BOUNDS
|
||||||
@@ -54,6 +54,7 @@ def plan(h, collision="SRT"):
|
|||||||
return dict(
|
return dict(
|
||||||
status="prepared_not_run",
|
status="prepared_not_run",
|
||||||
collision=collision,
|
collision=collision,
|
||||||
|
observation_mode=observation_mode,
|
||||||
root_gpu_gates_required=True,
|
root_gpu_gates_required=True,
|
||||||
root=c,
|
root=c,
|
||||||
uniform=f,
|
uniform=f,
|
||||||
@@ -156,10 +157,13 @@ def host_geometry(source, h, collision="SRT"):
|
|||||||
return cfg, pair, body, host
|
return cfg, pair, body, host
|
||||||
|
|
||||||
|
|
||||||
def verify_source(source, collision="SRT"):
|
def verify_source(source, collision="SRT", observation_mode="last_base_step"):
|
||||||
if collision not in ("SRT", "MRT"):
|
if collision not in ("SRT", "MRT"):
|
||||||
raise ValueError("Matched collision must be SRT or MRT")
|
raise ValueError("Matched collision must be SRT or MRT")
|
||||||
name = "source_manifest.json" if collision == "SRT" else "source_manifest_mrt.json"
|
if observation_mode not in ("last_base_step", "window"):
|
||||||
|
raise ValueError("Unknown refined observation mode")
|
||||||
|
name = ("source_manifest_window.json" if observation_mode == "window" else
|
||||||
|
"source_manifest.json" if collision == "SRT" else "source_manifest_mrt.json")
|
||||||
expected = json.loads((HERE / "data/refined_dfg" / name).read_text())
|
expected = json.loads((HERE / "data/refined_dfg" / name).read_text())
|
||||||
for name, digest in expected["sha256"].items():
|
for name, digest in expected["sha256"].items():
|
||||||
if hashlib.sha256((source / name).read_bytes()).hexdigest() != digest:
|
if hashlib.sha256((source / name).read_bytes()).hexdigest() != digest:
|
||||||
@@ -167,6 +171,46 @@ def verify_source(source, collision="SRT"):
|
|||||||
return expected
|
return expected
|
||||||
|
|
||||||
|
|
||||||
|
def advance_refined_interval(backend, n, deadline, observation_mode):
|
||||||
|
"""Return the same root-unit interval impulse, never an already averaged force."""
|
||||||
|
impulse = np.zeros(2)
|
||||||
|
if observation_mode == "window":
|
||||||
|
begin = backend.step_count
|
||||||
|
check_deadline(deadline)
|
||||||
|
backend.start_exchange_window()
|
||||||
|
backend.step(n)
|
||||||
|
exchange = backend.read_exchange_window(0, level=1)
|
||||||
|
if (
|
||||||
|
exchange["units"] != "base_lattice_per_unit_depth"
|
||||||
|
or exchange["window"] != "window"
|
||||||
|
or exchange["sample_count"] != 2 * n
|
||||||
|
or exchange["time_start"] != begin
|
||||||
|
or exchange["time_end"] != begin + n
|
||||||
|
or exchange["dt"] != 0.5
|
||||||
|
):
|
||||||
|
raise RuntimeError("Unexpected window force observation contract")
|
||||||
|
impulse += exchange["total"]["impulse"]
|
||||||
|
check_deadline(deadline)
|
||||||
|
return impulse
|
||||||
|
if observation_mode != "last_base_step":
|
||||||
|
raise ValueError("Unknown refined observation mode")
|
||||||
|
for _ in range(n):
|
||||||
|
check_deadline(deadline)
|
||||||
|
backend.step(1)
|
||||||
|
exchange = backend.read_raw_exchange(
|
||||||
|
0, level=1, window="last_base_step"
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
exchange["units"] != "base_lattice_per_unit_depth"
|
||||||
|
or exchange["sample_count"] != 2
|
||||||
|
or exchange["time_end"] - exchange["time_start"] != 1
|
||||||
|
):
|
||||||
|
raise RuntimeError("Unexpected force observation contract")
|
||||||
|
impulse += exchange["total"]["impulse"]
|
||||||
|
check_deadline(deadline)
|
||||||
|
return impulse
|
||||||
|
|
||||||
|
|
||||||
def run_case(a, h, periodic, case):
|
def run_case(a, h, periodic, case):
|
||||||
from CelerisLab.simulation import Simulation
|
from CelerisLab.simulation import Simulation
|
||||||
from CelerisLab.cuda.context import CudaContext
|
from CelerisLab.cuda.context import CudaContext
|
||||||
@@ -199,6 +243,7 @@ def run_case(a, h, periodic, case):
|
|||||||
fine_block=FINE_BLOCK,
|
fine_block=FINE_BLOCK,
|
||||||
fine_objects=(body,),
|
fine_objects=(body,),
|
||||||
observe_raw_exchange=True,
|
observe_raw_exchange=True,
|
||||||
|
**({"observe_window_exchange": True} if a.observation_mode == "window" else {}),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
from CelerisLab.lbm.channel import channel_masks
|
from CelerisLab.lbm.channel import channel_masks
|
||||||
@@ -248,20 +293,9 @@ def run_case(a, h, periodic, case):
|
|||||||
impulse = np.zeros(2)
|
impulse = np.zeros(2)
|
||||||
tick = time.monotonic()
|
tick = time.monotonic()
|
||||||
if refined:
|
if refined:
|
||||||
for _ in range(n):
|
impulse = advance_refined_interval(
|
||||||
check_deadline(a.deadline)
|
backend, n, a.deadline, a.observation_mode
|
||||||
backend.step(1)
|
)
|
||||||
exchange = backend.read_raw_exchange(
|
|
||||||
0, level=1, window="last_base_step"
|
|
||||||
)
|
|
||||||
if (
|
|
||||||
exchange["units"] != "base_lattice_per_unit_depth"
|
|
||||||
or exchange["sample_count"] != 2
|
|
||||||
or exchange["time_end"] - exchange["time_start"] != 1
|
|
||||||
):
|
|
||||||
raise RuntimeError("Unexpected force observation contract")
|
|
||||||
impulse += exchange["total"]["impulse"]
|
|
||||||
check_deadline(a.deadline)
|
|
||||||
else:
|
else:
|
||||||
done = 0
|
done = 0
|
||||||
while done < n:
|
while done < n:
|
||||||
@@ -345,6 +379,7 @@ def run_case(a, h, periodic, case):
|
|||||||
ready = dict(
|
ready = dict(
|
||||||
case=case,
|
case=case,
|
||||||
collision=a.collision,
|
collision=a.collision,
|
||||||
|
observation_mode=a.observation_mode,
|
||||||
**a.provenance,
|
**a.provenance,
|
||||||
mode=a.mode,
|
mode=a.mode,
|
||||||
step=begin,
|
step=begin,
|
||||||
@@ -359,6 +394,7 @@ def run_case(a, h, periodic, case):
|
|||||||
result = dict(
|
result = dict(
|
||||||
case=case,
|
case=case,
|
||||||
collision=a.collision,
|
collision=a.collision,
|
||||||
|
observation_mode=a.observation_mode,
|
||||||
**a.provenance,
|
**a.provenance,
|
||||||
mode=a.mode,
|
mode=a.mode,
|
||||||
history=rows,
|
history=rows,
|
||||||
@@ -428,12 +464,14 @@ def check_deadline(deadline):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def verify_pilot(path, manifest, collision="SRT"):
|
def verify_pilot(path, manifest, collision="SRT", observation_mode="last_base_step"):
|
||||||
if path is None:
|
if path is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Full comparison requires --pilot-results from a completed matched pilot"
|
"Full comparison requires --pilot-results from a completed matched pilot"
|
||||||
)
|
)
|
||||||
previous = read_finite_json(path / "plan.json")
|
previous = read_finite_json(path / "plan.json")
|
||||||
|
if previous.get("observation_mode") != observation_mode:
|
||||||
|
raise ValueError("Pilot observation mode differs")
|
||||||
if previous.get("collision") != collision:
|
if previous.get("collision") != collision:
|
||||||
raise ValueError("Pilot collision differs")
|
raise ValueError("Pilot collision differs")
|
||||||
if previous["source_manifest"] != manifest or previous["bounds_root_edge"] != list(
|
if previous["source_manifest"] != manifest or previous["bounds_root_edge"] != list(
|
||||||
@@ -446,7 +484,8 @@ def verify_pilot(path, manifest, collision="SRT"):
|
|||||||
for case, diameter in (("uniform", 80), ("refined", 40)):
|
for case, diameter in (("uniform", 80), ("refined", 40)):
|
||||||
summary = read_finite_json(path / case / "summary.json")
|
summary = read_finite_json(path / case / "summary.json")
|
||||||
if (
|
if (
|
||||||
summary.get("collision") != collision
|
summary.get("observation_mode") != observation_mode
|
||||||
|
or summary.get("collision") != collision
|
||||||
or summary.get("case") != case
|
or summary.get("case") != case
|
||||||
or summary.get("mode") != "pilot"
|
or summary.get("mode") != "pilot"
|
||||||
or summary.get("status") != "pilot_complete"
|
or summary.get("status") != "pilot_complete"
|
||||||
@@ -498,7 +537,8 @@ def verify_pilot(path, manifest, collision="SRT"):
|
|||||||
raise ValueError("Unhealthy pilot observations")
|
raise ValueError("Unhealthy pilot observations")
|
||||||
ready = read_finite_json(path / case / "ready.json")
|
ready = read_finite_json(path / case / "ready.json")
|
||||||
if (
|
if (
|
||||||
ready.get("collision") != collision
|
ready.get("observation_mode") != observation_mode
|
||||||
|
or ready.get("collision") != collision
|
||||||
or ready.get("case") != case
|
or ready.get("case") != case
|
||||||
or ready.get("mode") != "pilot"
|
or ready.get("mode") != "pilot"
|
||||||
or ready.get("step") != interval
|
or ready.get("step") != interval
|
||||||
@@ -523,6 +563,8 @@ def verify_pilot(path, manifest, collision="SRT"):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--exchange-window", action="store_true",
|
||||||
|
help="Opt in to refined window-ledger observations on the pinned candidate")
|
||||||
parser.add_argument("--collision", choices=["SRT", "MRT"], default="SRT")
|
parser.add_argument("--collision", choices=["SRT", "MRT"], default="SRT")
|
||||||
parser.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
|
parser.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
|
||||||
parser.add_argument("--output", type=Path, required=True)
|
parser.add_argument("--output", type=Path, required=True)
|
||||||
@@ -536,13 +578,14 @@ def main():
|
|||||||
)
|
)
|
||||||
a = parser.parse_args()
|
a = parser.parse_args()
|
||||||
a.source = a.source.resolve()
|
a.source = a.source.resolve()
|
||||||
manifest = verify_source(a.source, a.collision)
|
a.observation_mode = "window" if a.exchange_window else "last_base_step"
|
||||||
|
manifest = verify_source(a.source, a.collision, a.observation_mode)
|
||||||
h, periodic = helpers(a.source)
|
h, periodic = helpers(a.source)
|
||||||
from source_provenance import checkout_provenance
|
from source_provenance import checkout_provenance
|
||||||
|
|
||||||
a.provenance = checkout_provenance(a.source)
|
a.provenance = checkout_provenance(a.source)
|
||||||
calibration = (
|
calibration = (
|
||||||
verify_pilot(a.pilot_results, manifest, a.collision)
|
verify_pilot(a.pilot_results, manifest, a.collision, a.observation_mode)
|
||||||
if a.mode == "full" else None
|
if a.mode == "full" else None
|
||||||
)
|
)
|
||||||
if a.mode != "plan" and (
|
if a.mode != "plan" and (
|
||||||
@@ -559,7 +602,7 @@ def main():
|
|||||||
if a.output.exists() and any(a.output.iterdir()):
|
if a.output.exists() and any(a.output.iterdir()):
|
||||||
raise ValueError("Output must be empty/new")
|
raise ValueError("Output must be empty/new")
|
||||||
a.output.mkdir(parents=True, exist_ok=True)
|
a.output.mkdir(parents=True, exist_ok=True)
|
||||||
specification = plan(h, a.collision)
|
specification = plan(h, a.collision, a.observation_mode)
|
||||||
specification.update(
|
specification.update(
|
||||||
source_manifest=manifest,
|
source_manifest=manifest,
|
||||||
**a.provenance,
|
**a.provenance,
|
||||||
@@ -586,6 +629,7 @@ def main():
|
|||||||
failure = dict(
|
failure = dict(
|
||||||
status="wall_time_limit",
|
status="wall_time_limit",
|
||||||
collision=a.collision,
|
collision=a.collision,
|
||||||
|
observation_mode=a.observation_mode,
|
||||||
**a.provenance,
|
**a.provenance,
|
||||||
case=case,
|
case=case,
|
||||||
matched_case_pass=False,
|
matched_case_pass=False,
|
||||||
@@ -601,6 +645,7 @@ def main():
|
|||||||
break
|
break
|
||||||
comparison = dict(
|
comparison = dict(
|
||||||
collision=a.collision,
|
collision=a.collision,
|
||||||
|
observation_mode=a.observation_mode,
|
||||||
**a.provenance,
|
**a.provenance,
|
||||||
status="pilot_only" if a.mode == "pilot" else "incomplete",
|
status="pilot_only" if a.mode == "pilot" else "incomplete",
|
||||||
matched_case_pass=False,
|
matched_case_pass=False,
|
||||||
|
|||||||
@@ -59,8 +59,15 @@ def decode_macros(data, w, cx, cy):
|
|||||||
return profile, *metrics
|
return profile, *metrics
|
||||||
|
|
||||||
|
|
||||||
def source_guard(root, variant):
|
EXPERIMENTS = {
|
||||||
manifest = json.loads((HERE / "data/les_flow/source_pins.json").read_text())
|
"historical": "source_pins.json",
|
||||||
|
"dev8403956": "source_pins_dev8403956.json",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def source_guard(root, variant, experiment="historical"):
|
||||||
|
manifest_path = HERE / "data/les_flow" / EXPERIMENTS[experiment]
|
||||||
|
manifest = json.loads(manifest_path.read_text())
|
||||||
for name, sha in manifest["sources"].items():
|
for name, sha in manifest["sources"].items():
|
||||||
expected = (
|
expected = (
|
||||||
manifest["candidate_header_sha256"]
|
manifest["candidate_header_sha256"]
|
||||||
@@ -69,7 +76,7 @@ def source_guard(root, variant):
|
|||||||
)
|
)
|
||||||
if hashlib.sha256((root / name).read_bytes()).hexdigest() != expected:
|
if hashlib.sha256((root / name).read_bytes()).hexdigest() != expected:
|
||||||
raise RuntimeError("Source pin mismatch: " + name)
|
raise RuntimeError("Source pin mismatch: " + name)
|
||||||
return dict(
|
identity = dict(
|
||||||
base_commit=manifest["base_commit"],
|
base_commit=manifest["base_commit"],
|
||||||
production_origin_commit=manifest["production_origin_commit"],
|
production_origin_commit=manifest["production_origin_commit"],
|
||||||
source_experiment=manifest["source_experiment"],
|
source_experiment=manifest["source_experiment"],
|
||||||
@@ -80,12 +87,22 @@ def source_guard(root, variant):
|
|||||||
header_sha256=hashlib.sha256((root / HEADER).read_bytes()).hexdigest(),
|
header_sha256=hashlib.sha256((root / HEADER).read_bytes()).hexdigest(),
|
||||||
variant=variant,
|
variant=variant,
|
||||||
)
|
)
|
||||||
|
if experiment != "historical":
|
||||||
|
identity.update(
|
||||||
|
experiment=experiment,
|
||||||
|
source_manifest_sha256=hashlib.sha256(manifest_path.read_bytes()).hexdigest(),
|
||||||
|
)
|
||||||
|
return identity
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ap = argparse.ArgumentParser(description=__doc__)
|
ap = argparse.ArgumentParser(description=__doc__)
|
||||||
ap.add_argument("--root", type=Path, required=True)
|
ap.add_argument("--root", type=Path, required=True)
|
||||||
ap.add_argument("--variant", choices=["baseline", "corrected"], required=True)
|
ap.add_argument("--variant", choices=["baseline", "corrected"], required=True)
|
||||||
|
ap.add_argument(
|
||||||
|
"--experiment", choices=tuple(EXPERIMENTS), default="historical",
|
||||||
|
help="Explicit source contract; historical pins remain the default",
|
||||||
|
)
|
||||||
ap.add_argument("--output", type=Path, required=True)
|
ap.add_argument("--output", type=Path, required=True)
|
||||||
ap.add_argument(
|
ap.add_argument(
|
||||||
"--device", type=int, default=0, help="Logical device in CUDA_VISIBLE_DEVICES"
|
"--device", type=int, default=0, help="Logical device in CUDA_VISIBLE_DEVICES"
|
||||||
@@ -100,7 +117,7 @@ def main():
|
|||||||
ap.error("Output exists; choose a new evidence path")
|
ap.error("Output exists; choose a new evidence path")
|
||||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
root = args.root.resolve()
|
root = args.root.resolve()
|
||||||
pins = source_guard(root, args.variant)
|
pins = source_guard(root, args.variant, args.experiment)
|
||||||
# Refuse installed-package shadowing; import only after explicit GPU opt-in.
|
# Refuse installed-package shadowing; import only after explicit GPU opt-in.
|
||||||
sys.path.insert(0, str(root / "src"))
|
sys.path.insert(0, str(root / "src"))
|
||||||
import CelerisLab
|
import CelerisLab
|
||||||
|
|||||||
Reference in new issue
Block a user