Expose MMFF forcefield API to python#119
Conversation
scal444
commented
Mar 25, 2026
Add Python bindings for MMFF batched forcefield energy and gradient computation via Boost.Python. Includes property bridge from RDKit MMFFMolProperties to internal MMFFProperties transport. - NativeMMFFBatchedForcefield C++ binding with compute_energy/compute_gradients - MMFFBatchedForcefield Python wrapper with per-molecule properties, conf_id, nonBondedThreshold, and ignoreInterfragInteractions support - _mmff_bridge module for RDKit MMFFMolProperties to native conversion - MMFFComputeEnergies/MMFFComputeGradients convenience functions - Tests for single-mol, batched, property variants, per-molecule properties, and conformer id selection vs RDKit reference Made-with: Cursor
|
| Filename | Overview |
|---|---|
| nvmolkit/batchedForcefield.cpp | New C++ Boost.Python extension exposing NativeMMFFBatchedForcefield with compute_energy/compute_gradients; CUDA error checking, async device-vector copy pattern, and gradient splitting all look correct. |
| nvmolkit/batchedForcefield.py | Python wrapper normalising scalar/per-molecule properties, conf_ids, thresholds, and lazy-building the native forcefield; minor issues: missing MMFFComputeEnergies/Gradients convenience functions and a redundant num_molecules attribute alongside len. |
| nvmolkit/_mmff_bridge.py | New bridge module converting RDKit MMFFMolProperties to nvMolKit's internal transport; uses WeakKeyDictionary to avoid the prior id()-based memory leak and uses fallback getters for externally-created properties objects; error message when a getter is missing could be more specific. |
| nvmolkit/tests/test_batched_forcefield.py | Comprehensive test suite covering single-mol, batched, property variants, per-molecule properties, and conformer id selection against RDKit reference values; tolerances and helper utilities look appropriate. |
| nvmolkit/CMakeLists.txt | Adds _batchedForcefield MODULE target following the same pattern as existing targets; link libraries and include directories look consistent with the rest of the build file. |
Reviews (2): Last reviewed commit: "Address review comment" | Re-trigger Greptile
evasnow1992
left a comment
There was a problem hiding this comment.
Thank you for exposing batch energy and gradients computation APIs to python. Changes look good to me.