Fix RYS_per_atom_jk_ip1_sum kernel - #879
Merged
Merged
Conversation
…_sum kernel and generate random number
sunqm
approved these changes
Aug 29, 2026
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.
Fix a problem that
gpu4pyscf.grad.tdrhf._jk_energies_per_atom()generates random number whensum_results=True. This mode is not used in any code path for real application, so nothing is actually affected. Butgpu4pyscf/grad/tests/test_tdrhf_grad.py::KnownValues::test_jk_energies_per_atom_hermi0will blow up randomly.The problem is, in
RYS_per_atom_jk_ip1_sumkernel function, it assumesdd_cache_sizeis greater than or equal toblockIdx.x * (li+1)*(li+2)/2 * (lj+1)*(lj+2)/2 * (lk+1)*(lk+2)/2 * (ll+1)*(ll+2)/2, but the caller does not satisfy that, so at https://github.com/pyscf/gpu4pyscf/blame/551d9bb165941a49c0b3d1281a3705680487b1b3/gpu4pyscf/lib/gvhf-rys/rys_contract_jk_ip1.cu#L1434 a block actually steps on the space assigned to another block.