Possible performance improvement?
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
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- julia
- Lĩnh vực
- performance
Hướng nghiên cứu
Bắt đầu trong src/NonLinearProgram/NonLinearProgram.jl, quanh ForwCache và phần tính Δs, sau đó theo dõi _compute_sensitivity và _compute_derivatives_no_relax trong src/NonLinearProgram/nlp_utilities.jl. So sánh phép giải K\N hiện có với các phép giải RHS dạng vector lazy cho vi phân xuôi và ngược. Hoàn thành khi vẫn giữ nguyên các kết quả Jacobian-vector, đồng thời giảm công việc và bộ nhớ không cần thiết cho hệ tuyến tính.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
following an initially-unrelated discussion with @andrewrosemberg
I think there might be room for (substantial 🤔🤞) performance improvements in the NonLinearProgram code.
Note: what I write below might apply to other classes of problems, I only checked the nonlinear code so far.
TLDR: I think we can replace {a lot of linear system solves} with {a single linear system solve} during forward/reverse diff
Medium-long explanation:
Forward/reverse diff compute Jacobian-vector products of the form J*v or J'*v, and the Jacobian J is of the form K\N, where K, N are matrices. Currently, to obtain w=J*v, we solve KJ = N (matrix RHS), then compute J*v. I believe we can instead compute w = Jv by solving Kw = (Nv), which requires a single linear system solve (with vector RHS).
Why it matters for the ACOPF example I work with, on a 300-bus case with loads as parameters, K has size 13k x 13k, and N is 13k x 200. Replacing K\N with K\(Nv) potentially yields a 200x reduction in memory and time.
Complete thought process and stack traversing.
I'm focusing on forward diff for the sake of example, same remarks apply to reverse diff
- Forward diff returns primal/dual sensitivities in a
ForwCachestructure here:
https://github.com/jump-dev/DiffOpt.jl/blob/df4a7dcee059ee048ff620590ff5478d8b2c79cc/src/NonLinearProgram/NonLinearProgram.jl#L534-L537 - These are obtained from a left multiplication with Jacobian here
https://github.com/jump-dev/DiffOpt.jl/blob/df4a7dcee059ee048ff620590ff5478d8b2c79cc/src/NonLinearProgram/NonLinearProgram.jl#L530-L532 - Said Jacobian
Δsis computed by the_compute_sensitivityfunction. Stepping into that call, said jacobian is obtained from_compute_derivatives_no_relax
https://github.com/jump-dev/DiffOpt.jl/blob/df4a7dcee059ee048ff620590ff5478d8b2c79cc/src/NonLinearProgram/nlp_utilities.jl#L457 - which then points us to a linear system solve
https://github.com/jump-dev/DiffOpt.jl/blob/df4a7dcee059ee048ff620590ff5478d8b2c79cc/src/NonLinearProgram/nlp_utilities.jl#L425-L427
The alternative implementation I propose would cache the factorization of K (which seems to already be the case), and lazily compute Jacobian-vector products w=J*v by solving w = K\(Nv). The math would be similar (I think) for Jacobian-transpose-vector products
- Ngôn ngữ chính
- Julia
- Star
- 146
- Fork
- 21
- Merge trung bình
- 1 giờ 25 phút
- Pull request đã merge (30 ngày)
- 2
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 jump-dev/DiffOpt.jl
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
jump-dev/DiffOpt.jl#362 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
jump-dev/DiffOpt.jl#358 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
jump-dev/DiffOpt.jl#348 ·
-
good first issue
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
jump-dev/DiffOpt.jl#336 · 4 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
jump-dev/DiffOpt.jl#331 · 1 bình luận ·
Tất cả issue của jump-dev/DiffOpt.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
EnzymeAD/Reactant.jl#3549 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
JuliaGeometry/Meshes.jl#1469 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
distributed 🕸️
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
CliMA/Oceananigans.jl#6295 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày