Fix CUDA error 700 when docking with flexible residues#176
Draft
caic99 wants to merge 2 commits intodptech-corp:mainfrom
Draft
Fix CUDA error 700 when docking with flexible residues#176caic99 wants to merge 2 commits intodptech-corp:mainfrom
caic99 wants to merge 2 commits intodptech-corp:mainfrom
Conversation
The CUDA kernel supports at most MAX_NUM_OF_FLEX_TORSION (1) flex torsion, but using --flex with --gpu_batch crashed with CUDA error 700 instead of reporting the limitation. Root causes: 1. Ligand Config grouping (main.cpp) ignored receptor flex atoms and torsions, placing combined models (e.g. 165 atoms) into undersized Config groups (e.g. SmallConfig with max 40), causing out-of-bounds GPU memory access. 2. assert(m.num_other_pairs() == 0) was compiled out in Release builds (NDEBUG), providing no protection at all. 3. cuda_to_vina result conversion did not populate c.flex, causing segfault during CPU-side pose refinement when model.set(c) was called. This commit: - Fixes grouping to account for receptor flex atoms and torsions so that the correct Config is selected - Replaces the ineffective assert with a comment noting the limitation - Initializes flex conf from the model before pose refinement - Adds an early check that exits cleanly with a clear error message when flex torsions exceed the kernel's supported limit Single flex residue docking (1 torsion) now works correctly on GPU. Configurations exceeding the limit get a clear error instead of a CUDA crash. Refs dptech-corp#159 Co-Authored-By: Claude Opus 4.6 (1M context) <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
Fixes #159 — CUDA error 700 (
cudaErrorIllegalAddress) when using--flexwith--gpu_batch.The CUDA kernel supports at most 1 flex torsion (
MAX_NUM_OF_FLEX_TORSION = 1), but exceeding this limit crashed with an opaque CUDA error instead of a clear message. The crash had three root causes:main.cpp): Ligand classification ignored receptor flex atoms/torsions. A combined model with 165 atoms was placed into SmallConfig (max 40), causing out-of-bounds GPU memory access → CUDA error 700.monte_carlo.cu):assert(m.num_other_pairs() == 0)was compiled out byNDEBUGin Release builds, providing zero protection.vina.h):cuda_to_vinadidn't populatec.flex, so CPU-side pose refinement segfaulted onmodel.set(c).Changes
main.cppmonte_carlo.cuvina.hBehavior
CUDA error code=700 cudaErrorIllegalAddressCUDA error code=700Test plan
🤖 Generated with Claude Code