Merge mr-transform-layout: the corner-packed molecular transform beside MR on every card
Build Packages / Create release (push) Successful in 7s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 4m38s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 8m58s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 14m20s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 18m0s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 21m31s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 21m55s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 21m49s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 13m41s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m30s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 26m7s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 15m22s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 21m54s
Build Packages / Generate python client (push) Successful in 31s
Build Packages / Build documentation (push) Successful in 1m13s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 18m45s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 23m54s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 25m56s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 25m47s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 20m33s
Build Packages / Unit tests (push) Failing after 1h28m5s
Build Packages / Validation Battery (push) Successful in 34m34s

Combines mr-multigpu (per-card engine budgets, a transform copy on each other
card, the rotation/translation functions split over the cards) with
mr-transform-layout (the GPU transform optionally held corner-packed, same
bits, 2.2x faster rotation function).

Conflict (MolecularReplacement.cpp): the two new functions side by side
(PackMolecularTransformGPU next to SplitRotationFunction/SplitTranslationFunction).
On top of the textual resolution:
- One layout decision for all cards, not one per card: the functions are split
  into equal slices, so a mix of packed and plain cards would run at the speed
  of the plain ones; either layout gives the same bits.
- PackMolecularTransformGPU now plans with the other cards' budgets too and packs
  only where every card keeps what the plain plan gives it: this card's
  transform, engines and score engine, and on every other card its copy and its
  engine count. A packed copy is made after the card's engines are reserved;
  copy and engines within half of that card's budget leave room for the plain
  grid it is made from.
- The copies on the other cards are made in the chosen layout, and the per-card
  plan (copies, engines, room) is made with the bytes actually placed.
- Test: four 15.6 GB cards stay plain (packed, each other card would fall from
  T+2 to T+1); with 24 GB cards beside, packed.

So on a 4x T4 4nwv runs split and plain, on one card packed; whether giving up
3 of 7 engines for the packed rotation function would pay there is left to a
server measurement.

Workstation (1x RTX 5080, --gpulock), against rc176: battery timing
--benchmark standard (9zlo, 9s02, 9gjx, 4nwv) and --benchmark inhouse (myob,
cytc, 4nwv) on GPU, inhouse also --no-gpu: p.hkl, p_model.pdb and the MR_
report block byte-identical on every set. 4nwv GPU: rotation 5.53 -> 2.50 s,
MR step 20.1 -> 16.5 s (packed, 2.28 GB in place of 0.84 GB).

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-16 18:46:58 +02:00
commit 0f461a65a2
5 files changed
+169 -21

No files matched your search

@@ -2384,19 +2384,40 @@ MolecularReplacementResult search_model(const SearchModel &model, const std::vec
return result;
}
const MolecularTransform &ft = *ft_made;
[[maybe_unused]] const size_t transform_bytes = ft.Grid().data.size() * sizeof(std::complex<float>);
[[maybe_unused]] size_t transform_bytes = ft.Grid().data.size() * sizeof(std::complex<float>);
#ifdef JFJOCH_USE_CUDA
// The rotation and translation functions on the GPU where the transform fits the budget (the plan's first
// part, PlanMolecularReplacementGPU); the rest of the search is the same either way.
std::unique_ptr<MolecularReplacementGPU> gpu;
const int device = get_gpu_count() > 0 ? RigidBodyGPUEngine::CurrentDevice() : 0;
bool packed = false;
if (get_gpu_count() > 0 && transform_bytes <= gpu_budget) {
// Packed - here and in every copy on the other cards - where the answer merge's plan holds as much beside
// it on every card (PackMolecularTransformGPU), decided on that merge's sizes, which its plan then takes
// as they are.
MergeGPUSize size = sized[0].get();
MolecularReplacementGPUNeed need;
need.budget = gpu_budget;
need.other_budgets = other_budgets;
need.transform = transform_bytes;
need.rigid_body = size.rigid_body;
need.rigid_body_engines = size.rigid_body_engines;
need.structure_factors = size.structure_factors;
const size_t packed_bytes = MolecularReplacementGPU::TransformBytes(ft, true);
packed = PackMolecularTransformGPU(need, packed_bytes);
sized[0] = std::async(std::launch::deferred, [size = std::move(size)]() mutable { return std::move(size); });
logger.Info("Molecular replacement: the transform on the GPU {}{}", packed
? fmt::format("packed, {} in place of {}", in_gb(packed_bytes), in_gb(transform_bytes))
: fmt::format("plain, {} (packed, {}, does not fit beside the rest of the plan)", in_gb(transform_bytes),
in_gb(packed_bytes)),
other_budgets.empty() ? "" : ", the same in each copy on the other cards");
try {
gpu = std::make_unique<MolecularReplacementGPU>(ft);
gpu = std::make_unique<MolecularReplacementGPU>(ft, packed);
} catch (const JFJochException &e) {
result.failure_reason = std::string("GPU: ") + e.what();
return result;
}
transform_bytes = MolecularReplacementGPU::TransformBytes(ft, packed);
}
result.gpu_search = gpu != nullptr;
// The transform's copies on the other cards the plan gives one (made by the first merge's plan, the same for
@@ -2468,7 +2489,7 @@ MolecularReplacementResult search_model(const SearchModel &model, const std::vec
for (size_t i = 0; i < on.size(); i++)
uploading.push_back(std::async(std::launch::async, [&, i] {
const ScopedGpuPin pin(on[i]);
copies[i] = std::make_unique<MolecularReplacementGPU>(ft);
copies[i] = std::make_unique<MolecularReplacementGPU>(ft, packed);
}));
for (auto &u : uploading)
u.get();
@@ -3406,6 +3427,21 @@ MolecularReplacementGPUPlan PlanMolecularReplacementGPU(const MolecularReplaceme
return plan;
}
bool PackMolecularTransformGPU(const MolecularReplacementGPUNeed &need, size_t packed) {
MolecularReplacementGPUNeed with_packed = need;
with_packed.transform = packed;
const MolecularReplacementGPUPlan plain = PlanMolecularReplacementGPU(need);
const MolecularReplacementGPUPlan plan = PlanMolecularReplacementGPU(with_packed);
bool same = plan.search && plan.rigid_body_engines == plain.rigid_body_engines
&& plan.structure_factors == plain.structure_factors && need.transform + packed <= need.budget;
// Every other card keeps its copy and its engines. A copy is made after the card's engines are reserved, and
// the two within half of its budget leave room for the plain grid it is made from.
for (size_t k = 1; k < plan.cards.size(); k++)
same = same && plan.cards[k].transform == plain.cards[k].transform
&& plan.cards[k].rigid_body_engines == plain.cards[k].rigid_body_engines;
return same;
}
#ifdef JFJOCH_USE_CUDA
namespace {