Fix consistency of passing array_ns in functions#1178
Conversation
|
Hi there, this is jenkins continuous integration... |
1 similar comment
|
Hi there, this is jenkins continuous integration... |
Remove the array_ns: ModuleType parameter from functions that already receive NDArray inputs. Instead, derive the array namespace using data_alloc.array_namespace() from the first input array. Updated functions: - grid/topography.py: compute_nabla2_on_cell, smooth_topography - initialization/topography.py: jablonowski_williamson - math/projection.py: gnomonic_proj - metrics/compute_coeff_gradekin.py: compute_coeff_gradekin - grid/geometry_stencils.py: compute_primal_cart_normal Also updated all callers and removed now-unused imports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
Remove array_ns: ModuleType = np parameters from functions that already receive input NDArray arguments. These functions now derive the array namespace internally using data_alloc.array_namespace() from their first input array. Functions modified: - compute_max_nbhgt_array_ns (derives from c2e2c) - _compute_k_start_end (derives from z_mc) - compute_diffusion_mask_and_coef (derives from c2e2c) - compute_diffusion_intcoef_and_vertoffset (derives from c2e2c) - compute_wgtfacq_c_dsl (derives from z_ifc) - compute_wgtfacq_e_dsl (derives from e2c) - compute_zdiff_gradp (derives from z_mc) - compute_flat_max_idx (derives from e2c) - compute_nflat_gradp (derives from flat_idx_max) - compute_exner_w_implicit_weight_parameter (derives from c2e) Callers in metrics_factory.py and test files updated accordingly. Unused imports (ModuleType, numpy) removed where no longer needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
…put NDArrays Remove array_ns: ModuleType = np parameters from functions that already receive input NDArray arguments. These functions now derive the array namespace from their input arrays using data_alloc.array_namespace(). Files modified: - base.py: _replace_skip_values, _has_skip_values_in_table - grid_refinement.py: compute_domain_bounds, is_unordered_field, convert_to_non_nested_refinement_values, is_limited_area_grid - grid_manager.py: _get_derived_connectivities, _construct_diamond_vertices, _determine_center_position, _construct_diamond_edges, _construct_triangle_edges, _construct_butterfly_cells, _patch_with_dummy_lastline - vertical.py: _compute_SLEVE_coordinate_from_vcta_and_topography, _check_and_correct_layer_thickness, _check_flatness_of_flat_level, compute_vertical_coordinate All callers updated accordingly. Unused imports removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
…put NDArrays Remove array_ns: ModuleType = np parameters from functions that can derive the array namespace from their input NDArray arguments using data_alloc.array_namespace(). Updated functions: - definitions.py: Reductions protocol and SingleNodeReductions methods - halo.py: global_to_local() - mpi_decomposition.py: _reduce, _calc_buffer_size, min, max, sum, mean - grid_manager.py: _get_local_connectivities and its caller - geometry.py: remove functools.partial wrapping for mean reductions - metric_fields.py: update min_reduction callable signature and call Functions without input arrays (_create_dummy_decomposition_arrays, _min_identity, _max_identity, _sum_identity) retain array_ns parameter. Note: Test files in decomposition/mpi_tests/ still pass array_ns to reduction methods and need updating separately (MPI tests require special infrastructure to run). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: jcanton <5622559+jcanton@users.noreply.github.com>
|
Make sure the following scenario is covered: if you are on gpu, you might want to use cupy, but the starting point might be a numpy array after reading from somewhere. |
Context for @copilot: arrays that are read in
but it's good to double check. @copilot can you check for this and make necessary changes? Also continue work on unfinished tasks. |
|
@copilot once you're done with the previous changes, can you make a summary of the state of the following (don't make any changes):
|
Verified and confirmed: the GPU/serialbox scenario is covered. Functions where inputs are already arrays derive I've also completed all the remaining unfinished work:
Commits: |
Here's the current state: 1. Defaulted
So 35 problematic defaulted parameters remain (all in files not yet refactored), and 5 legitimate ones. 2. Places where
Beyond
In total, roughly 26 of the 34 |
@copilot for 1. fix the remaining array_ns uses that still need refactoring. Keep For 2. change the ones where |
…functions in interpolation_fields.py Each function now overrides the array_ns parameter by deriving the array namespace from the first NDArray parameter at runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: msimberg <42977+msimberg@users.noreply.github.com>
… functions Override the array_ns parameter by deriving it from the first NDArray argument using data_alloc.array_namespace() in all 11 functions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: msimberg <42977+msimberg@users.noreply.github.com>
… all/any to member form Agent-Logs-Url: https://github.com/C2SM/icon4py/sessions/328d2ac6-5d1f-45e0-9236-cfe0a64ad8f6 Co-authored-by: msimberg <42977+msimberg@users.noreply.github.com>
Done in commits Task 1: Added Task 2: Converted to member form where
|
|
@copilot run |
Agent-Logs-Url: https://github.com/C2SM/icon4py/sessions/628aba4d-eef8-42b7-b601-bf5eb8edc11b Co-authored-by: nfarabullini <41536517+nfarabullini@users.noreply.github.com>
Ran
Remaining pre-commit failures are infrastructure-related ( Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
cscs-ci run default |
|
cscs-ci run distributed |
|
@copilot Fix errors wuch as: |
|
@nfarabullini I fixed the reductions array_ns issues locally and pushed. |
|
cscs-ci run distributed |
|
Mandatory Tests Please make sure you run these tests via comment before you merge!
Optional Tests To run benchmarks you can use:
To run tests and benchmarks with the DaCe backend you can use:
To run test levels ignored by the default test suite (mostly simple datatest for static fields computations) you can use:
For more detailed information please look at CI in the EXCLAIM universe. |
|
cscs-ci run distributed |
|
cscs-ci run default |
|
Waiting for #1102 to be merged first. This will conflict heavily with it. |
Refactored functions that receive input numpy/cupy arrays to derive
array_nsfrom those inputs usingdata_alloc.array_namespace()instead of requiring it as a parameter. Functions that only produce arrays (no suitable input arrays) retain thearray_nsparameter.