Skip to content

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented May 20, 2025

This showed up when trying to vectorize statespace models


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

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 fixes a bug in the local_blockwise_advanced_inc_subtensor functionality and extends test coverage to handle cases with both batched and unbatched core_y.

  • Updated the test for local_blockwise_advanced_inc_subtensor with a new parameter (core_y_implicitly_batched) and random integer generation for improved variation.
  • Modified the subtensor rewriting function to automatically apply expand_dims on y when necessary and adjusted symbolic index extraction.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/tensor/rewriting/test_subtensor.py Extended test scenarios to cover both implicit batching and non-batching for core_y, refactoring expected behavior using a unified inplace function.
pytensor/tensor/rewriting/subtensor.py Fixed bug in handling implicit dimensions by introducing expand_dims for y, and updated the extraction of symbolic indices accordingly.

symbolic_idxs = x[tuple(new_idxs)].owner.inputs[1:]
x_view = x[tuple(new_idxs)]

# We need to introduce any implicit expand_dims on core dimension of y
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider expanding the comment to clarify why x_view is obtained and used for reassigning symbolic_idxs. This additional context would improve code maintainability.

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented May 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.10%. Comparing base (5ffe17a) to head (7684042).
⚠️ Report is 161 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1405   +/-   ##
=======================================
  Coverage   82.10%   82.10%           
=======================================
  Files         208      208           
  Lines       49576    49581    +5     
  Branches     8791     8792    +1     
=======================================
+ Hits        40704    40709    +5     
  Misses       6699     6699           
  Partials     2173     2173           
Files with missing lines Coverage Δ
pytensor/tensor/rewriting/subtensor.py 90.14% <100.00%> (+0.06%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94 ricardoV94 requested a review from AlexAndorra May 21, 2025 09:13
@jessegrabowski jessegrabowski merged commit 4829455 into pymc-devs:main May 21, 2025
74 checks passed
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.

2 participants