Skip to content

Expose Dask "lazy timeseries" from compatible readers for full parallelism in analysis #4713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ljwoods2 opened this issue Sep 23, 2024 · 4 comments · May be fixed by #4714
Open

Expose Dask "lazy timeseries" from compatible readers for full parallelism in analysis #4713

ljwoods2 opened this issue Sep 23, 2024 · 4 comments · May be fixed by #4714

Comments

@ljwoods2
Copy link
Contributor

ljwoods2 commented Sep 23, 2024

Is your feature request related to a problem?

This idea follows up on @orbeckst's suggestion from a few months ago and a discussion with @hmacdope about making full use of dask in mda.

Current parallelism development allows splitting a trajectory into a number of parts and then combining intermediate results. However, allowing analysis classes to use dask arrays for positions, velocities, forces across the entire trajectory can cover cases that the split-apply-combine paradigm doesn't cover (like RMSF, AFAIK) and potentially lead to greater speedup.

Describe the solution you'd like

A DaskTimeSeriesAnalysisBase which accepts a dasktimeseries as an argument. A dask timeseries is exactly the same as a reader's timeseries except that it is a dask.array rather than a numpy.ndarray, so it is loaded lazily into memory and a dask task graph is created and optimized by dask automatically before .compute() is called.

Describe alternatives you've considered

Do nothing.

Additional context

I provide an extremely minimal example in PR #4714. Here, using dask to perform RMSF rather than in serial leads to a speedup of ~15x

Sample notebook available here: https://github.com/ljwoods2/mdanalysis/blob/dask-timeseries/tmp/lazyts.ipynb

@ljwoods2 ljwoods2 linked a pull request Sep 23, 2024 that will close this issue
5 tasks
@orbeckst
Copy link
Member

Good idea (although RMSF (and anything that computes higher order moments) can be made to work with split-apply-combine, see PMDA RMSF and Nik's report referenced therein).

@ljwoods2
Copy link
Contributor Author

Oh thank you, didn't know that existed, that would be a far better comparison

@RobertArbon
Copy link

Hi folks, I actually implemented trajectory analysis using Dask's dataframe class in a previous job. It was far from perfect but would be happy to work on this. I know you've added this as a project to GSOC (which I can't do) but would be happy to contribute or get something up an running.

@ljwoods2
Copy link
Contributor Author

ljwoods2 commented Apr 7, 2025

@RobertArbon Cool to see other people are interested in this, and thanks for reaching out. Why did you decide to go with dask dataframes instead of dask arrays? MDAnalysis analysis classes rely on the timestep's numpy array storage of the trajectory, so my initial thought was that dask arrays would be an easier conversion and potentially more natural, but it's totally possible I missed the mark.

Is the implementation open source in a fork somewhere? Would love to see your approach.

As far as GSoC, there is no guarantee that someone will actually be accepted for this particular project this year, but that will be decided by early-ish May

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

Successfully merging a pull request may close this issue.

3 participants