Skip to content

0.40.0

Latest

Choose a tag to compare

@github-actions github-actions released this 24 Nov 23:01
· 1 commit to develop since this release
ac0f1f4

Release notes for sbmlsim 0.40.0

sbmlsim

One evaluation of a fit now uses the whole machine, and the rest of the release is the follow-ups of the last two days: every one of them a place where the code was quieter than it should have been - a formula the parser could not read was folded instead of refused, two walkers of the same plan agreed by hand, a stored set of parameters kept numbers which never took effect without saying so, and the comparison of the objective of the engine ran in a corner of the space it guards.

One evaluation of a fit is one batch of the engine

One evaluation of the objective is one simulation per group of fit mappings, and the groups do not depend on each other: they are exactly the batch _simulate_batch already builds for the vectors of a jacobian. The single vector path did not use it and called execute_plan once per group, so a whole evaluation ran on the thread of its caller however many CPUs the machine had - and an optimizer which spends its time in single evaluations, a profile point, a polishing step, a report, left every other core idle.

_batched_evaluation is a context manager around the group loop of residuals: it builds the batch of the one vector and sets it as self._batch, which _execute already reads before it simulates, so the groups go to execute_plans and sbmlsim-core runs them on its threads. An evaluation which is already part of a batch, a vector of a jacobian or a member of a population, keeps that batch and builds no second one. The curve of a group of the complete data is a plan of its own and is the point _CURVE of its group, which keeps it apart from the data times plan of the same group where the two read the same columns.

_threads_of_an_evaluation gives the batch the CPUs of the process, and one thread for a single group or inside a worker of a pool: the processes of a JacobianPool or a PopulationPool already use the CPUs of the machine, and a worker which took them for its threads would oversubscribe them. With one thread the evaluation builds no batch and runs exactly as before. The CPUs of the process are read once per problem and kept: they come from /proc and the cpu.max chain of the cgroup, they do not change while a problem is evaluated, and an evaluation is the hot loop of a fit.

On the HCTZ PK problem of pkdb_models, 49 groups and 160 mappings on the engine core over 20 CPUs, ten evaluations of residuals at the model values:

wall cpu cpu/wall
before, n_workers 1 102.4 ms 102.5 ms 1.00
before, n_workers 12 102.0 ms 102.1 ms 1.00
after, n_workers 1 62.9 ms 190.4 ms 3.03
after, n_workers 12 59.9 ms 178.7 ms 2.98

The residuals of a batched evaluation are the serial ones bitwise; what is left serial is the python around the simulations, the plans, the interpolation and the residuals themselves.

Four cases of the PEtab suite return to the engine

linear_form is the one place which tells a linear form, constant + Σ factor * symbol, from any other formula, and it parsed the formula as it is written. The math of PEtab has identifiers, and two selections of roadrunner are none: the concentration of a species, [S], whose brackets the parser does not read at all, and the dotted name of an observable, pk.cmax. compile_formula has escaped both since it was written; linear_form did not, so [A] + 5 raised out of the parser and every caller took that for a formula which is no form and folded it into the number of the point the request was built at - and because a request writes its formulas as forms all or nothing per plan, one such formula folded every formula of its plan.

The escaping is shared now, so a formula either of them reads is the same formula, and a formula without a bracket or a dot escapes to itself: nothing which was a form before changes in text, symbols, order of its terms or coefficients.

The four cases of the PEtab v2 test suite which set a concentration at a change by a formula which reads one, C + [S] (0016, 0031) and [A] + 5 (0028, 0030), are fits of the engine again, of least squares and of the likelihood, with residuals bitwise the ones the problem computes: 30 of the 31 cases are a fit of the engine, up from 26. The one which is not has parameters with a prior and no bounds.

A model whose change formula reads a concentration gets forms where it got folded numbers, for its whole plan. At a single simulation the two are the same request evaluated at the same state, bitwise; away from the point the request was built at the form is the one which follows the search, which is what a form is for. Two openings of the same kind are left, a term of the time and a change over the target of a fitted parameter, see #650.

A stored parameter set says which of its values were applied

A parameter set keeps every value it carries, and a value the problem neither fits nor uses in its noise models changes nothing: the model keeps its own. 0.39.0 named those values in the log, which reaches whoever ran the command. The set did not, and the set is what is written into the report's parameters.json, the record of an adopted fit and the credibility.json of an assessment, so a later reader of that evidence saw a number next to a predictive check, a Fisher information or a profile with no way to tell that nothing was simulated with it.

ParameterSet.unapplied is the mark, written by OptimizationProblem.bind_parameter_set, the one place which knows both sides; to_units carries it, to_dict writes it and from_dict reads it back, ParameterSet.applied is the values without it and __str__ stars one. A set whose every value took effect carries none and writes no key, so the parameters.json of such a fit is the file of 0.39.0 byte for byte and an older file reads back with an empty mark. The parameters table of a report is the parameters of the problem, so such a value has no row there at all; the report says underneath which values the set carries that the fit does not apply.

One enumeration of the places of a plan

sbmlsim.fit.fit_core decides whether a fit runs in the engine by walking the places of a plan which carry a value, and it walked them twice, in two functions which must agree and which nothing compared: the places the engine would hold a plain number at, and the places which carry a formula. A place a later change gives Plan and teaches only one of them about makes the other go quiet rather than fail, and the fit runs in the engine with a value frozen where it started - an objective which is wrong without saying so, and a fit whose objective is quietly wrong still converges and still reports a fitted parameter.

Plan.places is the one enumeration now, a Place of its path, of where it is in the words of a message and of its assignments. Plan.assigned reads it and so do both walkers, one as every place but the pre-initialization of the plan itself, the other as all of them. A new place reaches all three at once and gets the conservative answer, a gap, until it is given a rule of its own.

Plan.steady_state_output was the field neither walker knew about. It is a SteadyStatePlan and therefore has a pre-initialization, nothing builds it with one, and no executor applies one: the steady state after the end continues from the state the timecourse ended in, for roadrunner, COPASI, AMICI and the steady_state_after of a request alike, so a value there would have been dropped by every engine without a word. Plan.__post_init__ refuses one.

The test derives every attribute path which can hold an assignment from the annotations of Plan and of the dataclasses it holds, not from a second hand-written list, so a new field which carries assignments and is not enumerated fails the suite.

The objective of the engine is compared where it is used

Every comparison of a posterior of the engine with python built its problem on the linear parameter scale, while LOG10 is the default of the package and is the space a fit searches in: the prior rows, the cost and the prior columns of the jacobian all pass through the conversion of the scale, and none of it was exercised by a test which runs by default. Both comparisons run on both scales now. The position of a prior was 0 in every test, so an off-by-one in the indexing on either side would have answered the same numbers for every case the suite holds; a fit of three parameters carries a prior on the second and the third now.

Nothing of the package changes there: both agree today and both were measured by hand when the objective was moved into the engine. The tolerance of the difference quotient of the engine is a measured constant per scale instead of one pair of numbers.