Skip to content

Optimize Zonal Weights, Cartesian Extreme Lat - #1130

Merged
philipc2 merged 13 commits into
mainfrom
opti-weights
Jan 23, 2025
Merged

philipc2 merged 13 commits into
mainfrom
opti-weights

Conversation

@philipc2

@philipc2 philipc2 commented Jan 21, 2025 •

Copy link
Copy Markdown
Member

Closes #1131

Overview

  • Implements a Cartesian-Only version of extreme_gca_lat, which returns the maximum z instead of the maximum lat, not requring any spherical coordinates to be passed in or converted.
  • Implements get_non_conservative_zonal_face_weights_at_const_lat, an optimized zonal weight calculation which falls back to the original implementation for values near the equator.

Comparison

image

@philipc2 philipc2 self-assigned this Jan 21, 2025
@philipc2
philipc2 marked this pull request as draft January 21, 2025 19:29
@philipc2 philipc2 changed the title DRAFT: Optimize Zonal Weights, Cartesian-only Extreme Lat DRAFT: Optimize Zonal Weights, Cartesian Extreme Lat Jan 21, 2025
@philipc2 philipc2 changed the title DRAFT: Optimize Zonal Weights, Cartesian Extreme Lat Optimize Zonal Weights, Cartesian Extreme Lat Jan 21, 2025
@philipc2
philipc2 marked this pull request as ready for review January 21, 2025 21:11
@philipc2 philipc2 added the run-benchmark Run ASV benchmark workflow label Jan 21, 2025
@github-actions

Copy link
Copy Markdown

ASV Benchmarking

Benchmark Comparison Results

Benchmarks that have improved:

Change Before [575b00d] After [100c28f] Ratio Benchmark (Parameter)
- 512M 401M 0.78 face_bounds.FaceBounds.peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/geoflow-small/grid.nc'))
- 695M 387M 0.56 face_bounds.FaceBounds.peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.nc'))
- 330±10ns 294±0.9ns 0.89 mpas_ocean.ConstructTreeStructures.time_ball_tree('480km')
- 1.07±0.04μs 791±1ns 0.74 mpas_ocean.ConstructTreeStructures.time_kd_tree('120km')
- 318±30ns 277±1ns 0.87 mpas_ocean.ConstructTreeStructures.time_kd_tree('480km')
- 470M 382M 0.81 mpas_ocean.Integrate.peakmem_integrate('480km')

Benchmarks that have stayed the same:

Change Before [575b00d] After [100c28f] Ratio Benchmark (Parameter)
398M 398M 1 face_bounds.FaceBounds.peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/mpas/QU/oQU480.231010.nc'))
427M 427M 1 face_bounds.FaceBounds.peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/scrip/outCSne8/outCSne8.nc'))
18.7±0.06ms 18.9±0.2ms 1.01 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/mpas/QU/oQU480.231010.nc'))
7.67±0.08ms 7.56±0.2ms 0.99 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/scrip/outCSne8/outCSne8.nc'))
43.9±0.1ms 43.9±0.3ms 1 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/geoflow-small/grid.nc'))
3.93±0.09ms 3.92±0.05ms 1 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.nc'))
2.99±0.05s 2.98±0.02s 1 import.Imports.timeraw_import_uxarray
688±8μs 656±7μs 0.95 mpas_ocean.CheckNorm.time_check_norm('120km')
443±2μs 450±1μs 1.01 mpas_ocean.CheckNorm.time_check_norm('480km')
662±4ms 667±5ms 1.01 mpas_ocean.ConnectivityConstruction.time_face_face_connectivity('120km')
42.2±0.4ms 42.6±0.5ms 1.01 mpas_ocean.ConnectivityConstruction.time_face_face_connectivity('480km')
2.03±0.02ms 2.18±0.1ms 1.07 mpas_ocean.ConnectivityConstruction.time_n_nodes_per_face('120km')
604±20μs 588±10μs 0.97 mpas_ocean.ConnectivityConstruction.time_n_nodes_per_face('480km')
6.35±0.06ms 6.54±0.09ms 1.03 mpas_ocean.ConstructFaceLatLon.time_cartesian_averaging('120km')
3.65±0.05ms 3.60±0.04ms 0.98 mpas_ocean.ConstructFaceLatLon.time_cartesian_averaging('480km')
3.53±0.02s 3.53±0.01s 1 mpas_ocean.ConstructFaceLatLon.time_welzl('120km')
225±2ms 226±2ms 1.01 mpas_ocean.ConstructFaceLatLon.time_welzl('480km')
1.23±0μs 1.21±0μs 0.98 mpas_ocean.ConstructTreeStructures.time_ball_tree('120km')
436±3ms 441±2ms 1.01 mpas_ocean.CrossSection.time_const_lat('120km', 1)
227±2ms 221±4ms 0.98 mpas_ocean.CrossSection.time_const_lat('120km', 2)
115±1ms 117±0.6ms 1.02 mpas_ocean.CrossSection.time_const_lat('120km', 4)
362±4ms 358±4ms 0.99 mpas_ocean.CrossSection.time_const_lat('480km', 1)
180±2ms 180±2ms 1 mpas_ocean.CrossSection.time_const_lat('480km', 2)
93.3±1ms 93.0±1ms 1 mpas_ocean.CrossSection.time_const_lat('480km', 4)
124±1ms 124±0.7ms 1 mpas_ocean.DualMesh.time_dual_mesh_construction('120km')
8.76±0.09ms 8.59±0.1ms 0.98 mpas_ocean.DualMesh.time_dual_mesh_construction('480km')
1.10±0.02s 1.08±0.01s 0.98 mpas_ocean.GeoDataFrame.time_to_geodataframe('120km', False)
55.5±0.7ms 55.4±0.6ms 1 mpas_ocean.GeoDataFrame.time_to_geodataframe('120km', True)
87.5±2ms 86.2±0.8ms 0.99 mpas_ocean.GeoDataFrame.time_to_geodataframe('480km', False)
5.58±0.08ms 5.48±0.09ms 0.98 mpas_ocean.GeoDataFrame.time_to_geodataframe('480km', True)
338M 338M 1 mpas_ocean.Gradient.peakmem_gradient('120km')
315M 315M 1 mpas_ocean.Gradient.peakmem_gradient('480km')
2.79±0.01ms 2.75±0.01ms 0.99 mpas_ocean.Gradient.time_gradient('120km')
319±2μs 318±6μs 1 mpas_ocean.Gradient.time_gradient('480km')
242±4μs 249±2μs 1.03 mpas_ocean.HoleEdgeIndices.time_construct_hole_edge_indices('120km')
124±0.7μs 119±0.6μs 0.96 mpas_ocean.HoleEdgeIndices.time_construct_hole_edge_indices('480km')
399M 399M 1 mpas_ocean.Integrate.peakmem_integrate('120km')
156±0.6ms 158±2ms 1.01 mpas_ocean.Integrate.time_integrate('120km')
11.3±0.7ms 11.0±0.07ms 0.98 mpas_ocean.Integrate.time_integrate('480km')
358±2ms 355±3ms 0.99 mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('120km', 'exclude')
355±5ms 355±2ms 1 mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('120km', 'include')
356±2ms 354±1ms 0.99 mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('120km', 'split')
23.8±0.2ms 23.6±0.1ms 0.99 mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('480km', 'exclude')
23.5±0.3ms 24.2±0.2ms 1.03 mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('480km', 'include')
23.7±0.1ms 23.5±0.3ms 0.99 mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('480km', 'split')
55.5±0.1ms 55.5±0.2ms 1 mpas_ocean.RemapDownsample.time_inverse_distance_weighted_remapping
45.2±0.09ms 45.2±0.2ms 1 mpas_ocean.RemapDownsample.time_nearest_neighbor_remapping
356±1ms 357±1ms 1 mpas_ocean.RemapUpsample.time_inverse_distance_weighted_remapping
260±0.6ms 262±1ms 1.01 mpas_ocean.RemapUpsample.time_nearest_neighbor_remapping
311M 313M 1.01 quad_hexagon.QuadHexagon.peakmem_open_dataset
310M 311M 1 quad_hexagon.QuadHexagon.peakmem_open_grid
6.45±0.07ms 6.46±0.1ms 1 quad_hexagon.QuadHexagon.time_open_dataset
5.49±0.07ms 5.39±0.05ms 0.98 quad_hexagon.QuadHexagon.time_open_grid

@philipc2 philipc2 removed the run-benchmark Run ASV benchmark workflow label Jan 21, 2025

@erogluorhan erogluorhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a quick review and a few comments.

Comment thread uxarray/grid/integrate.py Resolved
Comment thread uxarray/grid/integrate.py Resolved
Comment thread uxarray/grid/grid.py Resolved
@philipc2
philipc2 requested a review from erogluorhan January 22, 2025 07:12

@hongyuchen1030 hongyuchen1030 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Great work!

@philipc2
philipc2 merged commit 0fd0c7e into main Jan 23, 2025
@philipc2 philipc2 mentioned this pull request Jan 29, 2025
10 tasks done
@erogluorhan
erogluorhan deleted the opti-weights branch February 5, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement extreme_gca_lat using strictly cartesian coordinates

3 participants