nv-legate / cunumeric

An Aspiring Drop-In Replacement for NumPy at Scale
https://docs.nvidia.com/cunumeric/24.06/
Apache License 2.0
609 stars 69 forks source link

Support for sparse matrices? #797

Open zohimchandani opened 1 year ago

zohimchandani commented 1 year ago

Our collaborator, @FHedin, is having some issues related to ufunc multiply

I'll let them elaborate with some error messages they are observing.

rohany commented 1 year ago

Check out https://github.com/nv-legate/legate.sparse!

FHedin commented 1 year ago

Hi, thanks @zohimchandani for opening this issue.

A little bit of context first : together with @axelcqp we are working on a code written by @ChemCesar (Quantum Computing emulation applied to chemistry problems); this code is private for now but Nvidia people (@zohimchandani and others) are helping us porting it on a multi GPU environment.

We started having a look at the legion + legate + cuNumeric environment last week; for now we simply substituted the import numpy as np by import cunumeric as np

We observe a ufunc multiply error as you can see below; this seem to happen after a call to a part of the code working on Sparse Matrices but it is still not clear for we whether both problems are related.

image image image

I will investigate legate.sparse ; I need to rebuild most of the things it seems so it might take a few hours before I can give more details; I will keep you updated.

Thanks for your help,

Florent Hédin

rohany commented 1 year ago

yeah, if you are trying to a dot between a sparse matrix and a cunumeric dense matrix then you will run into problems, as cunumeric doesn't know how to interpret the sparse matrix types. Utilizing legate.sparse instead of scipy should be able to dispatch that dot towards the sparse matrix's dot routine.

manopapad commented 1 year ago

AFAICT the arrays involved in this error are default NumPy (i.e. dense) arrays, so the cunumeric.linalg.dot implementation should be able to handle them. It looks like our code was simply not expecting this combination of dtypes. @FHedin do you mind printing out the shapes and dtypes of the arrays involved in this operation (self.hamiltonian, self.initial_state)?