pymc-devs / pymc-devs/pytensor
`pytensor.sparse.dot` returns a dense matrix even when both inputs are sparse
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
As mentioned in https://github.com/pymc-devs/pytensor/pull/1854, PyTensor's dot product for sparse matrices always returns a dense array, even when both inputs are sparse. This behavior differs from SciPy's, which returns a sparse matrix when both inputs are sparse (using the format of the first input IIRC).
Note this only happens with pytensor.sparse.dot. The other operator, pytensor.sparse.structured_dot, does return a sparse matrix when both inputs are sparse.
I have not looked into pytensor.sparse.true_dot yet, but a skim suggests this one always return a sparse matrix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the pytensor.sparse.dot entry point and compare its behavior with SciPy when both inputs are sparse. Check the existing behavior of pytensor.sparse.structured_dot and pytensor.sparse.true_dot for guidance, then verify that sparse inputs produce a sparse result while existing dense behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100