Skip to content

Avoid default allocation for taps of length 1 in ScanSaveMem #1395

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented May 8, 2025

The check we had for whether a variable was a default scan buffer always failed for single tapped outputs. There's a conservative check that the original value is not being broadcast to the number of initial taps, but that doesn't matter for single taps.

Also added some checks that we are actually only keeping buffers of the expected size in the test.


📚 Documentation preview 📚: https://pytensor--1395.org.readthedocs.build/en/1395/

@ricardoV94 ricardoV94 changed the title Avoid large allocation for taps of length 1 in ScanSaveMem Avoid default allocation for taps of length 1 in ScanSaveMem May 8, 2025
@ricardoV94 ricardoV94 requested a review from Copilot May 8, 2025 15:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses an issue with the default scan buffer allocation for single-tapped outputs in ScanSaveMem and enhances the tests for buffer size validation. Key changes include:

  • Adjusting the test configuration by excluding "scan_pushout" and renaming an internal function from f_rnn to step for clarity.
  • Updating the implementation of default scan buffer handling by adding a new parameter (taps) to _is_default_scan_buffer and adapting buffer expansion and slicing logic accordingly.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/scan/test_rewriting.py Modified test configuration and assertions regarding scan buffer sizes and function naming.
pytensor/scan/rewriting.py Updated _is_default_scan_buffer's signature and revised buffer handling logic using the taps value.

return True
bx = bx[-len(by) :]
bx = bx[bx_len - by_len :]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would fail with the infamous [-0:] edge case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant