Skip to content

Fix RYS_per_atom_jk_ip1_sum kernel - #879

Merged
sunqm merged 1 commit into
pyscf:masterfrom
bytedance:bugfix_jk_ip1
Aug 29, 2026
Merged

Fix RYS_per_atom_jk_ip1_sum kernel#879
sunqm merged 1 commit into
pyscf:masterfrom
bytedance:bugfix_jk_ip1

Conversation

@henryw7

@henryw7 henryw7 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Fix a problem that gpu4pyscf.grad.tdrhf._jk_energies_per_atom() generates random number when sum_results=True. This mode is not used in any code path for real application, so nothing is actually affected. But gpu4pyscf/grad/tests/test_tdrhf_grad.py::KnownValues::test_jk_energies_per_atom_hermi0 will blow up randomly.

The problem is, in RYS_per_atom_jk_ip1_sum kernel function, it assumes dd_cache_size is greater than or equal to blockIdx.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.

@sunqm
sunqm merged commit 4e51558 into pyscf:master Aug 29, 2026
3 of 4 checks passed
@sunqm
sunqm deleted the bugfix_jk_ip1 branch August 29, 2026 00:07
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.

2 participants