DRAFT: Optimize Connectivity Construction#1195
Conversation
|
@hongyuchen1030 Hi Hongyu, I'm trying to bring this PR up to date. Currently, merging it into main is complex with significant merge conflicts. I've been working through some of them, but since I'm new I'm not completely sure what to prioritize. I ran a speed comparison for the edge_node and face_face connectivity changes in Claude, which found similar speedups to what Philip was originally finding, so I think the core changes here are probably still valuable. I'm still getting some value errors in the connectivity tests though. |
Hi @cmdupuis3, Thanks for looking into this PR. I think one of the easiest ways to speed up connectivity construction is to separate the logic by input grid type when possible, and only use the fully general default solution for uncategorized or irregular grids. In many common cases, we are working with structured or semi-structured grids where we can safely use additional assumptions about the grid shape/connectivity. Those assumptions can make the implementation much easier to optimize and vectorize. The current general solution is useful because it can handle arbitrary grid shapes, but that also makes it less ideal for performance-sensitive paths. So I think a good direction would be to provide faster specialized paths for the input grid types UXarray already supports, while keeping the existing general method as the fallback for arbitrary grids. Also, if any of the terminology around spherical grids, connectivity, or grid geometry is confusing, you can refer to my paper here: https://egusphere.copernicus.org/preprints/2026/egusphere-2026-636/. It may be more detailed than what is needed for this specific PR, but I think it can serve as a useful guideline and reference for the concepts and terminology involved here. |
Closes #1196 #1197
Overview
edge_node_connectivityface_edge_connectivityface_face_connectivityGridAll timings below were taken on a single NCAR Derecho CPU node.
Connectivity Timing (Before)
Connectivity Timings (After)
Connectivity Speedup
edge_nodeandface_edgeconnectivity8.7xto17.35xspeedupface_face462xto764xspeedup