SciML / SciML/ComponentArrays.jl

AD failing with ComponentArrays

Open
#126 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
375
Forks
42
Avg merge
7h 25m
Merged PRs (30d)
17

Description

Hi there, and thanks for the great package
Are ComponentArrays supposed to be AD-compatible? If so, did I do something wrong with the following code?

julia> using ComponentArrays, Zygote

julia> function mysum(x::AbstractVector)
           y = ComponentVector(x=x)
           return sum(y)
       end
mysum (generic function with 1 method)

julia> Zygote.gradient(mysum, rand(10))
ERROR: MethodError: no method matching size(::NamedTuple{(:x,), Tuple{Vector{Float64}}})

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

Start with the reported mysum example, including ComponentVector construction and the Zygote.gradient entry point, and reproduce the size(::NamedTuple) error. Trace the ComponentArrays and automatic-differentiation interaction; done means the shown gradient call works as intended without the reported MethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.