Skip to content
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

Workaround PyTensor bug in vectorize of logp graph #7415

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

ferrine
Copy link
Member

@ferrine ferrine commented Jul 17, 2024

fix #7414

Description

Related Issue

  • Closes #
  • Related to #

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7415.org.readthedocs.build/en/7415/

@ferrine ferrine requested a review from ricardoV94 July 17, 2024 13:37
@ricardoV94 ricardoV94 added the bug label Jul 17, 2024
@ricardoV94 ricardoV94 changed the title fix: Replace unsafe under vectorize pt.zeros(value.shape) Workaround bug in vectorize of logp graph Jul 17, 2024
@ricardoV94 ricardoV94 changed the title Workaround bug in vectorize of logp graph Workaround PyTensor bug in vectorize of logp graph Jul 17, 2024
@ferrine
Copy link
Member Author

ferrine commented Jul 17, 2024

what is this error in float64 tests, is it related?

@ricardoV94
Copy link
Member

what is this error in float64 tests, is it related?

That's weird, values seem transposed

@ferrine
Copy link
Member Author

ferrine commented Jul 18, 2024

feels to me this is failing check_pymc_draws_match_reference

@ferrine
Copy link
Member Author

ferrine commented Jul 18, 2024

Another thing, I'm not able to reproduce the bug

(/home/ferres/dev/pymc/.venv) @c1 ➜ pymc git:(fix/vectorize-graph) PYTENSOR_FLAGS=floatX=float64 pytest tests/distributions/test_continuous.py::TestPolyaGamma::test_distribution
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/ferres/dev/pymc
configfile: pyproject.toml
collected 1 item

tests/distributions/test_continuous.py .                                                                                                                                                             [100%]

============================================================================================= warnings summary =============================================================================================
.venv/lib/python3.11/site-packages/pytensor/configdefaults.py:375
  /home/ferres/dev/pymc/.venv/lib/python3.11/site-packages/pytensor/configdefaults.py:375: DeprecationWarning: Use shutil.which instead of find_executable
    newp = find_executable(param)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================================= 1 passed, 1 warning in 0.36s =======================================================================================

Should we merge instead and open a new issue to resolve that?

@ricardoV94
Copy link
Member

If it's not failing on main we shouldn't merge. Did you retrigger the CI to see if it was a (very weird) fluke?

@ferrine
Copy link
Member Author

ferrine commented Jul 18, 2024

same error, retriggered

@ferrine ferrine force-pushed the fix/vectorize-graph branch from a01ec77 to 7518dce Compare July 18, 2024 12:40
@ferrine
Copy link
Member Author

ferrine commented Jul 18, 2024

attempted to rebase on latest main

@ferrine
Copy link
Member Author

ferrine commented Jul 18, 2024

I have not seen these transforms are even used by PolyaGamma

@ricardoV94
Copy link
Member

I'll have to dig, is rather surprising, but somehow related

@zoj613
Copy link
Contributor

zoj613 commented Jul 18, 2024

I have not seen these transforms are even used by PolyaGamma

Can you try pinning polyagamma to 1.3.6 just to see if the tests fail. I just released 1.3.7 which includes numpy 2.0 support. I suspect this change might be the root cause.

Looking at this output:

E           AssertionError: 
E           Arrays are not almost equal to 6 decimals
E           
E           Mismatched elements: 14 / 15 (93.3%)
E           Max absolute difference: 0.25700269
E           Max relative difference: 7.27861386
E            x: array([0.175503, 0.304112, 0.32734 , 0.285465, 0.15268 , 0.208075,
E                  0.324094, 0.261004, 0.256576, 0.173434, 0.115312, 0.034482,
E                  0.121655, 0.047109, 0.358831])
E            y: array([0.358831, 0.047109, 0.121655, 0.034482, 0.115312, 0.173434,
E                  0.256576, 0.261004, 0.324094, 0.208075, 0.15268 , 0.285465,
E                  0.32734 , 0.304112, 0.175503])

It appears that the linked PR leads to values being generated in a reverse order than in v1.3.6....or at at least that's my immediate guess since i'm not quite familiar with the code that is being tested in the CI.

@ferrine
Copy link
Member Author

ferrine commented Jul 19, 2024

I can confirm that updating the polyagamma to 1.3.7 I reproduce the error

@ferrine
Copy link
Member Author

ferrine commented Jul 19, 2024

since this test is a blocker, I created an issue #7417 and a temporary solution #7418 to unblock any related work

@ferrine ferrine force-pushed the fix/vectorize-graph branch from 7518dce to 944478e Compare July 19, 2024 09:55
@ferrine
Copy link
Member Author

ferrine commented Jul 19, 2024

just rebased on the updated CI

@zoj613
Copy link
Contributor

zoj613 commented Jul 19, 2024

I've pulled 1.3.7 from Pypi and re-released it as v2.0.0 so you likely no longer need to pin the package. see : https://github.com/zoj613/polyagamma/actions/runs/10006421637

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.18%. Comparing base (8fd4f1c) to head (944478e).
Report is 94 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7415   +/-   ##
=======================================
  Coverage   92.18%   92.18%           
=======================================
  Files         103      103           
  Lines       17259    17259           
=======================================
  Hits        15910    15910           
  Misses       1349     1349           
Files with missing lines Coverage Δ
pymc/logprob/transforms.py 95.46% <100.00%> (ø)

@ricardoV94 ricardoV94 merged commit f6d1b33 into main Jul 19, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Dirichlet is broken under graph vectorization
3 participants