⚡ Bolt: Optimize conformer benchmark loops#590
Conversation
…d hoisting means Replaced slow pandas `iterrows` with `itertuples` during benchmark reference energy parsing. Cached the heavy `get_atoms` operations to avoid redundant file I/O operations and translated calculations, and hoisted $O(N)$ calculations (e.g. `np.mean()`) out of inner loops. Cleared `atoms.calc` before disk write to avoid regenerating stale calculators. Co-authored-by: alinelena <3306823+alinelena@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
Replaced
df.iterrows()withdf.itertuples()for parsing reference energies. In theMPCONF196andsolvMPCONF196benchmark logic, cached the parsedase.Atomsstructures to avoid repeatedly reading the same structures from disk. Hoistednp.meancalculations out of the main loop. Explicitly clearedatoms.calcon the cached structures right before writing the metadata-annotated versions to disk.🎯 Why:$O(N)$ work inside an $O(N)$ loop.
The application was performing redundant disk operations by calling
get_atoms()(which reads an .xyz file) in consecutive loops over the same set of molecules. Additionally, computingnp.meaninside a loop results in redundantdf.iterrows()is notoriously slow compared todf.itertuples().📊 Impact:
Significantly reduces file I/O operations during the conformer benchmarks (reduces reads by exactly half per target) and reduces redundant arithmetic, dropping the calculation logic's runtime.
🔬 Measurement:
Run the conformer calculation pipelines using
uv run pytest ml_peg/calcs/conformers/MPCONF196/calc_MPCONF196.pyanduv run pytest ml_peg/calcs/conformers/solvMPCONF196/calc_solvMPCONF196.py. The output geometries will be exactly the same as before.PR created automatically by Jules for task 11023888217711457893 started by @alinelena