perf(amr): source-centric transposed CSR for the coarse–fine fill adjoint
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
- 45/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- julia
- Lĩnh vực
- distributed-systems, performance
Hướng nghiên cứu
Start with halo_update_adjoint! and the existing (fills, terms) CSR, then review the forward fusion in #84 and descriptor context from #42. Measure schedule rebuild cost and transposed-CSR footprint for both layouts, and run test/exchange_schedule.jl, including its bit-parity and zero-allocation assertions. Done means the adjoint remains the exact transpose, preserves bit parity, and passes both layout checks.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What
halo_update_adjoint! still runs one scatter-add broadcast per CSR term, and after the forward gather was fused (#84) it is by far the slower half of the exchange. Fusing it bit-identically needs a source-centric transposed CSR built at schedule time; this issue is that work.
Why it was not done in #84
The forward gather is dst-centric and each dst cell is written by exactly one fill, so one broadcast per fill reproduces the per-term loop's arithmetic exactly. The transpose is a scatter, and a fill's term windows collide on shared source cells, so a dst-centric single pass would accumulate into a colliding cell in dst-cell order instead of term order and change the roundoff. Measured on refined forests (x < 0.5, maxlevel 2), counting the scatter-adds a phase issues and how many land on a cell some earlier term of the same fill already wrote:
| forest | phase | fills | scatter-adds | colliding |
|---|---|---|---|---|
| 3D 32³, 8³ blocks | interpolation | 1024 | 77 824 | 40 960 |
| 3D 32³, 8³ blocks | restriction | 64 | 9 216 | 0 |
| 3D 32³, 4³ blocks | interpolation | 4096 | 77 824 | 0 |
| 2D 256², 32² blocks | interpolation | 64 | 3 584 | 1 792 |
| 2D 256², 32² blocks | restriction | 16 | 1 280 | 0 |
Restriction rows never collide, and interpolation rows only collide once the tangential windows are wider than one cell (blocksize ≥ 6). Fusing "only collision-free rows" was considered and rejected: it makes the exchange's cost depend on the blocksize in a way nothing in the API hints at.
The measured lopsidedness
Min-of-N, alternating processes, three rounds, on this machine (macOS/aarch64, Julia 1.12), µs:
| leg | forward (fused) | adjoint (per-term) |
|---|---|---|
3D 32³ / 4³ blocks, BlockField |
677 | 3322 |
| 3D 32³ / 4³ blocks, packed | 672 | 3448 |
| 3D 32³ / 8³ blocks, packed | 205 | 983 |
| 2D 256² / 32² blocks, packed | 14.5 | 46.2 |
So the adjoint is 3–5× the forward on exactly the geometry #84 was aimed at, and #84's acceptance is met on the forward half only.
Shape of the fix
Emit, alongside each phase's (fills, terms) CSR, a transposed CSR keyed by source cell: for every source cell touched by the phase, the list of (dst cell, weight) contributions in the order the current loop applies them — fills in reverse order, terms within a fill in forward order. The adjoint sweep then walks source cells once, accumulating left to right, which is the same accumulation sequence per cell and therefore bit-identical, followed by the dst zeroing pass.
Things to settle before building it:
- Storage. This is cell-granular, not slab-granular: ~78 k contributions for the 3D interpolation phase above, each needing a block index plus a Cartesian index on both ends. That is the descriptor bloat #42/#84's CSR shape was chosen to avoid, and it is rebuilt on every regrid — measure the build cost and the footprint before committing to it.
- Layout independence. Contributions cannot be precomputed as linear indices:
BlockFieldandPackedBlockFieldindex the same cell differently, so the record has to stay (block, CartesianIndex) and the sweep pays the decode. - Acceptance. The exchange must stay the exact transpose of the forward (dot-product identity to roundoff), the existing bit-parity testsets in
test/exchange_schedule.jlmust keep comparing against something that is not a re-written copy of the new loop, and the zero-allocation assertions must hold for both layouts.
Related: #84 (forward fusion), #42 (isbits descriptors).
🤖 Filed by Claude — Kyle's ghost cells, my scatter-adds.
- Ngôn ngữ chính
- Julia
- Star
- 3
- Fork
- 1
- Merge trung bình
- 1 ngày 28 phút
- Pull request đã merge (30 ngày)
- 6
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 RallypointOne/MatrixFreeOperators.jl
-
Roadmap: open-issue priorityĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
perf(forest): thread the reference BlockForest path — leaf sweeps and exchange descriptor loopsĐang mởperformance
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
RallypointOne/MatrixFreeOperators.jl#81 · 1 bình luận ·
Tất cả issue của RallypointOne/MatrixFreeOperators.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
legend-exp/LegendDataManagement.jl#232 ·
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 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SciML/OrdinaryDiffEq.jl#4907 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
documentation model-weights
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
FluxML/Metalhead.jl#311 ·
Maintainer thường phản hồi trong vòng 1 ngày