pymc-devs / pymc-devs/pytensor

Rethink Scan special behavior when n_steps < pre-allocated output buffer

Open
#1,741 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend compatibility Op implementation scan
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Description

We had a subtle bug in the Numba implementation of Scan found out in #811

Scan is supposed to zero-out unwritten buffers when n_steps doesn't cover it all. This adds yet another nugget of complexity to Scan, as if it weren't already a mess.

Things to investigate:

  1. Do we need to zero out? Can we slice away like while Scans do?
  2. If not, can this be handled outside the Scan by the code that creates such a Scan?

https://github.com/pymc-devs/pytensor/blob/bc0d670fd542b7276ad5af583bf87862a4334868/pytensor/scan/op.py#L2179-L2203

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 in pytensor/scan/op.py around lines 2179-2203 and review the Numba Scan behavior described in #811. Investigate whether unwritten buffers must be zeroed when n_steps is smaller than the pre-allocated output, or whether they can be sliced like while Scans or handled by the code creating the Scan. Done means the required behavior and its implementation location are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.