Fix CUDA error when docking with flexible residues#175
Closed
caic99 wants to merge 1 commit intodptech-corp:mainfrom
Closed
Fix CUDA error when docking with flexible residues#175caic99 wants to merge 1 commit intodptech-corp:mainfrom
caic99 wants to merge 1 commit intodptech-corp:mainfrom
Conversation
The CUDA kernel lacked support for flexible receptor residues, causing crashes when using the --flex flag. This fixes five interrelated bugs: 1. Remove assert(m.num_other_pairs() == 0) that blocked flex docking 2. Add other_pairs (flex-flex interactions) storage and evaluation in the CUDA kernel scoring function 3. Increase MAX_NUM_OF_FLEX_TORSION from 1 to 24 to prevent buffer overflow when copying flex torsion data 4. Fix ligand grouping to account for receptor flex atoms/torsions, preventing models from being placed in undersized Config groups 5. Initialize flex conf before pose refinement to prevent segfault when the CPU-side quasi_newton calls model.set() Also adds sm_100 (Blackwell/B200) to CMAKE_CUDA_ARCHITECTURES. Closes dptech-corp#159 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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--flexfor flexible receptor residues.The CUDA kernel completely lacked support for flexible residues, causing crashes through five interrelated bugs:
assert(m.num_other_pairs() == 0)in 4 locations inmonte_carlo.cuimmediately crashed when flex residues createdother_pairs(flex-flex interaction pairs)MAX_NUM_OF_FLEX_TORSION = 1was too small for real flex residues (which can have 20+ torsions across multiple residues), causing memory corruption when copying torsion datamain.cppignored receptor flex atoms/torsions, placing combined models (e.g., 165 atoms) into undersized Config groups (e.g., SmallConfig with max 40 atoms), causing out-of-bounds GPU memory accesscuda_to_vinadidn't initialize flex conformation data, causing segfault during CPU-side pose refinement whenmodel.set()was calledChanges
kernel.hMAX_NUM_OF_FLEX_TORSION1→24 in all Config structs; addother_pairsstructs tom_cuda_tandm_cuda_t_<Config>monte_carlo.cuother_pairsGPU data copying; fix flex torsion copy to flatten all residueswarp_ops.cuhother_pairsinm_eval_deriv_warp; copyother_pairsinm_cuda_init_with_m_cuda_warpmain.cppvina.hCMakeLists.txtCMAKE_CUDA_ARCHITECTURESLimitations
This fix enables flex docking to run without crashing and correctly evaluates flex-flex interaction energy (
other_pairs). However, flex torsions are not yet optimized during the GPU Monte Carlo search — they remain at their initial values and are refined only during the CPU-side post-processing step. Full flex torsion optimization in the CUDA kernel (flex tree coordinate updates, flex torsion mutation, flex derivatives) would be a follow-up enhancement.Test plan
🤖 Generated with Claude Code