Status (2026-10-20): implemented, and partly superseded. The first-
solve3Dcapnptcls3D_maxthis plan keeps no longer exists (removed inc878daae4), and decisions 2 and 3 were replaced or reversed. The living description isdoc/policies/stream/stream_3D_ingestion_policy.md. What is left open is a stream run that exercises the first run, which is a validation, not a refactor.
Stream 3D first run plan, 7 October 2026¶
p07 (stream multistate 3D) stops re-classifying its first publication with solve2D. The first
publication is taken like every later one. The first solve3D runs on at most a set number of
selected particles, 100,000 by default. Every other selected particle waits for the first
solve3D_addon run.
Decisions¶
- The cap applies to the first
solve3Donly. Every selected particle it leaves out joins the first addon run's cohort, however many there are. Later addon runs are unchanged. - The first run's particles are drawn class-balanced. Each selected 2D class gets an equal share, capped at its population, with its best 2D scores first.
- p06 keeps publishing iteration 10. p07 scores that publication's class averages with the pool model, as it scores every later one. They were made with the previous mask diameter and before the low-pass ramp ended, so the first selection is less settled than later ones. Later publications correct it, because they now govern every row (item 4 of section 2.1).
- The cap is a p07 parameter only. It is a developer setting on p07's UI entry, like
nstatesandnparts3D. The master does not pass it, so a stream run uses the default.
Defaults taken without a question:
- The name is nptcls3D_max, after the stage's 3D job settings (nparts3D, nthr3D) and
the _max limits (nsample_max, nboxes_max). Change it before implementing if another name
reads better.
- A selection within the cap gives the first run every selected particle, as today, and
leaves nothing queued.
- The first run still starts once MIN_PTCLS_PER_STATE (5) particles per state are
selected. It takes the first publication's selection alone, because p07 takes no publication
while a job runs.
1. Where things stand¶
- The first set (
take_first_set,merge_first_set; follow-up plan, decisions 31 to 38): - The first publication into a stage without rows is merged as it selects its particles.
The pool model's selection is kept only as a fallback (
first_fallback). - Those rows are the first set.
solve2Dclassifies them again insolve2D/(start_solve2D,PHASE_SOLVE2D). The chunk model and the class-compatibility filter select from its class averages (finish_solve2D,quality_selection/first_set/), andmap2Dshifts23Dmakes its shifts the 3D start. A failedsolve2Dfalls back to the pool model's selection (fallback_first_set). - Later publications change only the first set's 2D parameters, not its selection
(
in_first_setinmerge_publication). - Imports pause from the first set until
solve3Dstarts (l_solve2D_dueiniterate). - The first
solve3D(start_solve3D) runs on every selected row and recordsnptcls_at_full. The final refine3D is skipped when the selection still has that many particles. - Addon runs: a result's active rows are the frozen particles. The cohort is the selected
rows that are not frozen (
count_cohort). An addon run starts once the cohort reaches max(5 ×nstates, 10 % of the frozen particles) (next_job). - Class-balanced draws already exist:
oris%get_class_sample_statslists each class's selected particles, best 2D score (corr) first.oris%sample4update_class, run greedily (l_greedy), takes each class's equal quota from the top. It also incrementsupdatecntand setssampledon what it draws.
2. SIMPLE¶
2.1 Retire the first set (simple_stream_stage_solve3D.f90)¶
- Remove:
- procedures:
take_first_set,merge_first_set,in_first_set,start_solve2D,finish_solve2D,fallback_first_set; - components:
first_set,first_fallback,l_solve2D_due; - constants:
PHASE_SOLVE2D,SOLVE2D_DIR,FIRST_SET_DIR,NPTCLS_PER_CLS2D,NCLS2D_MIN,NCLS2D_MAX,NSAMPLE2D,LPSTOP2D; - the
l_compatpath ofselect_with_model, with the imports only it uses (class_compatibility,CAVG_QUALITY_MODEL_CHUNK_DEFAULT). import_setstakes every publication the same way:select_cavgs,merge_publication, thentake_cavgs. The pool model's selection applies to the first publication too.iterateno longer pauses imports for a duesolve2D.advance_jobshas nosolve2Dbranch. Thesolve2Dcases go fromsend_statusandprune_run_dirs.merge_publicationhas no first-set exception: every row follows each publication's selection.- Restart is unchanged, except that the newest publication is taken as a normal one.
2.2 The cap¶
- The parameter
nptcls3D_max, following the parameter lifecycle (simple-main-params): - declared in
simple_parameters.f90as0("the stage's default"), registered withadd_intinsimple_parameters_parse.f90. The generated argument list follows fromsimple_parameters.f90; - given its default
NPTCLS3D_MAX = 100000in the p07 commander'sset_solve3D_cline, besideNPARTS3Dand the others, with the header comment updated; - checked in
init_params: a cap underMIN_PTCLS_PER_STATE×nstatesis refused; - added to
solve3D_stream's UI entry (simple_ui_stream.f90), developer visibility,preserve_default,{100000}. start_solve3D, when more particles are selected than the cap:- A new
draw_first_run(cap)picks the run's rows:- It works on a scratch copy of
os_ptcl2D, so the rows'updatecntandsampledstay unchanged. - It builds
get_class_sample_statsover the selected classes and calls greedysample4update_classwithupdate_frac = cap / nselected. - The draw may exceed the cap by one particle per class, so the lowest 2D scores are trimmed until the run has exactly the cap.
- It works on a scratch copy of
- The selected rows the draw leaves out are recorded in a new component,
queued(:)(logical per row). - They are deselected (state 0) in both
ptcl2Dandptcl3Dof the run's project only. solve3D's class sampling readsptcl2Dstates (make_class_sampleswithoutl_drop_inactive3D). The stage's rows keep their selection. nptcls_at_fullis set to -1, because the run does not align every selected particle. The final refine3D is then never skipped on the strength of this run.- The log line gives the selected, drawn and queued counts.
finish_run, for the firstsolve3D, follows this order:- It reads the result as now: the queued rows come back deselected.
- It records
frozen_activefrom the result, so the queued rows are not frozen. - It selects the queued rows again (state 1 in both segments, the label a selected row
without one gets) and releases
queued.
The queued rows are then cohort (count_cohort), so they join the first addon run. That
run starts by the usual rule: right away when there are enough of them, otherwise once
later publications add more.
4. 3D snapshots take the result project, so the queued particles, which have no 3D label
yet, are not in a snapshot taken before the first addon run.
3. Docs¶
stream_3D_ingestion_policy.md:- §1 scope: no
solve2D;draw_first_run. - §3 item 1: iteration 10 is published early so that 3D starts sooner, and the pool model scores its classes (decision 3).
- §4 item 3: the first publication is taken like the others, and is replaced by the cap.
- §4 item 5: the first-set exception goes, and so does "the first set's
solve2Dreplaces them" in thetake_cavgsbullet. - §4 item 6: the first run, the cap, the draw and the queue.
- §4 item 12: the folders kept, without
solve2D/andquality_selection/first_set/. restart_policy.md: the p07 row and "p07 runssolve2Dandsolve3Dagain".pool2D_policy.md: the iteration-10 publication is no longer "3D's first set".doc/policies/stream/README.md: the p07 row gainsnptcls3D_max.- Code comments that cite decisions 31 to 38, in the stage and the commander.
- The
simple-main-streamskill, with approval: p07's line, should it mention the cap.
4. Tests (unit_stream, "solve 3D")¶
- Remove
test_first_setandtest_first_set_fallback. - Add:
- the first publication into a stage without rows merges as it selects, without exceptions, and a later publication deselects one of its rows;
draw_first_runon a fixture with uneven classes and scores:- exactly the cap;
- an equal share per class, capped at a small class's population;
- best scores first;
updatecntandsampledunchanged;
finish_runon a fixture result with queued rows: they are not frozen, they are selected again, andcount_cohortcounts them;- a selection within the cap queues nothing;
- the cap check in
init_params. test_rules: unchanged;next_jobkeeps its signature.- The stream chain tester runs far below the cap and needs no change. Check that it doesn't
look for
solve2D/.
5. Order¶
- Section 2.1 and its tests. Behaviour: no
solve2D, an uncapped first run. - Section 2.2 with its tests, the parameter and its UI entry.
- The docs.
Status¶
Implemented, 7 October 2026: sections 2.1 and 2.2, their tests, and the docs of section 3
(the skill line included) except the README row. Nothing has been compiled or run yet. The plan moves to
completed/ once unit_stream passes and a stream has run its first solve3D and addon run.
Where the implementation differs from the plan:
- The cap is checked in the commander (set_solve3D_cline), beside the nstates check,
rather than in init_params. The stage exports MIN_PTCLS_PER_STATE for it. The stage itself
treats a cap below 1 as none, so a tester that builds a stage without the commander draws
nothing.
- The draw, the queue's states and its release are three steps (draw_first_run,
set_queued_states, release_queue), so the tester can run them without a 3D job.
start_solve3D deselects the queued rows, writes the job's project, and selects them again.
- doc/policies/stream/README.md is unchanged: its p07 row lists the stage's resources, and
the cap is not one.
Changed 12 and 13 October 2026 (re-checked against the code 14 October): later commits reversed
several decisions above, and stream_3D_ingestion_policy.md (sections 3, 4, 8 and 9) is now the
living description. What survives and what does not:
- Survives: the cap (nptcls3D_max, p07 only, registered in simple_parameters.f90,
simple_parameters_parse.f90 and simple_ui_stream.f90), the queue of particles the first
solve3D leaves out (queued, set_queued_states, release_queue), and the first addon run's
cohort.
- Default changed: the cap is 30,000 (NPTCLS3D_MAX in the p07 commander), not 100,000.
- Reversed: p07 again keeps a first set (in_first_set, take_first_publication) and, with
ini3D_cavgs=yes (the default), runs solve2D into 150 classes, the pool model's selection,
cls_expansion into about 500 classes and solve3D_cavgs before the first solve3D (commits
a47a1f04c, d9286a57a). "No solve2D" and "uncapped first run" no longer hold.
- Replaced: decision 2, the class-balanced draw. draw_first_run is gone; cap_first_run
takes whole stacks in row order (85afad3f5), and balance=none was removed, so p07's runs
take solve3D's default cavg.
- Replaced: decision 3. p06 publishes the sieve's 2D as the first set (at 100,000 accepted
particles, 500 micrographs, the sieve's final set, or pool iteration 10), and p07 takes it
without scoring by the pool model.
- Still to do before this note closes: unit_stream passing and a stream run through the first
solve3D and addon run. No passing run is recorded in the repository.