Skip to content

feat: Morton placement, a faster regrid transfer, and the quadtree benchmark - #72

Merged
max-models merged 7 commits into
develfrom
claude/tree-d3d-poison-maxwell-atyjic
Nov 25, 2026
Merged

max-models merged 7 commits into
develfrom
claude/tree-d3d-poison-maxwell-atyjic

Conversation

@max-models

@max-models max-models commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • placement="morton": regrid places the patches on the ranks along a Morton curve (morton_ranks). All refined levels share one curve, keyed by the lower corner in cells of the finest level, so a patch and the patches over it tend to share a rank. The curve is cut into runs of about equal cells, counting the cells each rank already holds (the base level). The keys come from cunumpy's morton_encode. A patch added by hand with add_patch goes where "balanced" would put it.
  • The regrid's transfer looks up old patches through the bin index of the halo schedules instead of comparing every pair. It also drops copies that a later copy overwrites entirely: for node fields, an old patch with the same box makes the copies from its neighbours redundant. It skips the interpolation from below for patches that copies cover fully. Results are bit-identical (the last copy of a point still wins). On a mesh of 386 blocks of 8 cells, the serial regrid went from 866 to 277 ms per step.
  • benchmarks/quadtree: a particle-in-cell cycle following a moving beam (tag, regrid, migrate, deposit, solver setup, solve, halos, gather), each step a scope-profiler region. It compares clusters with quadtree blocks of 8, 16 and 32 cells, serially and on 4 ranks with both placements (RESULTS.md).
  • The "Quadtree patches" tutorial gets a section on Morton placement.

Findings (in RESULTS.md):

  • The cost follows the number of patches. At about the same patch count, quadtree blocks cost what clusters cost.
  • The 91–94% of patches a quadtree regrid keeps are not reused yet: halo schedules and composite numbering are rebuilt from scratch.
  • On one node, Morton and balanced placement are equal within the noise.

Checklist

  • pre-commit run and pytest pass (723 passed locally; the quadtree tests also under mpirun -n 2/3/4)
  • New code has docstrings and tests
  • The docs (docs/, tutorials or README.qmd) are updated where the behaviour changed
  • The commit messages follow Conventional Commits (feat:, fix:, docs:, ...)

@max-models
max-models merged commit a8e9bc3 into devel Nov 25, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant