Skip to content

Conversation

Michal-Novomestsky
Copy link
Contributor

@Michal-Novomestsky Michal-Novomestsky commented Aug 12, 2025

Refactors as part of pymc-devs/pymc-extras#532


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

@Michal-Novomestsky
Copy link
Contributor Author

pre-commit.ci autofix

@ricardoV94 ricardoV94 changed the title Minimize jacobian refactors Use vectorized jacobian in Minimize Op Aug 14, 2025
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.64%. Comparing base (c932ffb) to head (a2e3634).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/tensor/basic.py 75.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (88.88%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1582   +/-   ##
=======================================
  Coverage   81.63%   81.64%           
=======================================
  Files         231      231           
  Lines       52993    52998    +5     
  Branches     9395     9395           
=======================================
+ Hits        43263    43268    +5     
- Misses       7281     7282    +1     
+ Partials     2449     2448    -1     
Files with missing lines Coverage Δ
pytensor/tensor/optimize.py 87.38% <100.00%> (+0.03%) ⬆️
pytensor/tensor/basic.py 91.80% <75.00%> (-0.05%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Michal-Novomestsky
Copy link
Contributor Author

pre-commit.ci autofix

@ricardoV94
Copy link
Member

Can you open an issue for the fact the optimization notebook now fails with these changes?

@Michal-Novomestsky
Copy link
Contributor Author

Can you open an issue for the fact the optimization notebook now fails with these changes?

Will do, but I can't seem to find the specific block that fails, most of these seem to run fine for me? Didn't test all of them though (I assume this is the notebook you're referring to?):

https://pytensor.readthedocs.io/en/latest/gallery/optimize/root.html

@ricardoV94
Copy link
Member

ricardoV94 commented Aug 16, 2025

The nb runs top to bottom correctly after the PR? Can you confirm one of the dprint graphs changed now that the Jacobian doesn't use scan? Otherwise you may not be running with the changes from here

@Michal-Novomestsky
Copy link
Contributor Author

Michal-Novomestsky commented Aug 17, 2025

Ah, one of the blocks all the way near the bottom fails:

w_bar = (1 - β) * (c + β * pt.dot(v_star, q_probs))

# We want to study the impact of change in unemployment and patience on the reserve wage 
w_grads = pt.grad(w_bar, [c, β])
TypeError: Only tensors with the same number of dimensions can be joined. Input ndims were: [3, 2, 2, 2]

I'll raise an issue now.

@jessegrabowski
Copy link
Member

@ricardoV94 is the notebook failure a blocker for this PR?

@ricardoV94
Copy link
Member

No but we need to remember to rerun when we fix the bug

@jessegrabowski jessegrabowski force-pushed the minimize-jacobian-refactors branch from ee37c24 to 5859a2e Compare September 19, 2025 23:48
@jessegrabowski
Copy link
Member

I don't think the bug is related to this PR. But I changed this to an option in minimize and root (since I don't think vectorize will always be what we want), so this is good to go after tests pass imo.

@jessegrabowski jessegrabowski force-pushed the minimize-jacobian-refactors branch from dfe8768 to da10fbc Compare September 20, 2025 17:24
@jessegrabowski
Copy link
Member

@ricardoV94 after I rebased I got some cache key errors locally in the optimize tests and had to do pytensor-cache clear to get things working again. Was this a forseen consequence of the recent PRs? We might have to anticipate users having this issue after we cut the next release.

@ricardoV94
Copy link
Member

ricardoV94 commented Sep 20, 2025

There were major changes but cache errors sounds like a bug. Do you know which Op or what function we can try to compile to reproduce?

@jessegrabowski
Copy link
Member

Do you know which Op or what function we can try to compile to reproduce?

No, I intelligently didn't save the error message, just cleared the cache then re-ran it. I guess we'll see if anyone else hits it.

@ricardoV94
Copy link
Member

Do you know if it was when running some test here or a specific notebook?

@jessegrabowski
Copy link
Member

Test here

@jessegrabowski jessegrabowski merged commit ee107cb into pymc-devs:main Sep 20, 2025
63 of 64 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.

3 participants