8000 Mooncake errors when Turing model includes @show call · Issue #515 · chalk-lab/Mooncake.jl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Mooncake errors when Turing model includes @show call #515

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

Open
PTWaade opened this issue Mar 10, 2025 · 4 comments
Open

Mooncake errors when Turing model includes @show call #515

PTWaade opened this issue Mar 10, 2025 · 4 comments

Comments

@PTWaade
Copy link
PTWaade commented Mar 10, 2025

Forgive me if this is a known issue, or is desired behaviour.

I get an error when including a @show call inside my Turing model. Supposedly, a rrule!! hasn't been written for a primitive in the @show macro.
In my ignorance, I imagine it wouldn't be too hard to add.

I ran into it trying to use the @show call for quick debugging purposes - it is of course is in general not relevant to the actual model. So this issue is primarily for debugging convenience.

Minimal example below. ReverseDiff does not error. Using newest versions of Turing and Mooncake.

using Turing
import Mooncake, ReverseDiff

@model function testmodel(bar = [1, 1])

    dists = [arraydist([Normal(), Normal(), Normal()]),
             arraydist([Normal(), Normal()])
             ]

    @show dists
    foo = Vector(undef, length(bar))

    for (idx, barval) in enumerate(bar)
        foo[idx] ~ dists[idx]
    end
end

sample(testmodel(), NUTS(; adtype = AutoReverseDiff(; compile = true)), 100)

sample(testmodel(), NUTS(; adtype = AutoMooncake(; config = nothing)), 100)
@yebai
Copy link
Member
yebai commented Mar 10, 2025

Duplicate of #310.

@willtebbutt
Copy link
Collaborator

Thanks for opening this issue @PTWaade . You are correct that this is one of those things that ought not to be too hard -- the judicious use of @zero_adjoint (see https://compintell.github.io/Mooncake.jl/stable/utilities/defining_rules/#Functions-with-Zero-Adjoint) ought to be enough. We just need someone to take the time to understand exactly which low-level things need this rule applied to them, and to carefully test that everything works as expected.

@PTWaade
Copy link
Author
PTWaade commented Mar 10, 2025
8146

Thank you for the quick response ! And I'm sorry for creating a duplicate, I just saw the discussion on the original issue.
This is not urgent at all. I'd be happy to help, too, but I don't have the time this semester. I'm also not sure I'm familiar enough with Mooncake to be very efficient at figuring this out, even if I had the time..

Thank you for the great work though, and all the best!

@willtebbutt
Copy link
Collaborator

No problem at all re duplication -- we prefer to have a low bar for opening issues so that we hear about as many problems as possible, even if it does mean we occasionally get some duplication!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0