Skip to content

Introduce Deterministic Frame Map-Reduce Execution for Scalable LevelDAG Processing#359

Merged
harryswift01 merged 4 commits into
mainfrom
358-feature-restructure-frame-parallel-execution
Jun 16, 2026
Merged

Introduce Deterministic Frame Map-Reduce Execution for Scalable LevelDAG Processing#359
harryswift01 merged 4 commits into
mainfrom
358-feature-restructure-frame-parallel-execution

Conversation

@harryswift01

Copy link
Copy Markdown
Member

Summary

This PR refactors the hierarchy-level frame execution pathway into a deterministic frame/chunk map-reduce architecture.

The main purpose is to separate workflow orchestration from frame execution, Dask scheduling, worker task construction, and parent-side reduction. LevelDAG now owns the high-level workflow order, while the new levels.execution package owns chunking, scheduling, worker-side frame tasks, and deterministic reduction of covariance and neighbour outputs.

This PR also moves frame-dependent neighbour counting into the frame/chunk execution path, so each frame task now computes both covariance and neighbour-count contributions. Conformational/dihedral map-reduce is intentionally left for a follow-up PR.

Changes

Add frame map-reduce execution layer:

  • Added a new CodeEntropy.levels.execution package for frame execution infrastructure.
  • Added deterministic frame chunking via chunk_frame_indices.
  • Added ExecutionPolicy to keep chunk size and in-flight task limits internal.
  • Added FrameScheduler to choose between serial execution and Dask execution.
  • Added bounded Dask frame-chunk submission with deterministic chunk-order reduction.
  • Added compact worker task/result types for frame-chunk execution.

Move reduction out of LevelDAG:

  • Moved covariance reduction logic into CovarianceReducer.
  • Moved neighbour total/sample reduction into NeighborReducer.
  • Added stable key ordering for deterministic parent-side reductions.
  • Added merge helpers for combining frame-level and chunk-level running means.
  • Removed frame reduction, Dask submission, and worker payload construction responsibilities from LevelDAG.

Move neighbour counts into the frame path:

  • Replaced trajectory-wide neighbour averaging with frame-local neighbour-count payloads.
  • Added per-frame neighbour totals and sample counts as mergeable map outputs.
  • Kept symmetry number and linearity calculation as static metadata because they do not vary by frame.
  • Final neighbour averages are now computed after all frame/chunk outputs have been reduced.

Simplify LevelDAG and FrameGraph responsibilities:

  • LevelDAG now focuses on static setup, neighbour metadata initialisation, frame-stage delegation, and finalisation.
  • FrameGraph now only owns frame-local DAG execution and trajectory positioning.
  • Removed old LevelDAG private helpers for Dask execution and covariance reduction.
  • Removed the static neighbour node from the static DAG.

Update tests and documentation:

  • Added atomic unit tests for the new execution modules.
  • Updated tests to reflect the new ownership boundaries.
  • Added/updated Google-style docstrings across the refactored frame execution modules.
  • Preserved the existing conformational state output contract.

Impact

  • Makes the frame execution architecture easier to reason about and test.
  • Reduces LevelDAG complexity by moving low-level execution and reduction details into dedicated modules.
  • Enables scalable frame/chunk execution for serial and Dask workflows.
  • Moves neighbour counting into the frame-parallel path, increasing the useful work performed per frame task.
  • Keeps parent-side reductions deterministic even when Dask futures complete out of order.
  • Provides infrastructure for a future conformational/dihedral map-reduce refactor.
  • Keeps conformational analysis in the static stage for now to avoid mixing a larger multi-pass refactor into this PR.
  • Preserves existing scientific output contracts while improving execution structure.

@harryswift01 harryswift01 added this to the 2.3.0 milestone Jun 15, 2026
@harryswift01 harryswift01 self-assigned this Jun 15, 2026
@harryswift01 harryswift01 added the feature request New feature or request label Jun 15, 2026
@harryswift01 harryswift01 requested a review from jimboid June 16, 2026 09:23

@jimboid jimboid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR brings a necessary refactor to enable further enhancements to the parallel execution model. The PR is complete with the required code changes, docs and unit tests completed in one pass. The regression tests have not changed which is a very healthy sign that the changes brought here, although extensive are still delivering the same scientific outputs.

@harryswift01 harryswift01 merged commit 3efc3fa into main Jun 16, 2026
44 of 45 checks passed
@harryswift01 harryswift01 deleted the 358-feature-restructure-frame-parallel-execution branch June 16, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Restructure frame-parallel execution to include heavier frame-dependent stages

2 participants