modified _knn_from_dists to enable very large distance matrices #33
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.
This is a simple code modification that has enabled me to use very large distance matrices as input to UMAP (e.g. 100 000 x 100 000 distance matrices). The matrices may be so large that they do not fit into memory unless they are implemented in a sparse way (I have been using
DefaultArrays
; not really the most efficient implementation but it does the job).The modified code is equivalent to the old one but doesn't seem to require nearly as much memory.
With the older code, julia would run out of memory in the
_knn_from_dists
function while trying to allocate very large matrices. I am not sure why that happened but I guess it is related to how array comprehensions are materialized.On a side note, modifications I used that are not included in this PR are
Threads.@threads
in the for loop in_knn_from_dists
, which provides a great speedupProgressMeter
(for when UMAP takes 10 minutes...) in a few functions.Those are basic modifications but really improve the quality of life when dealing with large datasets. Let me know if you'd be interested in some of these.