From e8584423c64ebef4816d89c64b3e93c0ffc2a551 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Fri, 9 Oct 2026 12:47:04 +0200 Subject: [PATCH] rugnux: free the merge's GPU engine before model validation The rotation merge's resident device engine (RotationScaleMerge's GPU half) lived to the end of the scale-merge step, so model validation reserved its own engines on a card the merge still held: on the F432 1.30 A set 8.8 GB of the 16.6 GB card was taken when the validation started. Nothing after the validation reads the engine except the opt-in finalist ledger's P1 merge, which runs on it beside the validation; so, unless that merge is running, the engine is released just before the validation call. Device memory in use when the validation starts: 8.8 GB -> 2.2 GB; the validation window's device-wide peak is now 6.5 GB (structure factors 2.2 GB, ten rigid-body engines 2.5 GB). p.mtz md5-identical. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SVmAWnzCmRKAXVUCdc4iNi --- rugnux/RugnuxScaleMerge.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rugnux/RugnuxScaleMerge.cpp b/rugnux/RugnuxScaleMerge.cpp index 3197f3765..00dd32f2d 100644 --- a/rugnux/RugnuxScaleMerge.cpp +++ b/rugnux/RugnuxScaleMerge.cpp @@ -3259,6 +3259,11 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { // The ledger's P1 merge (started above) is taken before anything below acts on what the // validation decides: relabelling the outcomes and the group is what it must not see happen. // Every such relabelling reaches the P1 merge afterwards, through merge_to_written. + // The merge is done with its engine - nothing below reads it but the finalist ledger's P1 merge, + // which runs on it beside the validation - so the device memory it holds goes back before the + // validation decides, from the card's total, whether its GPU path fits. + if (!ledger_ahead.valid()) + rsm.reset(); ModelValidationResult validation = validate(logger); take_ledger_p1(); // A model that was asked for and could not be used has to say so where anyone will see