Repository navigation
fix(pw): prevent GPU force projector indexing overflow - #8471
Open
Flying-dragon-boxing wants to merge 6 commits into
Open
Flying-dragon-boxing wants to merge 6 commits into
Flying-dragon-boxing wants to merge 6 commits into
Conversation
Split from deepmodeling#8306. Bound save/restore launches by thread count on CUDA and HIP.
…ce-projector-bounds # Conflicts: # source/source_pw/module_pwdft/kernels/cuda/force_op.cu # source/source_pw/module_pwdft/kernels/rocm/force_op.hip.cu
…ce-projector-bounds
Flying-dragon-boxing
marked this pull request as ready for review
December 2, 2026 06:53
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc6052be8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ce-projector-bounds # Conflicts: # source/source_pw/module_pwdft/kernels/unittests/CMakeLists.txt
This branch has not been deployed
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.
What's changed?
With 8,421,376 selected projector entries, the GPU save and restore kernels used to launch one block per entry. The excess threads pushed the signed 32-bit index past its range. Negative indices could pass the bounds check and lead to out-of-bounds writes.
Launch one thread per entry, rounded up to a whole block. Use
size_tfor flattened indices and offsets, reject threads beyond the entry count, and skip empty launches. CUDA and ROCm use the same bounds logic. The projector mapping and restore coefficient are unchanged.Linked Issue
Correctness fix split from #8306 by @dyzheng.
Unit Tests and/or Case Tests for my changes
Recompiled the standalone CUDA reproducer against the upstream and patched
force_op.cuon an RTX 4090 with CUDA 12.6. From the scratch directory, with each source version saved asforce_old.cuorforce_new.cu:c7a18a8ed:cudaMemcpyreported illegal memory access (exit 2).Governance Notes