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

Fix type instabilities of SimplexBijector #174

Merged
merged 3 commits into from
Apr 5, 2021
Merged

Fix type instabilities of SimplexBijector #174

merged 3 commits into from
Apr 5, 2021

Conversation

devmotion
Copy link
Member

Fixes type instabilities discovered in TuringLang/Turing.jl#1276.

@torfjelde
Copy link
Member

I'll review, but quick quesh first: is there a reason why you re-introduced the Val? I don't think that's necessary here; at least when I experimented, it wasn't.

@devmotion
Copy link
Member Author

I could not obtain type stability without it. IMO this seems reasonable since it is not possible to infer the type, or rather the type parameter proj, of SimplexBijector from a boolean value proj.

@torfjelde
Copy link
Member

For the case when proj is a runtime parameter you mean, or nah? It is inferrable if you do SimplexBijector{true}().

@devmotion
Copy link
Member Author

Sure, you can hardcode it for the default version with true - but the three argument version, with true or false, is still type unstable.

@devmotion
Copy link
Member Author

BTW also with your suggestion in TuringLang/Turing.jl#1276 (comment) invlink(d, x) is still type unstable. It seems you accidentally checked link(d, x) instead?

@torfjelde
Copy link
Member

torfjelde commented Apr 5, 2021

Haha, yeah you're right! Sorry about that. I think I was just cycling through my command history to get the function call and seems like I was a bit too quick.

But regarding the 3-argument version. The reason why we replaced Val with proj was because when you use link and invlink in a different scope than Main, you'll have to hardcode proj to get type-stability no matter if we're using Val or not. And if you hardcode, even when not using Val, you should get type stability due to constant propogation.

Thouhgh in the light of the stuff we saw in the DPPL PR, I'm not so certain about that anymore:) And it seems like even something as simple as

f(d, x) = Bijectors.invlink(d, x, true)

fails 😕

So I guess I'm in favour of adding back the Val.

Copy link
Member

@torfjelde torfjelde left a comment

Choose a reason for hiding this comment

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

LGTM!

But is this considered a breaking change? Should we bump the minor version or? (Also can you bump the version?:) )

@devmotion
Copy link
Member Author

Yes, IMO this is a breaking change.

@devmotion devmotion merged commit f8db035 into master Apr 5, 2021
@devmotion devmotion deleted the dw/dirichlet branch April 5, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants