-
Notifications
You must be signed in to change notification settings - Fork 279
Allow for list of int. Only project active times #1689
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
base: main
Are you sure you want to change the base?
Conversation
(cherry picked from commit 1dfafa5)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1689 +/- ##
==========================================
- Coverage 85.79% 85.24% -0.56%
==========================================
Files 427 427
Lines 55506 55509 +3
Branches 5189 5188 -1
==========================================
- Hits 47623 47320 -303
- Misses 6466 6736 +270
- Partials 1417 1453 +36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lheagy
left a comment
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.
Thanks for this @domfournier! This is a nice update. I ran it for a simple example and am seeing about a 5-10% speed-up, which is meaningful!
It looks like some of the EM tests are failing. I can take a look. I see the pr is still a draft. Is there something else you would like to update before bringing it in? or just the tests?
|
It looks like it is falling down inside of simpeg/simpeg/electromagnetics/time_domain/receivers.py Lines 178 to 208 in d58b57f
|
| numpy.ndarray | ||
| Active times for the receiver. | ||
| """ | ||
| return np.unique(sp.find(projection)[1]) |
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 think we should be able to do the following since it is a sparse matrix
| return np.unique(sp.find(projection)[1]) | |
| return projection.indices |
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 suspect that using .indices is going to be faster. Just two caveats:
- We still need to do
np.unique(projection.indices). If we don't get the unique ones, thePtmatrix after doingPt = Pt[:, self.active_times(Pt)]will be actually larger than the original one (in case we have repeated column indices). - Using
indicesor thefindfunction is equivalent only ifprojectionis acsr_matrix. For example, if it's acsc_matrix, then the.indiceswill be row indices instead of the column indices. SincegetPalways return acsr_matrix, this should not be a problem, But I would clarify this in the docstring, and maybe checkingisinstance(projection, csr_matrix)would be a good idea.
santisoler
left a comment
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.
Leaving a few comments below. I'll try to experiment with my second thought and share results.
|
|
||
| Ps = self.getSpatialP(mesh, f) | ||
| Pt = self.getTimeP(time_mesh, f) | ||
| Pt = Pt[:, self.active_times(Pt)] |
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 one issue I see by adding this line in getP is that any time we want to compute the dot product between P and any vector, the vector should also be "reduced" to only the active times. This makes the getP method less standalone: we need to call active_times again if we want to compute dot products of P with any vector.
Would it be possible to apply the optimization directly in eval and evalDeriv, without modifying the output of getP? I guess I'm asking if filtering out non-active times in the Update: no, it wouldn't be possible because the output of P matrix (P = sp.kron(Pt, Ps)) is possible and would achieve same performance as doing so in Pt.kron is a coo_matrix that cannot be subscripted.
|
Sharing here a few ideas we discussed today in the meeting:
|


(cherry picked from commit 1dfafa5)
Summary
This proposed change streamlines the compute of predicted data from time domain fields. Instead of looping over all dts, only loop over the times that needed by the projection of the receivers.
PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developerswhen ready for review.Reference issue
What does this implement/fix?
Additional information