Adding parallel implementations of (some?) quasisep algorithms #210
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.
The
quasisepsolver is fast on CPU, but the performance is very bad on GPU (and probably TPU) because of the extensive use oflax.scan. It's possible to rewrite at least some of these operations usinglax.associative_scanwhich (at least in principle) are more accelerator friendly. This approach is similar is spirit to the algorithms derived in https://arxiv.org/abs/1905.13002This PR is a WIP to add some of these operations. So far, I've just implemented a parallel matrix multiplication. There are still some precision issues to work out, but the initial performance looks good:
On CPU, the
scanandassociative_scanmatmuls take1.65 msand3.59 msrespectively, for aJ = 3lower triangular matrix withN = 50,000data points. On the GPU, these computations cost685 msand1.32 msrespectively. Therefore, thescanversion is ~600x slower on GPU, whereas theassociative_scanversion isn't. These GPU results are not impressive, but it might be worth investigating further in case someone wants to use this solver as part of a larger model that benefits from hardware acceleration.