Hi,
I am working on some interdigitated membranes formed by C18:0 and C18:1 glycolipids. Since these systems often exhibit very corrugated surfaces, I started using the Willard–Chandler approach to compute the surface of each leaflet in order to analyze properties such as surface corrugation, skewness, and bending rigidity (for which experimental values exist). This is why I began using pytim.
However, my systems are relatively large (100–120k atoms), and pytim.WillardChandler proved to be quite slow. To address this, I replaced the neighbour-list construction and gaussian_kde_pbc.py with a C++17/pybind11 implementation, adding simple OpenMP parallelism where possible. The new code is about 9× faster than the original. Results from the accelerated version are nearly identical to SciPy’s, though I do observe very small differences in the computed Willard–Chandler surfaces. I suspect these stem from algorithmic details in the neighbour search, but I cannot be completely certain.
I also tested a few branches from a-ws-m, but did not find measurable performance improvements compared to the original pytim. In a previous issue he was talking about JAX, but I couldn't find this extension in his code. Keep in mind that part of the C++ implementation was generated with Codex, but I carefully verified the code and the results for consistency. If you could review the changes and perhaps test them against your own benchmarks, that would help confirm nothing fundamental is wrong. I find that AI is very usefull to understand a code you haven't written, although its hallucinations are sometime quite unsettling.
Here is a summary of what has been changed:
- Replaced the Python/SciPy neighbour search with a C++17/pybind11 module (pytim/_wc_kde.cpp) that bins grid points into periodic cells and accumulates the Gaussian kernel in an OpenMP-parallel loop.
- Updated pytim/gaussian_kde_pbc.py so that it uses the new neighbour-search path automatically, falling back to the SciPy/KD-tree routine if the extension is not available.
- Added a regression benchmark (benchmarks/willard_chandler_kde.py), integrated it into CI to enforce a minimum speed-up, and updated documentation (docs/source/quick.rst) and the changelog.
And how it was done
- The extension is built with C++17 + OpenMP flags (via setup.py), releasing the GIL inside the loops; atomic updates ensure thread safety.
- The neighbour cutoff remains at 2.5·σ, so behavior "should" be unchanged, but faster.
- Documentation now highlights the new build requirements (pybind11, OpenMP) and describes how to run the benchmark.
Best regards,
Massimo MARCHI
Hi,
I am working on some interdigitated membranes formed by C18:0 and C18:1 glycolipids. Since these systems often exhibit very corrugated surfaces, I started using the Willard–Chandler approach to compute the surface of each leaflet in order to analyze properties such as surface corrugation, skewness, and bending rigidity (for which experimental values exist). This is why I began using pytim.
However, my systems are relatively large (100–120k atoms), and pytim.WillardChandler proved to be quite slow. To address this, I replaced the neighbour-list construction and gaussian_kde_pbc.py with a C++17/pybind11 implementation, adding simple OpenMP parallelism where possible. The new code is about 9× faster than the original. Results from the accelerated version are nearly identical to SciPy’s, though I do observe very small differences in the computed Willard–Chandler surfaces. I suspect these stem from algorithmic details in the neighbour search, but I cannot be completely certain.
I also tested a few branches from a-ws-m, but did not find measurable performance improvements compared to the original pytim. In a previous issue he was talking about JAX, but I couldn't find this extension in his code. Keep in mind that part of the C++ implementation was generated with Codex, but I carefully verified the code and the results for consistency. If you could review the changes and perhaps test them against your own benchmarks, that would help confirm nothing fundamental is wrong. I find that AI is very usefull to understand a code you haven't written, although its hallucinations are sometime quite unsettling.
Here is a summary of what has been changed:
And how it was done
Best regards,
Massimo MARCHI