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

Include Op in message when raising NotImplementedError from grad #711

Open
ricardoV94 opened this issue Apr 13, 2024 · 5 comments
Open

Include Op in message when raising NotImplementedError from grad #711

ricardoV94 opened this issue Apr 13, 2024 · 5 comments
Labels
enhancement New feature or request gradients

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Apr 13, 2024

Description

When grad fails because a specific Op doesn't support it it's quite difficult to figure out which one it was without jumping on an interactive debugger

https://discourse.pymc.io/t/avoiding-non-nuts-samplers-when-broadcasting-a-multiplication-operation/14245/4?u=ricardov94

We should return something like NotImplementedError(f"grad not implemented for Op {self}") in a base class.

Or use the grad_not_implemented functionality that exists for partial grad implementations which also provides a more readable error IIRC

@ricardoV94 ricardoV94 added enhancement New feature or request gradients labels Apr 13, 2024
@tanish1729
Copy link
Contributor

hello! i'll take up this issue. i understand the issue and also saw the main issue on pymc. how should i start solving this?

@ricardoV94
Copy link
Member Author

You should tweak this base case NotImplementedError, to include self in the message:

raise NotImplementedError()

@tanish1729
Copy link
Contributor

tanish1729 commented Apr 16, 2024

Im trying to use the grad_not_implemented function but im slightly confused about the implementation.
what is the inputs parameter to the grad function so that i can use it while passing to the grad_not_implemented as used in some other places.

@tanish1729
Copy link
Contributor

i made some commits to my fork but they arent showing up in this issue for u to review? 😕

@ricardoV94
Copy link
Member Author

ricardoV94 commented Apr 16, 2024

You need to open a pull request from your fork: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

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

Successfully merging a pull request may close this issue.

2 participants