-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
re-implementation of torch-lambdify #20516
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
Conversation
✅ Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.11. Click here to see the pull request description that was parsed.
|
🟠Hi, I am the SymPy bot (v167). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it. This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75. The following commits add new files:
The following commits delete files:
If these files were added/deleted on purpose, you can ignore this message. |
I'm getting a timeout on the travis env build -- @oscarbenjamin how's the progress looking on the move to github actions? Should I bother finding a workaround? |
I've restarted the Travis jobs. We are using github actions now but it doesn't run all the same jobs as Travis so we are not ready to turn off Travis yet. |
@oscarbenjamin Thanks for your work on moving to actions -- looks like it's passing now. |
Can pytorch be installed in actions? Or would that require moving actions to using conda (see also #20623)? |
I'm assuming this should close #15484. I edited the description so it actually will. |
Thanks for that! Pip isn't the reccommended method for installing but is possible afaik:
|
What's the status/stability of this PR? This is functionality we'd be interested in. (EDIT: for the sake of any future Googlers who end up here like I did: I ended up putting together something myself that converts SymPy expressions into PyTorch Modules and vice versa: sympytorch) |
I think the main blocking issue is getting the testing working on GitHub Actions. That may require some work on #20623. @patrick-kidger do you have any functionality in sympytorch that isn't implemented here? |
So I don't think the functionality here creates a trainable PyTorch (Conversely I am aware that this PR includes a bunch of things I didn't try to put into sympytorch.) |
Here's the JAX equivalent of @patrick-kidger's idea for parametrized expressions: https://github.com/MilesCranmer/sympy2jax. Having the constants be trainable makes lambdify very useful for optimization (e.g., symbolic regression https://github.com/MilesCranmer/pysr), which is why both sympytorch and sympy2jax record parameters in the expression rather than hardcoding them in. Could this behaviour be added as a kwarg or something? e.g., |
It looks fairly easy to setup conda on actions if that is needed: |
- github actions torch install in optional dependency
@MilesCranmer can you open a new issue about Jax support? @patrick-kidger does it make sense for those features to be in SymPy (assuming this PR is merged)? |
I think it would make sense. It seems to me like converting to a |
updating to sympy upstream
Closing after #27760 was merged |
References to other Issues or PRs
Fixes #20065
Closes #15484
Brief description of what is fixed or changed
This is a clean re-implementation of the torch-lambdify project without the conflicts from #15484 and #20065
Other comments
atan2 still not working and will require more extensive refactoring but this is a start.
Release Notes
f = lambdify(variables, expr, 'torch')
torch_code
enables conversion between sympy function and the equivalent pytorch operation.