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

Direct tests for dispatch implementations in alternative backends #1021

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Oct 7, 2024

This PR does a bunch of minor cleanups on the testing suite:

  • Execute minimal rewrites in PyTorch and JAX backends (Numba already did it), so that we are sure to test the Op implementations.
    • Sometimes tests were defined with constant inputs and due to constant folding who ended up never testing the backend implementation.
  • Fix incorrect configuration of pytest in pyproject.toml
  • Make xfail strict (test fails if marked as xfail but actually passed)

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

@@ -78,7 +78,7 @@ jobs:
install-jax: [0]
install-torch: [0]
part:
- "--doctest-modules --ignore=pytensor/misc/check_duplicate_key.py pytensor --ignore=pytensor/link"
- "--doctest-modules pytensor --ignore=pytensor/misc/check_duplicate_key.py --ignore=pytensor/link"
Copy link
Member Author

Choose a reason for hiding this comment

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

Just odd to have pytensor in the middle of the ignore files

@ricardoV94 ricardoV94 force-pushed the xfail_strict branch 5 times, most recently from 77fffef to f3e8575 Compare October 8, 2024 10:20
@ricardoV94 ricardoV94 changed the title Make xfail strict Misc testing fixes Oct 8, 2024
testpaths = "tests/"
[tool.pytest.ini_options]
addopts = "--durations=50 --doctest-modules --ignore=pytensor/link --ignore=pytensor/misc/check_duplicate_key.py"
testpaths = ["pytensor/", "tests/"]
Copy link
Member Author

Choose a reason for hiding this comment

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

pytensor is in the testpath because of --doctest-modules, so we test the code examples in the docstrings by default

@ricardoV94 ricardoV94 force-pushed the xfail_strict branch 2 times, most recently from 2cab125 to b5a0ca1 Compare October 9, 2024 08:53
Only run required rewrites in JAX tests

Several tests ended up not testing the backend Op implementations due to constant folding of inputs.
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.89%. Comparing base (f022e51) to head (1590dfa).
Report is 88 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/link/pytorch/dispatch/shape.py 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1021      +/-   ##
==========================================
+ Coverage   81.81%   81.89%   +0.07%     
==========================================
  Files         182      182              
  Lines       47778    47778              
  Branches     8597     8597              
==========================================
+ Hits        39088    39126      +38     
+ Misses       6523     6487      -36     
+ Partials     2167     2165       -2     
Files with missing lines Coverage Δ
pytensor/link/pytorch/dispatch/subtensor.py 89.74% <100.00%> (+5.12%) ⬆️
pytensor/tensor/nlinalg.py 94.84% <100.00%> (ø)
pytensor/link/pytorch/dispatch/shape.py 85.71% <0.00%> (+11.42%) ⬆️

... and 13 files with indirect coverage changes

@ricardoV94 ricardoV94 added jax torch PyTorch backend and removed no releasenotes labels Oct 10, 2024
@ricardoV94 ricardoV94 changed the title Misc testing fixes Direct tests for dispatch implementations in alternative backends Oct 10, 2024
@ricardoV94 ricardoV94 marked this pull request as ready for review October 10, 2024 15:52
@ricardoV94 ricardoV94 requested review from twiecki and maresb October 10, 2024 15:52
@ricardoV94 ricardoV94 merged commit b248eba into pymc-devs:main Oct 10, 2024
60 of 61 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