Skip to content

Enzyme doesn't like accumulators #947

@penelopeysm

Description

@penelopeysm

Index of upstreamed issues

EnzymeAD/Enzyme.jl#2429
EnzymeAD/Enzyme.jl#2512
EnzymeAD/Enzyme.jl#2518
EnzymeAD/Enzyme.jl#2580
✅ (fixed on DPPL side) EnzymeAD/Enzyme.jl#2589


Original comment

MWE (make sure to use breaking branch, or something with accumulators)

using DynamicPPL, Distributions
using ADTypes: AutoEnzyme
import Enzyme: Enzyme, Forward, Reverse, set_runtime_activity, Const

@model f() = x ~ Normal()
model = f()
vi = VarInfo(model)
ctx = DefaultContext()
params = [0.5]

function logp(x, model, vi, ctx)
    varinfo_new = DynamicPPL.unflatten(vi, x)
    varinfo_eval = last(DynamicPPL.evaluate!!(model, varinfo_new, ctx))
    return getlogjoint(varinfo_eval)
end

logp(params, model, vi, ctx)

Enzyme.gradient(set_runtime_activity(Forward), logp, params, Const(model), Const(vi), Const(ctx))

Enzyme.gradient(set_runtime_activity(Reverse), logp, params, Const(model), Const(vi), Const(ctx))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions