Vectorize subcolumn loop, enhance parallelism, and update dependencies - #161
Merged
Conversation
In set_convective_sub_col_frac: Replace nested for-i/for-k loop with a single broadcast expression: conv_profs = (np.arange(1, N+1)[:, None, None] <= data_frac[None, :, :]) in _allocate_strat_sub_col: - np.argwhere → np.flatnonzero for overlying_locs1/2 - Replace all locals()["overlying_locs%d" % (Iover_min/max + 1)]
…lumn.py`)
In set_stratiform_sub_col_frac / set_precip_sub_col_frac / set_q_n:
- Replace lambda closures with functools.partial so the worker callable is
picklable by both Dask and multiprocessing backends.
- Add a second parallel call path: parallel='processes' uses
ProcessPoolExecutor + tqdm (lower overhead on a single workstation);
parallel=True or 'dask' (default, unchanged behaviour) uses dask.bag +
dask.diagnostics.ProgressBar (compatible with multi-node Dask schedulers on HPC).
parallel=False runs serially as before.
- Remove the manual chunked while-loop that was a workaround for Dask task-queue
freezes caused by unpicklable lambdas; no longer needed.
- Add a labelled progress indicator for each path: desc= label on tqdm bars
('processes'), and a matching print label immediately before each ProgressBar
context (Dask).
dependencies:
- Add numba and tqdm to requirements.txt, setup.py install_requires, and all five
conda environment YMLs under continuous_integration/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements to the parallel processing capabilities and dependency management for the subcolumn module. The main focus is on enhancing flexibility and performance for parallel execution, simplifying code paths, and ensuring all required dependencies are explicitly listed.
Dependency and Environment Updates:
tqdmto the dependenciesParallelization and Code Structure Improvements:
subcolumn.pyAlgorithmic and Code Quality Improvements:
These changes collectively enhance the usability, flexibility, and performance of the simulation code, especially for users running on different hardware setups or requiring better progress monitoring during parallel execution.