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

Do we still need parametric types in model definition for autodiff? #823

Open
yebai opened this issue Feb 27, 2025 · 0 comments
Open

Do we still need parametric types in model definition for autodiff? #823

yebai opened this issue Feb 27, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@yebai
Copy link
Member

yebai commented Feb 27, 2025

We currently use the following DynamicPPL syntax to support AutoDiff.

@model function f(N, ::Type{T}=Vector{Float64}) where {T}
    a = T(undef, N)
    a .~ Normal()
    m = sum(a)
    o = T(undef, N)
    o .~ Normal(m, 1)
end

We still need the parametric type (..., ::Type{T}=Vector{Float64}) where {T} for operator-overloading approaches like ForwardDiff and ReverseDiff. However, this is no longer necessary for Mooncake, which is source-transformation-based.

There might be a way to work around such requirements for ForwardDiff and ReverseDiff by implementing a (simple) model (AST) expression transform similar to Mooncake's. Such an approach is a bit speculative at the moment, but it is worth considering to simplify the modelling syntax.

cc @willtebbutt

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

No branches or pull requests

2 participants