SciML / SciML/LabelledArrays.jl

AD (Zygote, ForwardDiff) compatibility?

Open
#91 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
125
Forks
20
Avg merge
6h 3m
Merged PRs (30d)
10

Description

LabelledArrays looks very promising to simplify model definitions. Unfortunately it seem largely incompatible with AD. Is there a good workaround?

using LabelledArrays
import ForwardDiff
import Zygote

model(p) =  p.a + p.b^2 + p.c^3

p = LVector(a=1, b=2, c=3)
ps = SLVector(a=1, b=2, c=3)
model(ps)
model(p)

ForwardDiff.gradient(model, p) # works :)
Zygote.gradient(model, p)      # ERROR: ArgumentError: invalid index: Val{:c}() of type Val{:c}

ForwardDiff.gradient(model, ps) # ERROR: type SArray has no field a
Zygote.gradient(model, ps)      # ERROR: ArgumentError: invalid index: Val{:c}() of type Val{:c}

(In case of ForwardDiff this is probably related to #68)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Julia examples for LVector and SLVector with ForwardDiff and Zygote, then inspect the compatibility concern linked to issue #68. Compare the reported field and Val-index errors across both array types; done would require a confirmed compatibility fix or a documented workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.