MPI Message Size Fix (NGWPC-11089) - #225
Conversation
|
Would |
The PR description confused me since the picking/depickling described made me think Here is another uses of |
|
Here's another existing |
|
In this particular place, For the 2D numpy array, numpy arrays are always stored in contiguous C arrays. If you have an array of shape |
|
It's nice that a xarray.Dataset is picklable so |
mxkpp
left a comment
There was a problem hiding this comment.
This approach is reasonable, approving, but is somewhat wasteful of memory. I needed to increase my environment's memory to be able to run the forcing pytest for the AnA case with mpirun -n 2.
- It is creating a pickled representation of the entire
Dataset - It is creating a list of all the chunks before iterating through them.
If the increased memory usage needs to be mitigated, I think 2) should be revised so that the chunks are processed JIT.
|
Update made to let it iterate over the pickled bytes instead of building a list. This is a double-edged sword since we're no longer clearing memory after we use it, but it does decrease overhead of creating copies of the end data as it's chunked. Primarily, I've increased the cutoff for when chunking happens and decreased the chunk size significantly. This will mean more MPI messages need to be sent, but it prevents needing 1.5 GB of memory to be allocated for each chunk. |
|
On the topic of trying to use As for attempting to |
MPI broadcasts have a data size limit of ~2 GB due to a 32-bit integer being used for messaging the number of bytes passed. Some of the xarray Datasets we are passing surpass this size limit, leading to an exception being thrown in some areas.
The changes made address this by checking the size of the Dataset before passing, and if it exceeds 1.5 GB, the Dataset will be pickled by MPI root, split into 1.5 GB chunks, then broadcasted to the other ranks to be merged and depickled. Attempts were made in this process to limit memory usage during this process as, at minimum, you're duplicating an object that is at least 1.5 GB in size.
The 1.5 GB size was chosen to attempt a sizable buffer before hitting the 32-bit size limit. MPI seems to have a custom pickling system when they transfer python objects, and I'm unsure how much overhead gets added to an object during the pickling process. I've been able to confirm that 1.5 GB is a very safe number to use to fix the problem, but it might be worth experimenting with larger numbers if we notice a significant slowdown from the chunking overhead.
Additions
Removals
Changes
Testing
Screenshots
Notes
Todos
Checklist
Testing checklist
Target Environment support