feat: add mixed-resolution embedding index for stretched mesh#229
Conversation
|
@jacobbieker these are the small, independent building blocks for the stretched-grid regional model, The PR that wires all three into RegionalForecaster is next and depends on them. No rush - whenever you get a chance. |
|
@jacobbieker these are the small, independent building blocks for the stretched-grid regional model, all off main: #227 (latent graph over the mixed-res mesh, coarse/fine seam stitched), #228 (assign observation points to the right-size cell), and #229 (mixed-resolution embedding index so a moving region keeps its learned per-cell vectors). Each is pure h3 with its own tests. The PR that wires all three into RegionalForecaster is next and depends on them. No rush - whenever you get a chance. |
|
Looks good, thanks for this! If you can fix the branch conflicts, we can then merge this |
7c86a7f to
9817560
Compare
|
Thanks @jacobbieker 😊 Rebased on main, conflicts resolved. Ready whenever you are. |
Pull Request
Description
Adds
mixed_resolution_embedding_indices, the piece that lets a stretched mesh use a learnable embedding per H3 cell. On a single-resolution mesh the model keeps one embedding table indexed by cell, but a stretched mesh mixes coarse and fine cells, so one table indexed by a single resolution no longer fits.This maps each mesh cell to a
(resolution, row). The row is the cell's position insorted(uncompact_cells(get_res0_cells(), res)), the same global numberingDynamicGraphBuilderalready uses. Because the row depends only on the cell, a location keeps the same row no matter which mesh it lands in, so a moving region reuses the vector it already learned for that spot instead of relearning it after every move.Pure function, no model or training changes yet. The model wiring that gathers from two per-resolution tables (coarse and fine) using these indices comes in a later PR. This is the third building block for the stretched-grid model, after the mesh builder (#226) and alongside the latent graph (#227) and point assignment (#228).
Related to #3
How Has This Been Tested?
Added tests to
tests/test_stretched_mesh.py- plain pytest, runs entirely on h3, no network:(resolution, row)per cell, resolution matching the cellCommands:
pytest tests/test_stretched_mesh.py -q-> 12 passedruff check graph_weather/models/layers/stretched_mesh.py tests/test_stretched_mesh.py-> cleanChecklist: