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

Non-differentiable operations are left off the tape, so replays return stale values and gradients

Aperta
#313 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
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
julia

Direzione di ricerca

Start in src/tracked.jl, where the issue says these operations on TrackedReals return untracked values, then read how forward_pass! replays recorded instructions. Use the provided floor(x[1]) * x[2] example to check GradientTape replay, compiled tape replay, and gradient! with a DiffResult. Done means the replayed value and gradient match fresh evaluation for the listed operations.

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

Descrizione

floor, ceil, trunc, round (also with a type argument), fld, cld and div of TrackedReals return untracked values (src/tracked.jl), so nothing is recorded for them. forward_pass! only replays recorded instructions, so downstream instructions keep the value captured at recording time. A replayed GradientTape or compiled tape then returns a wrong gradient, and gradient! with a DiffResult also a wrong value:

using ReverseDiff, DiffResults

f(x) = floor(x[1]) * x[2]
tape = ReverseDiff.GradientTape(f, [1.5, 2.0])
x = [2.5, 2.0]
r = ReverseDiff.gradient!(DiffResults.GradientResult(x), tape, x)

DiffResults.value(r)                          # 2.0, but f(x) == 4.0
DiffResults.gradient(r)                       # [0.0, 1.0], but ReverseDiff.gradient(f, x) == [0.0, 2.0]
ReverseDiff.gradient!(ReverseDiff.compile(tape), x)  # [0.0, 1.0]

This is not the documented limitation on value-dependent branching: there is no branch, the operation is just not recorded. Recording these operations (with zero derivatives) would let the forward pass recompute them while the reverse pass skips them.

#301 extends the same behaviour to broadcasts whose function returns no Dual (e.g. (t -> t > 0 ? 1.0 : -1.0).(x)), which master records.

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.