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

Tracking issue: Add Array API standard support #21

Open
12 of 47 tasks
mtsokol opened this issue Mar 15, 2024 · 9 comments
Open
12 of 47 tasks

Tracking issue: Add Array API standard support #21

mtsokol opened this issue Mar 15, 2024 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@mtsokol
Copy link
Member

mtsokol commented Mar 15, 2024

Hi @willow-ahrens @hameerabbasi,

This issue is meant to track progress of implementing Array API standard for finch-tensor.

I thought that we could try adding short notes to bullet-points, saying which Finch.jl functions should be called to implement given entry. I think we already had some ideas during one of our first calls.

Array API: https://data-apis.org/array-api/latest/index.html

Backlog

main namespace

linalg namespace

(I copied those from the benchmark suite. If something turns out to be unfeasible we can drop it.)

  • linalg.vecdot - finch.tensordot
  • linalg.vector_norm - finch.norm
  • linalg.trace - eager
  • linalg.tensordot - implemented in the main namespace. Just needs an alias
  • linalg.outer #89
  • linalg.cross - eager for now
  • linalg.matrix_transpose - lazy
  • linalg.matrix_power - eager (call matmul on sparse matrix until it gets too dense)
  • linalg.matrix_norm - for nuc or 2, call external library. For fro, inf, 1, 0, -1, -inf, call jl.norm.
  • xp.linalg.diagonal - finch.tensordot(finch.diagmask(), mtx)
  • xp.linalg.cholesky - call CHOLMOD or something
  • xp.linalg.det - call EIGEN or something
  • xp.linalg.eigh - call external library
  • xp.linalg.eigvalsh - call external library
  • xp.linalg.inv - call external library - scipy.sparse.linalg.inv
  • xp.linalg.matrix_rank - call external library
  • xp.linalg.pinv - call external library

Tensor methods and attributes

  • Tensor.to_device() - finch.moveto

miscellaneous

@willow-ahrens
Copy link
Collaborator

I added some methods you can call for most of these! Some of them need to be external library calls

@mtsokol
Copy link
Member Author

mtsokol commented Mar 15, 2024

@willow-ahrens thank you - that's exactly what I needed! 😄

@mtsokol mtsokol added the enhancement New feature or request label Mar 27, 2024
@jorenham
Copy link

Don't forget about __array_namespace_info__() function, and the isdtype() and result_type() data type functions 🙂

@willow-ahrens
Copy link
Collaborator

Thanks! Added a bullet for it.

@ilan-gold
Copy link

Hello!

Re: #88 I think the root of this is having a way to do boolean indexing for us.

I don't see anything here about boolean indexing (https://data-apis.org/array-api/latest/API_specification/indexing.html#boolean-array-indexing) along axes. And from what I can tell, it's not supported in the julia library (or it is but only as a custom loop: https://github.com/finch-tensor/Finch.jl/blob/2e89d2228a777a8238eccd145cfa6a7b405eb76c/docs/src/docs/language/mask_sugar.md?plain=1#L5); however it is part of the array-api.

Is there a plan to support it? I would really love to use this but lacking a proper indexing method is a big blocker (assuming I have this right).

@willow-ahrens
Copy link
Collaborator

@ilan-gold Hi Ilan! Thanks for your interest in the project! Our goal is to support all of the operations in the array API, so if something has been left out it likely wasn't intentional. It is quite feasible to implement this operation, and I've added it to the list! The only caveat is that I don't think we will be able to implement it in a way that can fuse it with other operations, at least for now. I think I left it out of the julia implementation just because I needed to get things up and running quickly, but Boolean indexing is actually part of the Julia indexing api as well, so this addition is in scope for both languages!

@ilan-gold
Copy link

ilan-gold commented Feb 20, 2025

that can fuse it with other operations

Could you highlight what this would mean practically for users? This is mostly a performance, not a practical (in the sense of "all downstream operations will break if you boolean index" thing), no?

@willow-ahrens
Copy link
Collaborator

willow-ahrens commented Feb 20, 2025

Yes, this is a performance thing, not a semantics thing. What it would mean for users is just that if we wish to do a logical indexing operation, we would need to materialize the inputs and outputs of the operation (This is normal for most libraries, Finch just provides a special fusion optimization for certain operations).

@ilan-gold
Copy link

Right, ok, interesting. Thanks @willow-ahrens I'll keep my ear to the ground in the meantime. Your library is a big target for us using the array-api, really looking forward to digging into it a bit more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants