Skip to content
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

Multi-GPU support with dask #179

Merged
merged 111 commits into from
Dec 19, 2024
Merged

Multi-GPU support with dask #179

merged 111 commits into from
Dec 19, 2024

Conversation

Intron7
Copy link
Member

@Intron7 Intron7 commented Apr 25, 2024

This adds dask support

Functions to add:

  • calculate_qc_metrics
  • normalize_total
  • log1p
  • highly_variable_genes with seurat and cell_ranger
  • scale
  • PCA
  • neighbors

@Intron7 Intron7 marked this pull request as draft April 25, 2024 13:08
@Intron7 Intron7 changed the title add first functions Multi-GPU support with dask Apr 30, 2024
@Intron7 Intron7 added the run-gpu-ci runs GPU CI label May 3, 2024
@Intron7 Intron7 marked this pull request as ready for review May 13, 2024 14:27
@ilan-gold
Copy link
Contributor

We should look into the cost of allocating ahead of time for all operations that are currently in-place

@Intron7
Copy link
Member Author

Intron7 commented Nov 21, 2024

Median out of core is a bad choice. Uses way more memory and is slower. Loose Loose

@Intron7 Intron7 added the run-gpu-ci runs GPU CI label Dec 5, 2024
@github-actions github-actions bot removed the run-gpu-ci runs GPU CI label Dec 5, 2024
@Intron7 Intron7 added the run-gpu-ci runs GPU CI label Dec 16, 2024
@github-actions github-actions bot removed the run-gpu-ci runs GPU CI label Dec 16, 2024
Copy link
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think I can really review this.

I checked out parts like the PCA code, but generally the whole codebase lacks some abstractions that would get rid of visual noise while exposing the intent, especially for patterns like invoking a kernel with block sizes specified (mentioned here: https://github.com/scverse/rapids_singlecell/pull/179/files#r1838497326)

I also still want to see docstrings for the kernels! (ideally coupled with an abstraction for the kernel pattern)

Let’s tackle both of these abstractions before the next feature PR. I’m happy to meet with you to design them.

If the first abstraction (calling kernels) and the big code moves (e.g. PCA) were done before this PR, I could actually see what changes happened and what’s new and therefore review this, but like this it’s just too much to wrap my head around.

PS: there are a bunch of unaddressed comments still above

@@ -260,6 +266,21 @@ def in_bounds(
)


def _hvg_expm1(X):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does that have to do with HVG? isn’t it just expm1?

also seems like it could be cleaner with singledispatch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

singledispatch doesnt work with cupy

This comment was marked as duplicate.

src/rapids_singlecell/preprocessing/_hvg.py Outdated Show resolved Hide resolved
int n_cells) {
int cell = blockDim.x * blockIdx.x + threadIdx.x;
if(cell >= n_cells){
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as in the other PR: no error handling? is this expected to be called with invalid inputs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how cuda works

Comment on lines 257 to 265
if isinstance(X, cp.ndarray):
X = cp.log1p(X)
else:
elif sparse.issparse(X):
X = X.log1p()

elif isinstance(X, DaskArray):
if isinstance(X._meta, cp.ndarray):
X = X.map_blocks(lambda x: cp.log1p(x), meta=_meta_dense(X.dtype))
elif isinstance(X._meta, sparse.csr_matrix):
X = X.map_blocks(lambda x: x.log1p(), meta=_meta_sparse(X.dtype))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should become a helper like the expm1 above

import dask
import dask.array as da

if isinstance(X._meta, sparse.csr_matrix):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please figure out a way to reuse code here.

@Intron7 Intron7 added the run-gpu-ci runs GPU CI label Dec 17, 2024
@github-actions github-actions bot removed the run-gpu-ci runs GPU CI label Dec 17, 2024
@Intron7 Intron7 added the run-gpu-ci runs GPU CI label Dec 19, 2024
@github-actions github-actions bot removed the run-gpu-ci runs GPU CI label Dec 19, 2024
@Intron7 Intron7 merged commit 4629c05 into main Dec 19, 2024
9 checks passed
@Intron7 Intron7 deleted the dask_mg_support branch December 19, 2024 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants