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
quasisep
solver 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_scan
which (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
scan
andassociative_scan
matmuls take1.65 ms
and3.59 ms
respectively, for aJ = 3
lower triangular matrix withN = 50,000
data points. On the GPU, these computations cost685 ms
and1.32 ms
respectively. Therefore, thescan
version is ~600x slower on GPU, whereas theassociative_scan
version 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.