这是indexloc提供的服务,不要输入任何密码
Skip to content

Enzyme fails on simple MLP on GPU #2607

@lassepe

Description

@lassepe

MWE

On Julia 1.10.9

using Flux: Flux
using Enzyme: Enzyme
using CUDA: CUDA
using cuDNN: cuDNN

function reproducer(; device = Flux.gpu)
    Enzyme.API.strictAliasing!(false)
    Enzyme.Compiler.VERBOSE_ERRORS[] = true
    model =
        Flux.Chain(Flux.Dense(28^2 => 32, Flux.sigmoid), Flux.Dense(32 => 10), Flux.softmax) |>
        device
    # this allocates space for the gradient
    model_shadow = Enzyme.Duplicated(model) |> device
    input = Flux.randn32(28^2, 1) |> device
    label = [i == 3 for i in 1:10]
    f = (m, x, y) -> sum(abs2, m(x) .- y)
    grad_model = Flux.gradient(
        f,
        model_shadow,
        # input and label are const because we differentiate w.r.t. to the model parameters, not input or output.
        Enzyme.Const(input),
        Enzyme.Const(label),
    )
end

This reproducer works on CPU, but on GPU I get the error attached in this file (too long to fit into the issue character limited).

error.txt

Metadata

Metadata

Assignees

No one assigned

    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