Skip to content

steady_state: ask a waiting "residual" march's inputs where it stalls (#2074) - #2149

Merged
wshlavacek merged 3 commits into
mainfrom
fix/2074-residual-inputs-ask-schedule
Dec 4, 2026
Merged

wshlavacek merged 3 commits into
mainfrom
fix/2074-residual-inputs-ask-schedule

Conversation

@wshlavacek

@wshlavacek wshlavacek commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #2074: the second gap (the ask at a stall). The ask schedule is deliberately unchanged, and the issue's ring-down at damping 0.02 stays unconverged. The reasons are below, so this does not close the issue.

Change

SteadyStateMarcher::march (src/steady_state.cpp). A "residual" march that waits for masked inputs asks them by a Newton step only at the 1st, 2nd, 4th, ... step at which the kept species pass and the inputs do not, and at the stop time. A march called stalled, or ended by an integrator failure, between two such asks came back unconverged wherever it stopped. The march now records whether the inputs were asked at its last step (inputs_asked, reset where the roots-dropped branch moves the state). When it ends unconverged and unasked with the kept species under tol, it is asked there by ss_inputs_let_a_stop, the same test the loop makes. This mirrors the default criterion's if (by_distance_ && !asked) (#1001). The two never both apply: waits_for_inputs_ is for criteria other than "scaled", and by_distance_ only for "scaled". A run that is taken on marches with tol = 0, so the new ask never fires there. The first commit's message says "or out of steps"; that case cannot happen.

Test: test_a_march_that_waits_for_inputs_is_asked_where_it_stalls uses a model built to hit this case. Masked I sits 1e-10 (relative) off rest, with its rate (1e-8) over tol and not falling. Kept X reads I and creeps to X* from 1e-6 (relative) away. A masked ring that nothing reads sets the step size. The Newton step passes from the 1,385th kept-pass step, and the march stalls at the 2,005th, between the asks at 1,024 and 2,048. On main it is unconverged with X 2e-9 (relative) from X*; here it is converged. The assertion 1_024 < n_steps < 2_048 rules out a pass by an ask inside the loop.

Why the schedule is not changed

I measured the issue's three options on its reproduction and on the realistic models from #2040's Cost section.

  • Asking at every step converges the ring-down only by luck. I asked at every step of the a=0.02 march without stopping on a pass. Exactly 1 of the 8,762 steps at which the kept species pass passes: step 5,714. The march's accuracy floor (U, V about 4e-7 from rest) is above what the Newton test asks (about 1e-8). Units are not the cause: in units of 1, 1e6, 1e9 and 1e14 the march is unconverged at the same step count, as is "residual" with no mask. Beside 100, 250 or 500 species at rest that nothing reads, asking at every step does not converge either.

  • Cost of asking at every step. One ask (dense Jacobian plus LU) on the ring-down beside N species at rest:

    unknowns per ask doubling (now) every step
    3 ~2 µs 0.14 s 0.14 s, converged
    100 0.17 ms 0.06 s 1.5 s, unconverged
    250 2.3 ms 0.21 s 19.7 s, unconverged
    500 ~20 ms 0.73 s 260 s, unconverged

    At a=0.001 with 250 species: 1.05 s against 145 s.

  • Asking at every step once the inputs' residual stops falling asks 2,426 times on the reproduction and is still unconverged. The one passing step is a new least of the inputs' residual, so this option never asks there.

  • Realistic models. BIOMD0000000685 (keeping A_star, and keeping A at max_time 1e5), BIOMD0000000407 (first species left out), ige_receptor_cycle (Lyn left out, max_time 3e3, 1e4 and the default), BIOMD0000000252 (keeping mm, 1e5) and hawse_reduced_boolean (keeping the 16th species, and leaving out the first): the same verdicts and step counts under all three schedules.

Getting the ring-down to converge under "residual" would take something other than the schedule, such as a Newton polish at the stall. It fails the same way with no mask.

Also in this PR

test_cli_deadline.py::test_a_sharded_compile_leaves_no_compiler_and_no_debris[unsupervised] failed once in the local pre-push run. Under load, writing the 6,000-species model's code used up the whole 6 s deadline before any compiler started, so cc.pids did not exist. It passed 3 of 3 runs on its own. The deadline is now 15 s; the stand-in compiler sleeps 120 s, so the stop still lands mid-compile.

Checked

  • Pre-push suite on the first commit: 27,368 passed, 1 failed (the deadline test above), 96 skipped, 1:24:26.
  • The later commits (comments, changelog, the two deadline constants) were pushed with --no-verify after running all test_steady_state*.py files and test_cli_deadline.py against a rebuilt core: 1,247 passed, 10 skipped.
  • Main against this branch on the new test's model: unconverged at 2,005 steps, then converged at 2,005 steps.

Reviews

  • Independent review (Fable 5.2): no correctness issues. It traced every way the march ends (stall, step budget, stop time, root restart, integrator failure, the roots-dropped restore) and found the flag current on each. It confirmed the predicate matches the test inside the loop, and that a converged end skips the difference-quotient retry just as for the default criterion's end ask. Fixed: the wording of the comment, changelog and test comment. Left alone, both low severity:
    • The ladder's burst can now come back converged where it stalled between asks, which sends it on to the Newton polish. This is the same outcome an ask inside the loop would have given.
    • The test's margin is about 30% either way in mean step size, so a platform with a different step size is where it could fail.
  • /code-review (high): nothing blocking. Fixed: the sibling deadline test, test_a_slow_compile_is_stopped_and_the_next_command_compiles, which reads cc.pids after a 6 s deadline in the same way, now gets 15 s as well (test_cli_deadline.py: 155 passed). Left alone:
    • The ladder change noted above.
    • The stall test's platform margin; CI on the other platforms will show it.
    • A 15 s deadline is still a fixed-time race, only with more room.
    • No test for an end ask after an integrator failure, because I have no model that fails between two asks. A converged result there skips the difference-quotient retry, as it does for the default criterion's end ask.

…#2074)

A march under criterion="residual" that waits for masked inputs asks them
by a Newton step only at doubling counts of the steps the kept species
pass. One ended as stalled, by an integrator failure, or out of steps
between two asks was not asked where it stopped, unlike the default
criterion's march (#1001). It is now.

The ask schedule is unchanged: asking at every step costs one dense
factorization a step (260 s for 0.73 s at 500 unknowns) and converges
the issue's ring-down only at the one step of 8,762 that passes.

Refs #2074
Wording of the stall-ask comment, the changelog and the new test's comment
(the steps counted are those at which the kept species pass and the inputs
do not; the offsets are relative). The march's end ask cannot fire on a
run that is taken on, which marches with tol = 0, so "out of steps" in the
previous commit's message describes nothing reachable.

test_a_sharded_compile_leaves_no_compiler_and_no_debris[unsupervised]
failed in a loaded pre-push run: writing the 6,000 species' code took the
whole 6 s deadline, so no compiler had started and cc.pids did not exist.
15 s still stops it mid-compile (the stand-in compiler sleeps 120 s).

Refs #2074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant