Skip to content

feat(cli): support LMDB datasets in dp eval-desc and dp embed - #6161

Draft
Lovlace777 wants to merge 1 commit into
deepmodeling:masterfrom
Lovlace777:feat/lmdb-eval-desc-embed-6034
Draft

Lovlace777 wants to merge 1 commit into
deepmodeling:masterfrom
Lovlace777:feat/lmdb-eval-desc-embed-6034

Conversation

@Lovlace777

Copy link
Copy Markdown

Fixes #6034

Summary

  • Use format-aware process_systems() discovery and is_lmdb() / LmdbTestData / LmdbTestDataNlocView dispatch in deepmd/entrypoints/eval_desc.py and deepmd/entrypoints/embedding.py, matching dp test.
  • Handle single-nloc and mixed-nloc LMDB datasets deterministically without shuffling:
    • Single-nloc LMDB: outputs <basename>.npy (dp eval-desc) and HDF5 group <basename> with system=<path> (dp embed) in ascending LMDB storage order.
    • Mixed-nloc LMDB: partitions frames by ascending nloc (preserving ascending LMDB storage order within each group) into <basename>_nloc<N>.npy (dp eval-desc) and HDF5 group <basename>_nloc<N> with system="<path> [nloc=<N>]" (dp embed).
    • De-duplicate colliding output stems/group names across discovered systems (_1, _2, ...) and skip empty LMDBs cleanly with a warning.
  • Register optional conditioning inputs (fparam, aparam, charge_spin) consistently in eval_desc (checking find_* != 0.0) so deepmd/npy and deepmd/lmdb produce identical results.
  • Document LMDB input discovery, ordering, and output/group naming in deepmd/main.py, doc/inference/embedding.md, and doc/test/test.md.

Verification

  • Added source/tests/pt/test_lmdb_eval_desc_embed.py (9 tests) covering:
    • Single-nloc LMDB vs deepmd/npy parity (reversed type_map, unused element in LMDB type_map, unsorted atom order) for both dp eval-desc and dp embed (rtol=1e-12, atol=1e-12).
    • Interleaved mixed-nloc (3, 6, 9 atoms) LMDB deterministic ordering, naming, and numerical parity against equivalent deepmd/npy systems.
    • Recursive parent-directory discovery mixing deepmd/npy, .lmdb, and plain data.mdb directories, collision de-duplication, source-directory immutability, -f datafile input, and empty LMDB handling.
    • Non-PBC (nopbc), fparam/aparam + default fallback (se_e2_a), charge_spin + default fallback (pt_expt dpa4c), and dpdata.MultiSystems.to("deepmd/lmdb") parity.
  • Before fix: tests fail on master with RuntimeError: Did not find valid system (via -s) and FileNotFoundError: No set.* is found (via -f).
  • After fix:
    • pytest source/tests/pt/test_lmdb_eval_desc_embed.py -v -> 9 passed
    • pytest source/tests/pt/model/test_embedding.py source/tests/pt_expt/infer/test_embedding.py::test_dpa4_command_reads_the_conditions_of_the_system -v -> 8 passed, 1 skipped
    • ruff check, ruff format --check, and isort --check pass cleanly on all modified/added Python files.

@njzjz-bot njzjz-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agent: dot. The new LMDB paths in both eval-desc and embed can silently discard inputs in a mixed-availability batch. LmdbTestData._stack_frames AND-reduces find_* across the whole same-size group. For example, if one frame provides DPA4C charge_spin=[1,2] and a second frame omits it, both frames are evaluated with the model default. The regression tests cover all-present and all-absent inputs, not this mixed case. Please preserve supplied per-frame values and apply defaults only for missing frames, or reject mixed availability explicitly. This is a source-level finding; I did not run a model reproducer.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support LMDB datasets in dp eval-desc and dp embed

2 participants