Live molecular replacement: warmed up at model upload, searched beside the second pass and carried to the answer's merge

- WarmUpModelValidation did nothing for a prediction (no crystal cell: "no atoms or no unit cell"), so a broker's
  first molecular replacement paid every first use on the GPU. A prediction is now warmed up by a search of its
  own (WarmUpMolecularReplacement): its search model in a P 1 21 1 cell four radii on each edge, that crystal's
  intensities to 2.5 A, the search, and the validation of what it placed. RunMolecularReplacement waits for a
  warm-up still running, as ValidateAgainstModel does. --simulate-live warms the model up as the broker does at
  upload. Result-identical.
- fast_live with a prediction (or --mr): the search starts on the geometry pre-pass's merge, averaged into a group
  from that merge's own space-group search (to 3 A, standard setting), beside the second pass, on card 1 % cards,
  a quarter of the threads, under GPUWorkBeside. At the answer's merge CarryMolecularReplacement takes it over
  where it holds - same group and a cell within 1%, every copy refined by the rigid body beside the others
  against the answer's merge and its R-free within R_FREE_MARGIN of the one it was found at - and the merge is
  searched itself otherwise (and always where the twin hypothesis' merge is searched too). RESULT-CHANGING only
  in the refinement end point of the placement.

Sim-live (10 ms/frame, RTX 5080): molecular-replacement step thaumatin 0.96 -> 0.31 s, cytochrome C 1.19 ->
0.25 s; merged reflections identical; thaumatin placed model identical (0.000 A), R-free 0.3765 both;
cytochrome C a symmetry-equivalent placement, CA rmsd 0.03-0.05 A per copy, R-free 0.4443 -> 0.4431.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXc1zD1yxHqaR1DGdCTHL4
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-20 07:51:07 +02:00
1 parent 13dd2a8710
commit 6f5c235fd7
8 files changed
+376 -6

No files matched your search

@@ -41,6 +41,7 @@
#include "ModelFFT.h"
#include "ModelGrid.h" // PutModelDensityOnGrid, PutMaskOnGrid
#include "RigidBodyRefine.h"
#include "MolecularReplacement.h" // the warm-up of a prediction
#include "SigmaA.h"
#ifdef JFJOCH_USE_CUDA
#include "ModelStructureFactorsGPU.h"
@@ -1964,8 +1965,7 @@ ModelValidationResult ValidateAgainstModel(const std::vector<MergedReflection> &
const ModelValidationSchedule &schedule,
const gemmi::Op *twin_law,
const gemmi::Structure *placed) {
if (const auto w = LastWarmUp(); w.valid())
w.wait();
WaitForModelWarmUp();
#ifdef JFJOCH_USE_CUDA
// A CUDA failure ends the validation, not the run, and nothing is moved to the CPU part way through:
// the validation reports why it did not finish, and a validation that did not finish decides nothing,
@@ -1989,6 +1989,11 @@ ModelValidationResult ValidateAgainstModel(const std::vector<MergedReflection> &
#endif
}
void WaitForModelWarmUp() {
if (const auto w = LastWarmUp(); w.valid())
w.wait();
}
void WarmUpModelValidation(std::shared_ptr<const RugnuxModel> model, size_t nthreads, Logger logger) {
#ifdef JFJOCH_USE_CUDA
if (!model || get_gpu_count() == 0)
@@ -2002,6 +2007,26 @@ void WarmUpModelValidation(std::shared_ptr<const RugnuxModel> model, size_t nthr
// Held for as long as it runs: work beside a run waits for it where the card is too small for both.
GPUWorkBeside beside;
Logger quiet = Logger::Buffered();
if (const SearchModel search = PrepareSearchModel(*model); search.failure_reason.empty() && search.predicted) {
std::string failure;
try {
const MolecularReplacementWarmUp w = WarmUpMolecularReplacement(*model, nthreads);
failure = w.failure_reason;
if (w.placed) {
ModelValidationSchedule placed_elsewhere;
placed_elsewhere.fit_test = false;
failure = Validate(w.merged, w.cell, *model, quiet, &w.space_group, false, nthreads, 0.0, {},
placed_elsewhere, nullptr, true, w.placed.get()).failure_reason;
}
} catch (const std::exception &e) {
cuda_clear_error();
failure = e.what();
}
logger.Info("Molecular replacement warm-up on the GPU: {:.2f} s{}",
std::chrono::duration<double>(std::chrono::steady_clock::now() - start).count(),
failure.empty() ? "" : " (did not finish: " + failure + ")");
return;
}
const double d_min = model->structure.resolution > 0.0 ? model->structure.resolution : 2.0;
std::vector<MergedReflection> fake = ModelReferenceIntensities(*model, std::nullopt, nullptr, d_min, quiet);
for (size_t i = 0; i < fake.size(); i++) {