Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`@grad_from_chainrules` hygiene: types in vararg arguments are not escaped

Aperta
#319 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
julia
Ambito
backend

Direzione di ricerca

Start in src/macros.jl at the argument loop linked in the issue, then inspect _make_fwd_args, where the generated dispatch signature also contains the vararg type. Check how both paths handle the type in ys::Foo.... Done means the rule imports without UndefVarError and the stated ReverseDiff.gradient call returns [1.0, 1.0].

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

#224 was fixed by #232, but only for arguments of the form x::T. Types in a vararg argument are still resolved in ReverseDiff, not in the calling module:

using ReverseDiff, ChainRulesCore

struct Foo end
f(x, ys::Foo...) = sum(x)
ChainRulesCore.rrule(::typeof(f), x, ys::Foo...) = f(x, ys...), Δ -> (NoTangent(), fill(Δ, size(x)), map(_ -> NoTangent(), ys)...)

ReverseDiff.@grad_from_chainrules f(x::ReverseDiff.TrackedArray, ys::Foo...)
ERROR: LoadError: UndefVarError: `Foo` not defined in `ReverseDiff`

Expected: the rule is imported, and ReverseDiff.gradient(x -> f(x, Foo(), Foo()), [1.0, 2.0]) returns [1.0, 1.0].

Cause: the argument loop only escapes the type of a top-level x::T expression. ys::Foo... is an Expr(:..., :(ys::Foo)), so it's returned unchanged and Foo is resolved through macro hygiene. The type also ends up unescaped in the Vararg{Foo} of the dispatch signature generated by _make_fwd_args.

ReverseDiff master (b796032, v1.18.4), Julia 1.13.1.

Lingua principale
Julia
Stelle
396
Fork
61
Merge medio
23h 18m
PR unite (30g)
16

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaDiff/ReverseDiff.jl

Tutte le issue di JuliaDiff/ReverseDiff.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.