Report: 3-D fractional-update balance refactoring¶
Date: 2026-10-05 (updated after Phase 3). Plan: view_balanced_fractional_sampling_refactoring.md beside this report (its Progress section
holds the detail). Run: autonomous run balance_sampling on dell, base commit 9ac9517d0, nothing committed. The
diffs of the three phases are in /home/elmlundho/agent_runs/balance_sampling/review/phase_N.diff; logs, scripts and
tables are under /home/elmlundho/agent_runs/balance_sampling/scratch (logs/, cmp/).
Terms: fractional update refines only a sample of the particles each iteration (nsample of them); a sampling
unit is one selected 2-D class; FSC 0.143 is the resolution where the Fourier shell correlation of the two
independent half-map reconstructions falls to 0.143; sweep is the number of draws that visit every particle once.
What changed¶
- Phase 0 (
phase_0.diff, plan only). Baseline on a Release build of the base:solve3D nsample=1000withbalance=yes(A, 3.84 and 3.93 Å final FSC 0.143) and withpartition=yes(B, 3.98 and 3.84 Å), andrefine3D_stateson A1's final project (C, 10:59). The project has 50 selected classes, sonclustkeeps its default of 20. - Phase 1 (
phase_1.diff).balance=none|class|cavgreplacesbalance=yes|noand the sampling use ofpartitionandclust_crit. Sampling units are the selected 2-D classes; undercavgthey are grouped by average-linkage clustering of the class averages on their correlation, and the quota is nested: equal over groups, equal over the classes of a group, lowest update count first.clssmp.bincarries the group as a fourth header value. Projection-direction sampling inrefine3D_statesand thecls2Dcluster branch ofclassify3D_refsare deleted. The sweep comes from the unit table (refine3D_statesinitialization and iteration cap,refine3D_autocap); a coverage table is printed before the first stage with warnings.refine3D_statesholds one particle cohort per frequency block (internalcohort_sampling,sample4update_rescore). New unit tests cover the nested quota, the sweep, cohort rescoring, the file's group column and the trailing weight of a held cohort. Policies and the two sampling skills are updated. - Phase 2 (
phase_2.diff). Comparison runs; under the maintainer's ruling the per-stateupdatecnt == 1diagnostic added in Phase 1 was removed again, and theclassequivalence was settled by a fixed-seed paired test. The plan moved tocompleted/. - Phase 3 (
phase_3.diff, plan and report only). Added by the maintainer: two more seeded case-A runs, one per binary, to test reproducibility under a fixed seed. Both same-binary pairs differ from iteration 1, sosolve3Dis not reproducible under a fixed seed and the base/new outcome difference is not evidence against the change.
Decisions taken under delegation¶
All are recorded in the plan's Progress section (Phase 0, Phase 1, Phase 2 entries).
- Within a group, the remainder of the equal split goes to the classes whose particles have the lowest mean update
count (ties: larger population, then index): deterministic for every distributed partition and rotating over
iterations. The group level keeps the former equal-increment rule, so
classallocates exactly asbalance=yes. solve3Dwritesclssmp.binfor every fractional run (class units undernone, because its initial greedy sample and the docked split checkpoint always drew from class units); the split assignment uses the run'sbalance, orclassundernone.solve3Dwith input volumes defaults toclassand rejectscavg(random classes have no averages), as it rejectedpartition=yesbefore.refine3D_statesandclassify3D_refsleave particles inactive inptcl3Dout of their units.- The
classify3D_refsiteration cap was left unchanged (the plan names onlyrefine3D_statesandrefine3D_auto). - The
selectionprogram'sbalancewas a UI entry its commander never read; its choices becamenone|classandcavgis rejected on its command line. - Case C′ restores A1's run directory from
scratch/keep/before it starts, because the kept project refers to its consensus map by absolute path. - Phase 2 added four unseeded spread runs (two base, two
class) as evidence when A′2 failed; they are not acceptance runs. Phase 3 copied the Phase 2 seeded-pair script under new run names (seed_pair2.sh) and compared the logs with a new script (seed_logcmp.py).
Deviations from the plan¶
- One file-table row added in Phase 1 (
simple_oris_tester.f90, named in the plan's tests but missing from the table) and one in Phase 2 (simple_convergence.f90, for the ruling). - The per-state
updatecnt == 1diagnostic of the plan's "Convergence" section was implemented in Phase 1 and removed in Phase 2 by the maintainer's ruling: under cohorts it always reads 0. - The A′ acceptance as written (each A′ within the larger of the Phase 0 spread and 3 % of A's mean, i.e. ≤ 4.00 Å) failed for A′2 (4.29 Å); the phase stopped, and the maintainer's ruling replaced the criterion for A′ by a fixed-seed paired identity test of the sampling.
Evidence against the baseline¶
| Case | Baseline (Phase 0) | New code (Phase 2) | Acceptance |
|---|---|---|---|
A / A′ (balance=yes / class) |
3.84, 3.93 Å | 3.89, 4.29 Å | by ruling: sampling identical (below) |
B / B′ (partition=yes / cavg) |
3.98, 3.84 Å | 3.93, 3.89 Å | pass (≤ 4.05 Å) |
C / C′ (refine3D_states) |
state 1 4.03 Å, state 2 10.20 Å, 10:59 | 4.08 Å, 12.09 Å, 21:50 | completes, report shown, cohort behaviour holds |
- Same-seed control (Phase 3): base build 3.89 and 4.47 Å, new build 4.41 and 3.93 Å, each pair differing from
iteration 1 (
scratch/logs/p3_seed_logcmp.txt). - Paired fixed-seed test (
SIMPLE_SEED=20261005, inherited by the workers): all 133 sampling rounds of all eightsolve3Dstages hold the identical particle set in the base (balance=yes) and new (balance=class) runs; finalsampledandupdatecntagree for all 5,513 particles (scratch/cmp/seed/compare_rounds.txt). Final FSC 0.143: 3.89 Å (base) and 4.41 Å (class); their alignments differ from iteration 1 with identical particles. - C′:
% PARTICLES UPDATED SO FARper frequency block 27.374, 48.243, 62.369, 74.240, 83.998, 90.646, 94.444, 97.270, 98.789, 99.359, 99.739, 100.000, constant inside every block; the coverage report gives a 9-block sweep against 12 planned blocks, visits per particle 1.41 to 12.0, no warning; every active particle updated. C′ runs 36 iterations (4 × sweep) instead of C's 15, hence the doubled wall time; its projection-direction sampling drew 55.6 % of the particles per iteration whatevernsamplewas, C′ draws 27.4 %. - Builds: Release and Debug show the base's linker warnings only (5 and 6), no compiler warnings; the fast gate passes
(14/14) on the Phase 1 Debug build and the Phase 2 Release build; the unit areas of the touched code and
check_test_registry.pypass.
Open for the maintainer¶
- De novo divergence (not caused by this change).
solve3Dcase A on beta-galactosidase sometimes goes wrong in its ab initio stages (stage-4 FSC 0.143 near 8–9 Å instead of 5.5–6 Å) and ends above the Phase 0 limit of 4.00 Å. All runs of this refactoring: basebalance=yes1 of 6 poor (3.84, 3.93, 3.89, 3.98, 3.89, 4.47 Å), newbalance=class3 of 6 poor (3.89, 4.29, 5.10, 3.89, 4.41, 3.93 Å), view-partition B and B′ 0 of 4, and 0 of 6 identical runs in the earlier trailing_halfmap run.classsamples the same particles asbalance=yesin every round (Phase 2 paired test), and Phase 3 showed thatsolve3Dis not reproducible under a fixedSIMPLE_SEEDeven on one binary: two same-seed runs of the base build, and two of the new build, part at iteration 1 in cFAR, orientation change and score, as the base/new pair did. The spread is in the multithreaded alignment numerics, and 1 of 6 against 3 of 6 does not separate from chance. Open: the failure rate ofsolve3D's random start on this data set, and whether a fixed seed should make it reproducible. A two-run spread is too small a baseline for acceptance onsolve3Dresolutions. - Coverage warnings. With the
refine3D_statesiteration cap of 50 and three-iteration blocks, any sweep above about 17 blocks will trigger the "least-visited unit below one visit" warning; by design nothing is adjusted. - Pre-existing, not changed: distributed non-probabilistic refinement draws its stochastic sample per partition
with independent seeds, so the union is not one quota-exact sample; the
pose_policy=fixedinitialization phase may stop on the overlap target before a full sweep. - Old artifacts:
clssmp.binfiles andsolve3Drun manifests recordingpartitionfrom before this change do not read (release 4 rules);.simpleprojects are unaffected.