From 0b1b3d938f90a8f558a72609be0404ce427e3599 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 01:48:09 +0000 Subject: [PATCH] P1 (5/n): six GPU validation tests use the level-list constructor test_refinement_gpu (incl. PeriodicPatchStepper alias calls), test_channel_root_gpu, test_fine_surface_gpu, test_shifted_remap_gpu, test_runtime_child_remap_gpu and test_refinement_three_level_multipatch_gpu pass refinements/level_* lists; scalar and set children map to the second refinement entry exactly as _legacy_levels did. Assertions unchanged. Co-Authored-By: Claude Opus 5.5 --- tests/validation/multigrid/test_channel_root_gpu.py | 7 ++++--- tests/validation/multigrid/test_fine_surface_gpu.py | 6 ++++-- tests/validation/multigrid/test_refinement_gpu.py | 10 +++++----- .../test_refinement_three_level_multipatch_gpu.py | 8 ++++---- .../multigrid/test_runtime_child_remap_gpu.py | 5 ++--- tests/validation/multigrid/test_shifted_remap_gpu.py | 5 ++--- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tests/validation/multigrid/test_channel_root_gpu.py b/tests/validation/multigrid/test_channel_root_gpu.py index 5e66415..cf0593e 100644 --- a/tests/validation/multigrid/test_channel_root_gpu.py +++ b/tests/validation/multigrid/test_channel_root_gpu.py @@ -106,9 +106,10 @@ class ChannelRootGPU(unittest.TestCase): cfg = LBMConfig(nx=48, ny=32, viscosity=.1, velocity=.015, ddf_shifting=shifted) reference = None for block in ((32,48), (8,8), (4,1)): - with FixedPatchStepper(cfg, (8,6,40,26), context=context, - coarse_boundary="channel", base_block=block, fine_block=(8,8), - fine_objects=(body,) if bodies else (), jets=(jet,) if bodies else ()) as backend: + with FixedPatchStepper(cfg, context=context, coarse_boundary="channel", + refinements=[(8,6,40,26)], level_blocks=[block, (8,8)], + level_objects=[(), (body,) if bodies else ()], + level_jets=[(), (jet,) if bodies else ()]) as backend: arrays = [state(*level.shape[1:]) for level in backend._levels] backend.initialize(*arrays) backend.step(4) diff --git a/tests/validation/multigrid/test_fine_surface_gpu.py b/tests/validation/multigrid/test_fine_surface_gpu.py index a8fca1b..85fc266 100644 --- a/tests/validation/multigrid/test_fine_surface_gpu.py +++ b/tests/validation/multigrid/test_fine_surface_gpu.py @@ -140,7 +140,8 @@ def run_patch(speed, *, audit=True): build = (patch.object(compiler, "compile_kernel", audit_compiler(compiler.compile_kernel)) if audit else nullcontext()) with build: - backend = implementation.FixedPatchStepper(cfg, BOUNDS, context=context, fine_objects=[source]) + backend = implementation.FixedPatchStepper(cfg, context=context, refinements=[BOUNDS], + level_objects=[(), (source,)]) with backend, context.activate(): c, f = backend._levels cl = backend._fine_curved @@ -325,6 +326,7 @@ def test_cross_interface_donor_rejects_before_cuda(): context.activate.side_effect = AssertionError("must reject before CUDA activation") with patch.object(cuda, "mem_alloc") as allocate: with pytest.raises(ValueError, match="donor crosses"): - implementation.FixedPatchStepper(cfg, BOUNDS, context=context, fine_objects=[source]) + implementation.FixedPatchStepper(cfg, context=context, refinements=[BOUNDS], + level_objects=[(), (source,)]) context.activate.assert_not_called() allocate.assert_not_called() diff --git a/tests/validation/multigrid/test_refinement_gpu.py b/tests/validation/multigrid/test_refinement_gpu.py index efcfd0a..94bd042 100644 --- a/tests/validation/multigrid/test_refinement_gpu.py +++ b/tests/validation/multigrid/test_refinement_gpu.py @@ -84,13 +84,13 @@ class CoupledGPU(unittest.TestCase): cases = (("dense_unshifted", False, {}), ("blocked_shifted", True, - dict(base_block=(4, 4), fine_block=(6, 6)))) + dict(level_blocks=[(4, 4), (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, + with FixedPatchStepper(cfg, context=context, refinements=[(4, 4, 12, 12)], **storage) as backend: self.assertAlmostEqual(backend.patch.tau_coarse, spec.tau_coarse) self.assertAlmostEqual(backend.patch.tau_fine, spec.tau_fine) @@ -148,7 +148,7 @@ class CoupledGPU(unittest.TestCase): maps = ref.build_maps(spec) with CudaContext(0) as context: with PeriodicPatchStepper(LBMConfig(nx=16, ny=16, viscosity=.1), - (4, 4, 12, 12), context=context) as backend: + context=context, refinements=[(4, 4, 12, 12)]) as backend: backend.initialize(*postcollision(ref.make_state(spec), spec, maps)) coarse, fine = backend._levels @@ -187,7 +187,7 @@ class CoupledGPU(unittest.TestCase): with CudaContext(0) as context: with patch.object(compiler, "compile_kernel", audit_compile): - backend = PeriodicPatchStepper(cfg, (4, 4, 12, 12), context=context) + backend = PeriodicPatchStepper(cfg, context=context, refinements=[(4, 4, 12, 12)]) with backend: # Production allocations: four DDF arrays and four compact tables. device_bytes = 2 * 9 * (16**2 + 24**2) * 4 @@ -270,7 +270,7 @@ class CoupledGPU(unittest.TestCase): backend.download() # Compile and execute the actual non-audited entry as well: one step. - with PeriodicPatchStepper(cfg, (4, 4, 12, 12), context=context) as plain: + with PeriodicPatchStepper(cfg, context=context, refinements=[(4, 4, 12, 12)]) as plain: rest = postcollision(ref.make_state(spec), spec, maps) plain.initialize(*rest) plain.step() diff --git a/tests/validation/multigrid/test_refinement_three_level_multipatch_gpu.py b/tests/validation/multigrid/test_refinement_three_level_multipatch_gpu.py index 5b21c66..9d2c9e1 100644 --- a/tests/validation/multigrid/test_refinement_three_level_multipatch_gpu.py +++ b/tests/validation/multigrid/test_refinement_three_level_multipatch_gpu.py @@ -78,10 +78,10 @@ class ThreeLevelMultipatchGPU(unittest.TestCase): def run_case(self, ctx, cfg=CFG, parents=PARENTS, children=CHILDREN, mode='periodic', blocks=((4, 4), (4, 4)), objects=(), drive=(), switch=False, scalar_child=None): - kwargs = dict(child_rectangles_in_parent=children) if scalar_child is None else dict(child=scalar_child) - with FixedPatchStepper(config(cfg, mode), parents, context=ctx, coarse_boundary=mode, - base_block=(4, 4), fine_block=blocks[0], child_block=blocks[1], - child_objects=objects, child_jets=drive, **kwargs) as run: + child = children if scalar_child is None else scalar_child + with FixedPatchStepper(config(cfg, mode), context=ctx, coarse_boundary=mode, + refinements=[parents, child], level_blocks=[(4, 4), blocks[0], blocks[1]], + level_objects=[(), (), objects], level_jets=[(), (), drive]) as run: frame = frames(run) run.initialize(*(physical_state(level.shape[1:], *f) for level, f in zip(run._levels, frame))) diff --git a/tests/validation/multigrid/test_runtime_child_remap_gpu.py b/tests/validation/multigrid/test_runtime_child_remap_gpu.py index 07f5a72..0ebda7f 100644 --- a/tests/validation/multigrid/test_runtime_child_remap_gpu.py +++ b/tests/validation/multigrid/test_runtime_child_remap_gpu.py @@ -26,9 +26,8 @@ FP64_ATOL = 3e-6 def make(ctx): - return FixedPatchStepper(CFG, PARENTS, context=ctx, base_block=(4, 4), - fine_block=(4, 4), child_block=(4, 4), - child_rectangles_in_parent=A) + return FixedPatchStepper(CFG, context=ctx, refinements=[PARENTS, A], + level_blocks=[(4, 4)] * 3) def initial(run, uniform): diff --git a/tests/validation/multigrid/test_shifted_remap_gpu.py b/tests/validation/multigrid/test_shifted_remap_gpu.py index a225194..cbefe9e 100644 --- a/tests/validation/multigrid/test_shifted_remap_gpu.py +++ b/tests/validation/multigrid/test_shifted_remap_gpu.py @@ -22,9 +22,8 @@ B=((20,16,36,40),) def make(ctx): - return FixedPatchStepper(CFG,PARENTS,context=ctx,base_block=(4,4), - fine_block=(4,4),child_block=(4,4), - child_rectangles_in_parent=A) + return FixedPatchStepper(CFG,context=ctx,refinements=[PARENTS,A], + level_blocks=[(4,4)]*3) def initial(run):