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

Đang mở
#313 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
julia
Lĩnh vực
machine-learning

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Julia
Star
397
Fork
62
Merge trung bình
8 giờ 9 phút
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JuliaDiff/ReverseDiff.jl

Tất cả issue của JuliaDiff/ReverseDiff.jl

Issue tương tự

Thêm issue về Julia

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.