Skip to content

bugfix-ncycles-computed#80

Merged
Roy-Haolin-Du merged 8 commits intomichellab:mainfrom
Roy-Haolin-Du:main
May 1, 2026
Merged

bugfix-ncycles-computed#80
Roy-Haolin-Du merged 8 commits intomichellab:mainfrom
Roy-Haolin-Du:main

Conversation

@Roy-Haolin-Du
Copy link
Copy Markdown
Member

Description

Added nmoves as a configurable field and changed ncycles to a computed property

Todos

Added nmoves as a configurable field and changed ncycles to a computed property in engine_config.py to prevent memory overflow from single-cycle runtimes.

Status

  • Ready to go

@Roy-Haolin-Du
Copy link
Copy Markdown
Member Author

Fixes #79 - Adds ncycles support to prevent memory errors.

ncycles_int = round(float(ncycles))

if ncycles_int < 1:
raise ValueError(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I know this was done before for timestep and runtime, but I think it might be better to validate all of this stuff in a validator, rather than in the property. Then, an error will be raised on instantiation/ assignment (we've set it to validate on assignment) rather than later when the user tries to call the property. The property can then just compute ncycles.

Comment thread a3fe/configuration/engine_config.py Outdated
"""
Make sure runtime is a multiple of timestep
Calculate number of cycles from runtime, nmoves and timestep.
Formula: runtime = nmoves × ncycles × timestep
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I might not be remembering how these settings work, but my main comment is: do we know if this will work with adaptive computations where the assigned times may be pretty short? 25000 * 4 fs = 100 ps which is a fairly large smallest runtime. Have you tried this with the adaptive runs?

A simple way to make this more flexible would be to replace nmoves with max_nmoves. This would modify the behaviour of the previous nmoves property so that the behaviour stays as it was unless runtime > max_nmoves * timestep, in which case the nmoves gets e.g. halved and ncycles doubled or something similar. We'll need to be careful to make sure you get a valid nmoves and ncycles in this case (easiest way might be to enforce that runtime must be a multiple of 2 * timestep).

@fjclark
Copy link
Copy Markdown
Collaborator

fjclark commented Feb 28, 2026

Thanks Roy! Mainly looks good but have left a couple of comments.

@Roy-Haolin-Du
Copy link
Copy Markdown
Member Author

Roy-Haolin-Du commented Apr 30, 2026

  • Added max_nmoves as a configurable field in SomdConfig.
  • Made nmoves/ncycles computed properties derived from runtime, timestep, max_nmoves and energy_frequency

This prevents memory overflow from single cycle long runtimes while keeping runtime the SSOT.
Adaptive resubmit grid rounded up to 0.1 ns (stage.py) so requested runtimes always factor cleanly.

  • Old pickle files written before this change lack the max_nmoves field. Test fixtures have been regenerated.
  • Full integration adaptive and non-adaptive test with Slurm and GPU done.

Ready for a version bump.

@Roy-Haolin-Du
Copy link
Copy Markdown
Member Author

Hi Finlay @fjclark would you mind taking a quick look?
I’ve set max_nmoves and determine a reasonable nmoves if long runtime simulations to prevent memory issues.
No worries if you’re busy.
Thanks in advance!

Comment thread docs/guides.rst Outdated
# Works if the calculation has already been setup
calc.update_engine_config_option(timestep=2.0) # fs
# Before setup(): modify the engine_config directly
calc.engine_config.timestep = 2.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Super minor comment, but probably keep the # fs comments here and below

@fjclark
Copy link
Copy Markdown
Collaborator

fjclark commented May 1, 2026

Amazing thanks Roy, looks good to me! Tests look good and thorough! Feel free to merge and bump the version.

Copy link
Copy Markdown
Collaborator

@fjclark fjclark left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@Roy-Haolin-Du
Copy link
Copy Markdown
Member Author

Thanks, Finlay I’ll merge and bump the version.

@Roy-Haolin-Du Roy-Haolin-Du merged commit d2e28ac into michellab:main May 1, 2026
3 checks passed
@Roy-Haolin-Du
Copy link
Copy Markdown
Member Author

close #79

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants