Skip to content

Aliased differentials and Inplace Accumulation #350

Open
@oxinabox

Description

@oxinabox

If a pullback is something like dx->(dx, dx) for dx being a reference type, e.g. like the pullback for +(::Array, ::Array), then the two outputs are the same object.
They are aliased.
Even though they are actually differentials for (usually) distinct (nonaliased) primal values.
This causes inplace accumulation to act wrong.

See discussion here FluxML/Zygote.jl#962 (comment)
where @mcabbott was just adding inplace accumulation for getindex.

I am wondering if we need to require that if the primals are not aliased the differentials also need to not be aliased.
This extra copies is slow if not inplace accumulation is not actually done though.
we might want to make it configurable depending on the AD system.
(this related to the config needs for #68)

I think the ideal solution would be copy-on-write objects.
But doing that without language support is suffering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdesignRequires some desgin before changes are madeinplace accumulationfor things relating to inplace accumulation of gradients

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions