-
Notifications
You must be signed in to change notification settings - Fork 73
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
Change annotate logic from windowed to batched pre- and postprocessing #282
Conversation
Pre- and postprocessing in the annotate function was so far done per window and in numpy. This PR changes the processing to a batched mode running on PyTorch. This also ensures that all processing can happen on the GPU if available. In addition, this now allows to wrap the three processing steps in a thread, allowing to release the GIL during the heavy numeric operations. Overall, this will reduce run times, in particular, on GPU. As this change improves the efficiency of the asyncio implementation, it removes the (suboptimal) process implementation completely. To ensure compatibility with the previous implementation, a suite of tests has been added and the former `annotate_window_pre`/`annotate_window_post` functions are retained. These functions and tests should be removed in a future PR. Additional small changes: - increased default batch size from 64 to 256 - refactored some functions in seisbench.util
0ebcf13
to
c648b27
Compare
Here are the benchmark results. All experiments were run on a server using 12 CPU cores and a V100 GPU for the GPU experiments. Times are in seconds to annotate 10 stations, each with 1 day of 3 component data at 100 Hz. The batch size was set to 4096 (even though the GPU could handle even more).
Overall, there are speed-ups on both CPU and GPU in all configurations. The magnitude of speed-up vary a lot between the models, depending on how heavy pre- and postprocessing are compared to the model itself. A few quick observations:
Notably, PhaseNet, PhaseNetLight and EQTransformer can now annotate a day of data at 100 Hz on GPU in under a second, i.e., around 10e5 times faster than real time. |
- remove all annotate_window_pre and annotate_window_post functions - adjusts tests still using these functions - remove compatibility tests (the compatibility only needed to be checked on the CI once) - remove further leftovers from process-based interface
…_checks Clean-up legacy annotate code (Follow-up #282)
Remark: Dropping the process interface also made the tests much quicker. |
- remove all annotate_window_pre and annotate_window_post functions - adjusts tests still using these functions - remove compatibility tests (the compatibility only needed to be checked on the CI once) - remove further leftovers from process-based interface
Pre- and postprocessing in the annotate function was so far done per window and in numpy. This PR changes the processing to a batched mode running on PyTorch. This also ensures that all processing can happen on the GPU if available. In addition, this now allows to wrap the three processing steps in a thread, allowing to release the GIL during the heavy numeric operations. Overall, this will reduce run times, in particular, on GPU.
As this change improves the efficiency of the asyncio implementation, it removes the (suboptimal) process implementation completely.
To ensure compatibility with the previous implementation, a suite of tests has been added and the former
annotate_window_pre
/annotate_window_post
functions are retained. These functions and tests should be removed in a future PR.Additional small changes:
Closes #269