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

Torch dispatch for scipy-like functions and Softplus #1066

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ch0ronomato
Copy link
Contributor

@Ch0ronomato Ch0ronomato commented Nov 2, 2024

Description

I was goofing around with pymc using the pytorch backend. I implemented a beta binomial model and had an issue when supporting some scipy methods, and was missing softplus. I wrote some small shims. Let me know your thoughts on the importlib stuff.

Related Issue

Checklist

Type of change

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

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

@Ch0ronomato
Copy link
Contributor Author

I'm okay with closing this, just want to get your thoughts on it in relation to #1065

Copy link

codecov bot commented Nov 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.10%. Comparing base (e73258b) to head (f852075).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1066      +/-   ##
==========================================
+ Coverage   81.95%   82.10%   +0.15%     
==========================================
  Files         182      183       +1     
  Lines       47866    47933      +67     
  Branches     8622     8633      +11     
==========================================
+ Hits        39228    39357     +129     
+ Misses       6472     6410      -62     
  Partials     2166     2166              
Files with missing lines Coverage Δ
pytensor/link/pytorch/dispatch/scalar.py 71.87% <100.00%> (+11.00%) ⬆️

... and 6 files with indirect coverage changes

@ricardoV94
Copy link
Member

ricardoV94 commented Nov 2, 2024

I'm okay with closing this, just want to get your thoughts on it in relation to #1065

This looks fine why did you ask about closing it?

Can you add some small tests for one of the scipy ops and the softplus?

@ricardoV94 ricardoV94 changed the title Adds Scipy module stuff and softplus Torch dispatch for scipy-like functions and Softplus Nov 5, 2024
@ricardoV94 ricardoV94 added enhancement New feature or request torch PyTorch backend labels Nov 5, 2024
@@ -4,6 +4,7 @@
import numpy as np
import pytest

import pytensor.tensor as pt
Copy link
Member

Choose a reason for hiding this comment

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

We prefer to use explicit imports as a policy. In your case import expit and softplus directly

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

Looks great, just a nit in the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request torch PyTorch backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants