-
Notifications
You must be signed in to change notification settings - Fork 20
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
Richardson Lucy Parallelization V2 #274
Open
avalluvan
wants to merge
50
commits into
cositools:develop
Choose a base branch
from
avalluvan:feature/RLparallel
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
79109f3
Added new option "RLparallel" to ImageDeconvolution.deconvolution_alg…
avalluvan c918ab5
Renamed RLparallel.py to RichardsonLucyParallel.py and adapted code s…
avalluvan 015f648
Installed mpi4py to cosipy venv and added it to skeleton
avalluvan f259d36
Created subprocess call. Ported MPI to separate script RLparallelscri…
avalluvan 4cde4dd
Added code to register results if save_results_flag is set to True
avalluvan e98fb79
End-to-end working script version commit
avalluvan cd45e44
Unclear what files are causing conflicts
avalluvan ef279f4
Add modified files and new RL parallel script
avalluvan 871c9a8
Another tiny change
avalluvan 27c8afe
Modified configuration file for RLparallel
avalluvan f079988
Merge branch 'cositools:develop' into develop
avalluvan f044589
git fetch changes unclear. Performing a commit to avoid data loss.
avalluvan 3036a7a
This merge may result in data losses. Copies of files have been creat…
avalluvan 35b8293
Create LMDR.ipynb and add response creation attempt with h5py.
avalluvan d04f3c3
Created general code for multidimensional interpolation
avalluvan ac47f23
Attempted listmode response on the fly generation
avalluvan c257676
Add ListModeResponse.py
avalluvan 7de27fd
Used histpy functions to dramatically simplify the codebase
avalluvan 4c23188
Modified code to accept len(dr.axes) or len(dr.axes)-1 number of inputs.
avalluvan 71085fd
Added comments to get_point_source_response()
avalluvan dc35034
Tested new interpolation scheme on LMDR.ipynb
avalluvan f8bbaa4
Adhoc fix for interpolated psr calculation with deepcopy
avalluvan cdcb9b0
Simplified __getitem__ and get_point_source_response()
avalluvan aaff648
Ported ListModeResponse interpolation functionalities to DetectorResp…
avalluvan caa2d44
Removed ListModeResponse.py. All developed features incorporated in D…
avalluvan 2c80caa
Merge pull request #1 from avalluvan/feature/general_response
avalluvan dafd4f8
Added code to compress empty axes, i.e., those with axis shape = (1,)
avalluvan de31c0a
Create new file RichardsonLucyWithParallelSupport.py. Stash changes t…
avalluvan ebdf1ca
Skeleton for RLWithParellelSupport.py. Need to update MPI.DOUBLE with…
avalluvan 9aeba42
Looks like RLWithParallelSupport.py is complete. Need to create data …
avalluvan b1d61a4
Everything up to run_deconvolution works with new data interface WPS
avalluvan 61afc80
Dry run with single MPI process works with RichardsonLucy and dataIFW…
avalluvan 75b0b81
RichardsonLucyWPS.py works with both dataIF_DC2 and dataIFWPS for sin…
avalluvan 5d5eb3e
Working set up for small numproc MPI runs
avalluvan 59f9ce8
Syntactically correct. Algorithm has some discrepancies
avalluvan 406cf9a
Archive old version of RLparallelscript.py and RichardsonLucyParallel.py
avalluvan 2eb7e25
Single and multi process produce same, exact outputs!
avalluvan 1cd0d2c
Replaced old RichardsonLucy.py with new RichardsonLucy.py that now su…
avalluvan 1f4eeed
Minor bug in image_deconvolution now that RichardsonLucyParallel.py h…
avalluvan 14c34fd
Removed unnecessary imports in new RichardsonLucy.py
avalluvan 860b5ce
Added comments. Removed stubs of RLparallel. Ready to rebase and crea…
avalluvan 63527db
Migrated RichardsonLucy slicing and message passing to DataIFWithPara…
avalluvan 82fc4f8
Merge branch 'develop' into feature/RLparallel
avalluvan c085c17
Bug fix in reshaping and concatenating epsilon and C slices
avalluvan 279f6f2
Replacing superfluous edits with files from cositools/develop
avalluvan 04eb674
Undo changes to dataIF_COSI_DC2.py and allskyimage.py
avalluvan b99ff6a
Undoing changes to RichardsonLucy.py Estep structure
avalluvan cddaa24
Incorporated review suggestions about placement of parallel_computati…
avalluvan 7a2f65c
Rename dataIFWithParallel.py to dataIF_Parallel.py. Undo changes to i…
avalluvan 17aae47
Calculate parallel and master_node flags in RLparallelscript.py
avalluvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from pathlib import Path | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
from mpi4py import MPI | ||
from histpy import Histogram | ||
|
||
from cosipy.response import FullDetectorResponse | ||
from cosipy.image_deconvolution import ImageDeconvolution, DataIF_Parallel, DataIF_COSI_DC2 | ||
|
||
# Define MPI variables | ||
MASTER = 0 # Indicates master process | ||
DRM_DIR = Path('/Users/penguin/Documents/Grad School/Research/COSI/COSIpy/docs/tutorials/data') | ||
DATA_DIR = Path('/Users/penguin/Documents/Grad School/Research/COSI/COSIpy/docs/tutorials/image_deconvolution/511keV/GalacticCDS') | ||
|
||
def main(): | ||
''' | ||
Main script to create a parallel execution-compatible | ||
dataset using DataIF_Parallel and call ImageDeconvolution | ||
''' | ||
|
||
# Set up MPI | ||
comm = MPI.COMM_WORLD | ||
|
||
# Create dataset | ||
dataset = DataIF_Parallel(name = '511keV', | ||
event_filename = '511keV_dc2_galactic_event.hdf5', | ||
bkg_filename = '511keV_dc2_galactic_bkg.hdf5', | ||
drm_filename = 'psr_gal_511_DC2.h5', | ||
comm = comm) # Convert dataset to a list of datasets before passing to RichardsonLucy class | ||
|
||
# bkg = Histogram.open(DATA_DIR / '511keV_dc2_galactic_bkg.hdf5') | ||
# event = Histogram.open(DATA_DIR / '511keV_dc2_galactic_event.hdf5') | ||
# image_response = Histogram.open(DRM_DIR / 'psr_gal_511_DC2.h5') | ||
# dataset = DataIF_COSI_DC2.load(name = "511keV", # Create a dataset compatible with ImageDeconvolution: name (unique identifier), event data, background model, response, coordinate system conversion matrix (if detector response is not in galactic coordinates) | ||
# event_binned_data = event.project(['Em', 'Phi', 'PsiChi']), | ||
# dict_bkg_binned_data = {"total": bkg.project(['Em', 'Phi', 'PsiChi'])}, | ||
# rsp = image_response) | ||
|
||
# Create image deconvolution object | ||
image_deconvolution = ImageDeconvolution() | ||
|
||
# set data_interface to image_deconvolution | ||
image_deconvolution.set_dataset([dataset]) | ||
|
||
# set a parameter file for the image deconvolution | ||
parameter_filepath = DATA_DIR / 'imagedeconvolution_parfile_gal_511keV.yml' | ||
image_deconvolution.read_parameterfile(parameter_filepath) | ||
|
||
parallel_computation = True | ||
if comm.Get_rank() == MASTER: | ||
master_node = True | ||
else: | ||
master_node = False | ||
|
||
# Initialize model | ||
image_deconvolution.initialize(parallel_computation = parallel_computation, | ||
master_node = master_node) | ||
|
||
# Execute deconvolution | ||
image_deconvolution.run_deconvolution() | ||
|
||
# MPI Shutdown | ||
MPI.Finalize() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that RL needs to know if it is performed on the master node and needs this kind of parameter. I would suggest preparing two parameters alternatively, something like
I want to prepare a parameter that explicitly tells if the computation is in parallel or not. I will add some suggestions regarding these changes at other lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the ideas we discussed in a previous meeting was to let the program directly infer if it was being run in serial or parallel mode. In fact, the suggested flag variables were what I used in the initial V2 pull request code. Do you recommend making this modification, i.e, inferring self.parallel_computation in
image_deconvolution.py
or inRichardsonLucy.py
. The issue with inferring this in the image deconvolution class is - what happens when we have multiple input datasets? --> [dataset1, dataset2, ...], each dataset will have its own "sub_comm" object.