Ensure sort_crs_matrix in Kokkos is only performed on matrices with local column indices - #262
Merged
Merged
Conversation
…ocal column indices to prevent OOB errors Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
remove_small_from_sparse_kokkos,KokkosSparse::sort_crs_matrixwas called on the nonlocal block whilej_nonlocal_dstill held global column indices, but theKokkosCsrMatrixwas constructed withnumCols = cols_ao(the local count). Global indices >=cols_aocan cause out-of-bounds access inside the sort.rewrite_j_global_to_localinto device-side helpers (rewrite_j_global_to_local_device+remap_j_to_local_device, reusing the existingbinary_search_sorteddevice function) with the host garray copy kept in the original wrapper, whose signature is unchanged for its other callers.remove_small_from_sparse_kokkos, remapj_nonlocal_dto local indices before the lumping sort, and constructcsrmat_nonlocalwith the correctcol_ao_outputas numCols. The output block now just copies the device garray to the host.MatAXPY_kokkosneeds no change: it already performs the spadd in a merged-local column space.Testing
make checkandmake tests_shortpass: plain, with-mat_type aijkokkos -vec_type kokkos -dm_mat_type aijkokkos -dm_vec_type kokkos, and withPFLARE_KOKKOS_DEBUG=1🤖 Generated with Claude Code