pymc-devs / pymc-devs/pytensor
Remove BatchedDot and provide C implementation for batched matmul that uses numpy C-API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
Numpy has this function we can probably use for the Blockwise of Dot (Matmul) https://numpy.org/devdocs/reference/c-api/array.html#c.PyArray_MatrixProduct2 to replace
This also makes the BatchedOp redundant, so we can save a lot of code: https://github.com/pymc-devs/pytensor/blob/f10a6036ab0c24149565f469946d46f4d4922672/pytensor/tensor/blas.py#L1314-L1711
Including some rewrites that try to introduce it. May want to have a look at https://numpy.org/devdocs/reference/c-api/array.html#c.PyArray_InnerProduct for the respective Blockwise Dot
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 with pytensor/tensor/blas.py, especially the BatchedOp code at lines 1314–1711, then read NumPy's PyArray_MatrixProduct2 and PyArray_InnerProduct C-API documentation. Trace the proposed rewrites and determine how Blockwise Dot and batched matmul should use the C implementation; done means BatchedDot is removed and the rewrites support the intended operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, numpy, python
- Domain
- backend, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100