Use ChainRules for operators
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- julia
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu bằng cách đọc src/Nonlinear/univariate_expressions_generator.jl và phần dispatch toán tử xung quanh src/Nonlinear/operators.jl:570-582. Theo dõi cách ReverseAD biểu diễn các toán tử cổ điển, đã đăng ký và do người dùng định nghĩa, sau đó so sánh luồng đó với dispatch và fallback được đề xuất theo phong cách ChainRules. Công việc được xem là hoàn tất khi đã quyết định thiết kế, cập nhật phần xử lý toán tử và có bằng chứng cho thấy các trường hợp được hỗ trợ tránh được những lo ngại hiện tại về tính không ổn định kiểu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Currently, the approach in ReverseAD is to generate the symbolic expression of the first and second-order derivatives for classical univariate functions using Calculus
https://github.com/jump-dev/MathOptInterface.jl/blob/100eab2e669e73689e1dc214391d97c24402e35c/src/Nonlinear/univariate_expressions_generator.jl
Then, given a representation of the operator as an Int, we do an hard-coded binary search to evaluate a O(log(n)) number of Int comparison instead of a O(n) number of comparison:
https://github.com/jump-dev/MathOptInterface.jl/blob/100eab2e669e73689e1dc214391d97c24402e35c/src/Nonlinear/operators.jl#L570-L582
I'm wondering whether we could get closer to ChainRules instead like other Julia AD framework.
The naive way to do this would be
op = :tanh
f = eval(op)
value_and_derivative(f, 1)
The issue is that, because the value of op is discovered at run-time, the type of f is type-unstable.
But we can use the same trick with the if-else and do
if op == :tanh
value_and_derivative(tanh, x)
elseif op == :tan
value_and_derivative(tan, x)
elseif ...
else
value_and_derivative(eval(op), x)
end
Again, we can do a binary search instead of just a list of if-else.
So, for a fixed number of symbols, we avoid the type-instability thanks to the if-else and we have a fallback for the other ones with the eval.
That would also mean that for registered functions, we need to implement a method and just rely on multiple dispatch instead of adding an operators to the list of user-defined operators, user-defined operators already trigger a type-instability when they are called anyway.
- Ngôn ngữ chính
- Julia
- Star
- 6
- Fork
- 0
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 3
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của blegat/ArrayDiff.jl
-
Speed up +/- of arrays on GPUĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
blegat/ArrayDiff.jl#83 ·
-
Building matrixĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
blegat/ArrayDiff.jl#13 ·
Tất cả issue của blegat/ArrayDiff.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CliMA/ClimaArtifacts#184 ·
-
In-place Vern7 stiffness estimate uses mismatched stage valuesCó thể đã có người làm @devmotion đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SciML/OrdinaryDiffEq.jl#4778 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`pick_batchsize` spends ~1 µs constructing `BatchSizeSettings{B}(N)` with a run-time `B`Có thể đã có người làm @devmotion đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
SciML/ModelingToolkit.jl#5255 ·
Maintainer thường phản hồi trong vòng 1 ngày