Commit b534a1c
authored
feat(lmdb): support mixed-size batches and lazy label availability (#5962)
## Summary
- support `mix:N` LMDB batches containing frames with different atom
counts, using padded rectangular batches for dense models and a flat
ragged node axis for eligible graph models
- compact phantom atoms before graph-model evaluation and make loss
reductions, validation weighting, and epoch sizing use real atom counts
- resolve label availability lazily after data requirements are
registered, so required, optional, defaulted, and partially available
fields are handled without an eager full-dataset scan
- keep non-mixing and native-spin models on their existing rectangular
public paths; the ragged regression coverage uses upstream DPA1 and
avoids model-specific dependencies
## Behavioral changes
- Masked per-atom loss terms now pool all included labels across the
batch instead of averaging per-frame means. This intentionally retires
the bit-identical reduction guarantee from #5738/#5783 for existing
`mixed_type` NPY datasets whose frames have different real atom counts:
those frames are weighted by their real label counts rather than
equally. Uniform-atom-count batches are unchanged. Hessian pair terms
remain normalized per frame so their quadratic component count does not
make large structures dominate a batch.
- Legacy LMDB files have no exact per-frame label-availability metadata.
To avoid an eager O(N) startup scan, the reader uses a bounded probe and
conservatively reduces per-frame `find_*` flags at collation. A missed
rare signature may discard valid supervision for the affected batch, but
default-filled values are never treated as real labels. Recording exact
availability metadata when generating LMDB datasets is tracked in #5954.
## Testing
- all pre-commit hooks passed for the changed files
- 375 passed, 2 skipped, 1 deselected, and 13 subtests passed in the
main targeted LMDB/PT/PT-expt/model suite
- 15 passed in the isolated loss-reduction and decoder-pool regression
suite
- review fixes: 100 passed, 2 skipped, and 2 subtests passed in the
common loss suite; 60 passed in the PT padding-loss suite; all 25 LMDB
training tests passed; padded/unpadded DPA2 graph and Hessian parity
tests passed
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Added LMDB batching for frames with different atom counts, including
mixed-size and ragged layouts.
- Added ragged-batch inference and training for supported energy and
spin models.
- Added configurable data-source policies for optional labels and
parameters.
- Added safer handling of padded atoms across neighbor graphs and model
outputs.
- **Bug Fixes**
- Improved per-atom loss normalization for uneven and padded batches.
- Prevented padded atoms from affecting neighbor searches, metrics, or
losses.
- Improved handling of missing labels and default-valued data.
- **Documentation**
- Documented mixed-size batching, ragged data, and per-atom
normalization.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Closes #59651 parent 62cd093 commit b534a1c
69 files changed
Lines changed: 7533 additions & 1655 deletions
File tree
- deepmd
- dpmodel
- descriptor
- loss
- model
- utils
- neighbor_graph
- pt_expt
- model
- train
- utils
- pt
- loss
- model/model
- train
- utils
- utils
- doc
- data
- train
- source/tests
- common/dpmodel
- consistent
- pt_expt
- descriptor
- loss
- model
- utils
- pt
- model
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
38 | 46 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2186 | 2186 | | |
2187 | 2187 | | |
2188 | 2188 | | |
2189 | | - | |
| 2189 | + | |
2190 | 2190 | | |
2191 | 2191 | | |
2192 | 2192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
0 commit comments