pymc-devs / pymc-devs/pytensor

Dot and blas slowed by negative strides

Open
#1,388 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature request needs info performance
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Context for the issue:

Currently, cumulative sum is implemented as a wrapper for the corresponding Numpy function.
When testing with vectors, instead of using

pt.cumsum(x)

using

pt.dot(pt.tril(pt.ones((d,d))), x)

where d is the length of vector x, seems to lead to considerably faster sampling performance.

See this gist for a quick demo.

Proposal:

Keep the API un changed, but change the internals to compute the dot product with the lower diagonal matrix for the dimension specified in the axis argument of cumsum.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the cumsum implementation and its handling of the axis argument, then compare it with the existing dot-based expression using a lower-triangular matrix. Check how the current implementation is tested and benchmark the proposed internals; done means preserving the unchanged cumsum API while confirming improved sampling performance.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.