Commit 56151a8
authored
feat(mesh/io): zarr save/load for Mesh and DomainMesh via tensordict's zarr backend (NVIDIA#1894)
* feat(mesh/io): zarr save/load for Mesh and DomainMesh via tensordict backend
Delegates all serialization to tensordict's upstream zarr storage backend
(to_zarr/from_zarr, pytorch/tensordict#1754) and adds only what tensordict
cannot know: chunk/compression policy aligned to training subsample sizes,
and a root attr recording the mesh type so from_zarr can rebuild
Mesh/DomainMesh from the plain PersistentTensorDict the backend returns.
MeshReader/DomainMeshReader route zarr groups (zarr.json present) to
mesh.io.from_zarr; everything else in the dataloader path is unchanged.
Includes a scoped workaround for a tensordict bug where to_zarr
chunks/compressors kwargs are silently dropped for nested leaves.
* Address review: nested trees, recursive glob, zarr subsample push-down, tests
- from_zarr: recursive _read_tree returning TensorDict, so nested
TensorDict fields round-trip (review); shared by eager and windowed reads.
- Readers: restore recursive '**' discovery (glob.glob recursive=True).
- Subsample push-down for zarr stores: with subsample_n_cells/points set,
readers fetch only the selected window (contiguous row-runs; cell meshes
gather referenced points and compose measure weights) instead of
materializing the full mesh. Bitwise-identical to eager load + in-memory
subsample under the same seed.
- test/mesh/io/io_zarr: round-trip, nested fields, point clouds, subgroup
loads, layout policy on nested leaves, reader routing, push-down
equivalence, mixed-format discovery, plus a committed golden store
guarding on-disk format stability.
- CHANGELOG entries for the feature and the glob fix.
* Cache zarr store handles in readers; consolidate metadata on write
Cold-metadata cost fix: readers re-opened each case's store per draw,
walking the group-metadata chain -- on Lustre every uncached lookup is a
metadata-server round-trip, so the first epochs on a metadata-cold client
paid it per sample per epoch. Handles are now cached per reader (opened
once per case), and to_zarr consolidates metadata so the one remaining
open costs a single read instead of one per group.
* Address review: drop upstream workaround, top-level tensordict import, fixture-generated format contract
- Remove _propagate_nested_create_kwargs: fixed upstream in
pytorch/tensordict#1759 (merge is gated on the tensordict pin, which
will include it).
- tensordict imported at module top (core dependency); drop the runtime
backend checks for the same reason.
- Replace the committed golden store with a session-fixture store plus
explicit on-disk contract assertions (group paths, attrs, dtypes,
chunking, codecs) -- format drift still fails a test, without binary
files in the repo.1 parent c0740bd commit 56151a8
8 files changed
Lines changed: 778 additions & 5 deletions
File tree
- physicsnemo
- datapipes/readers
- mesh/io
- test/mesh/io/io_zarr
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
373 | 379 | | |
374 | 380 | | |
375 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
376 | 386 | | |
377 | 387 | | |
378 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
131 | 199 | | |
132 | 200 | | |
133 | 201 | | |
| |||
215 | 283 | | |
216 | 284 | | |
217 | 285 | | |
218 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
219 | 291 | | |
220 | 292 | | |
221 | 293 | | |
222 | 294 | | |
223 | 295 | | |
224 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
225 | 329 | | |
226 | 330 | | |
227 | 331 | | |
| |||
406 | 510 | | |
407 | 511 | | |
408 | 512 | | |
409 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
410 | 518 | | |
411 | 519 | | |
412 | 520 | | |
413 | 521 | | |
414 | 522 | | |
415 | | - | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
416 | 570 | | |
417 | 571 | | |
418 | 572 | | |
| |||
533 | 687 | | |
534 | 688 | | |
535 | 689 | | |
536 | | - | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
537 | 696 | | |
538 | 697 | | |
539 | 698 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
0 commit comments