Skip to content

fit ops qol#140

Merged
davidwalter2 merged 6 commits into
WMass:mainfrom
lucalavezzo:split/fit-ops-qol
Jun 22, 2026
Merged

fit ops qol#140
davidwalter2 merged 6 commits into
WMass:mainfrom
lucalavezzo:split/fit-ops-qol

Conversation

@lucalavezzo

@lucalavezzo lucalavezzo commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator
  • pass some minimizer options via CLI --minimizerMaxiter, --minimizerGtol, --minimizerFtol
  • timing output in debug mode
  • --externalPostfit covariance handling: when the external fitresult has no covariance (e.g. produced with --noHessian), recompute the Hessian at the loaded postfit point — enabling the two-pass recipe (fit with --noHessian, then --externalPostfit … --noFit to get the covariance)

lucalavezzo and others added 4 commits June 11, 2026 17:50
New CLI controls --minimizerMaxiter / --minimizerGtol / --minimizerFtol
forwarded to scipy.optimize.minimize as options={...}; unset values keep
the historical tol=0.0 behavior.

Timing instrumentation at debug verbosity: per-iteration dt/elapsed in
FitterCallback and [timing] lines around minimize(), _profile_beta(),
and the Hessian-free EDM/CG postfit step.

Two --externalPostfit fixes: (1) an Asimov dataset (-t -1) now loads
the external postfit values before computing the expected yield, so the
Asimov is generated at the postfit point rather than silently at
prefit; (2) the postfit covariance is recomputed at the loaded postfit
point when a Hessian is wanted (no --noHessian), enabling the two-pass
covariance recipe with --externalPostfit --noFit. The --noEDM help text
is updated to describe what is actually skipped.

rabbit_print_pulls_and_constraints.py gains --noPrefit to suppress the
prefit pull/constraint columns; the header separator now matches the
actual header width.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Per review on WMass#133: drop the unnecessary try/except and the
incorrect L-BFGS label (the callback counts iterations of whichever
minimizer method is in use).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Per review on WMass#133 ('or not args.noHessian' should be
removed): with --externalPostfit --noFit the covariance is taken from
the loaded fitresult again, as before. The recompute also failed with a
non-positive-definite Hessian on the test tensor's Asimov workflow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reconciles the review discussion on WMass#133 (rabbit_fit.py:603):
when --externalPostfit provides a covariance it is used as before; when
it does not (the fitresult was produced with --noHessian), the Hessian
is recomputed at the loaded postfit point instead of silently writing no
covariance. This enables the two-pass recipe for models whose full
Hessian is infeasible during the fit: pass 1 fits with --noHessian,
pass 2 reruns with --externalPostfit ... --noFit (without --noHessian)
to obtain the covariance. Verified on the test tensor that the two-pass
covariance is identical to the single-pass one, and that a fitresult
with a covariance is still consumed without recomputation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
parms_variances now defaults to a NaN-filled vector instead of None, so
the parms hist is always written with Weight storage and entries whose
uncertainty was not computed (e.g. --noHessian with --noEDM) read NaN
from .variances() downstream, instead of a silently absent or
plausible-looking value.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@davidwalter2

Copy link
Copy Markdown
Collaborator

I still don't agree that the asimov should be done with the --externalPostfit IMO it is more intuitive to expect that the asimov is done from the nominal model before the --externalPostfit is loaded and only the postfit is made with it. What was your thought about this?

Build the Asimov dataset at the prefit point regardless of
--externalPostfit, as before. The change had made `-t -1
--externalPostfit X` generate the Asimov at the loaded postfit
point, but that breaks the intended use cases:

- Two-pass covariance recipe (minimize, then Hessian via
  --externalPostfit ... --noFit): step 2 must rebuild the same
  likelihood step 1 minimized. A one-step Asimov fit holds nobs
  fixed at the prefit expectation while the parameters minimize,
  so a faithful split must use the prefit Asimov in step 2.
  Regenerating it at the postfit point yields a different
  likelihood whose minimum is no longer the loaded point (EDM != 0
  once regularization/priors move the postfit off prefit), giving
  the wrong covariance.
- Blinding operates on the real-data fit (-t 0); Asimov fits are
  never blinded, so this path is irrelevant there.

--externalPostfit still loads the postfit for the postfit step via
the in-fit() load. A genuine postfit-Asimov (expected sensitivity
at the data-driven point) is a separate use case that should be an
explicit opt-in flag, not silent default behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lucalavezzo

Copy link
Copy Markdown
Collaborator Author

Thanks @davidwalter2. The idea originally was to be able to get the expected sensitivity at the data-driven point. I don't think this is currently supported. For now, I've reverted, as indeed for a full Asimov fit, you are correct (i.e. one must use the prefit Asimov even with --externalPrefit is used).

@davidwalter2 davidwalter2 merged commit 040a7bd into WMass:main Jun 22, 2026
23 checks passed
lucalavezzo added a commit to lucalavezzo/rabbit that referenced this pull request Jun 23, 2026
Integrates the merged sibling PRs into the priors/unification branch:
  WMass#140 fit-ops (minimizer flags, externalPostfit), WMass#142 scalePoiScan,
  WMass#143 CompositeParamModel layout fix, WMass#144 blinding groups.

Conflicts (both trivial):
  - fitter.py: blinding_group=options.blindingGroup (main's direct form;
    the SimpleNamespace test fixtures already carry blindingGroup=[]).
  - helpers.py: kept main's cleaned-up version (dropped the explanatory
    comment removed on main).
Also dropped tests/test_composite_param_model.py, which the merge
re-introduced from this branch but was deliberately removed on main.

Validated: lint clean; pytest (15) + the five CI script-tests pass; the
ParamModel-prior closure is unchanged (gaussian sig_prior 1.105769e-02,
asym (-1.097e-2,+1.114e-2)); parsing.py is identical to main so all of
WMass#140/WMass#142/WMass#144's CLAs are present.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants