-
Notifications
You must be signed in to change notification settings - Fork 67
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
Reduce memory usage for timeseries jac computation #1001
Conversation
Thank you @johnjasa ! This fixes the issue I was facing. Here is a summary of the memory usage for my Dymos+OAS case. The memory usage is shown in % of the total memory I have on my machine (64GB). Before this fix (Dymos 1.9.0)
And with this fix:
As far as I observe, |
|
||
if rate: | ||
mat = self.differentiation_matrix | ||
else: | ||
mat = self.interpolation_matrix | ||
|
||
for i in range(size): | ||
if _USE_SPARSE: |
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.
The _USE_SPARSE setting was just used to quickly toggle and check performance between sparse and dense implementations. Let's remove the _USE_SPARSE
variable and just assume that we always do so. Any performance benefits of dense are typically only present in smaller problems.
Summary
After a good amount of digging into cases that scaled poorly as number of procs increased, I found a
toarray()
call that was turning a sparse array into a dense before going back to sparse. In the case of @kanekosh's run script with relatively highnum_segments
and a memory-expensive parallel ODE, this caused a large increase in memory usage duringsetup()
.This new implementation keeps the jac in sparse format throughout. I've changed it in the two places where it happened -- and maybe those files could be combined into one? Or @robfalck were they two separate files on purpose?
Prior
setup()
mem usage:Mem usage for
setup()
with the fix:This PR does not address potentially large memory usage in
final_setup()
as that is a separate but related issue regarding howPETScVectors
are created and used. We should further discuss if we have action items there.Related Issues
Backwards incompatibilities
None
New Dependencies
None