Skip to content

Let param models take initial parameters from the input file - #148

Merged
lucalavezzo merged 1 commit into
WMass:mainfrom
davidwalter2:260810_abcdInitialParams
Aug 12, 2026
Merged

Let param models take initial parameters from the input file#148
lucalavezzo merged 1 commit into
WMass:mainfrom
davidwalter2:260810_abcdInitialParams

Conversation

@davidwalter2

Copy link
Copy Markdown
Collaborator

Motivation

The smooth (extended) ABCD models can start the fit from pre-computed polynomial coefficients, but so far only via a standalone file passed on the command line (params:file.hdf5). That file has to be kept in sync with the datacard by hand — if the templates are regenerated with a different binning or a different input, nothing notices.

This lets the tool that writes the datacard ship the starting values instead, in an auxiliary bundle of the input file itself, where they cannot drift away from the templates they were derived from.

Changes

rabbit/auxiliary.py

  • initial_params_name(model, process, channel) fixes the bundle naming convention: initial_params_<model>_<process>_<channel>.
  • read_initial_params(indata, name) decodes a bundle into (params, order).

rabbit/param_models/smooth_extended_abcd_model.py

  • The params: token parsing is factored into resolve_params_token(token, indata), which gains an aux:<name> spec alongside the existing .hdf5/np.load paths.

rabbit/param_models/abcd_isomtmt_model.py

  • SmoothExtendedABCDIsoMT resolves its starting values in this precedence:
tokens source
params:aux:<name> that bundle
params:<file.hdf5> standalone file (unchanged)
order:N zeros at order N — automatic pickup deliberately disabled
(none) initial_params_SmoothExtendedABCDIsoMT_<process>_<channel> if present, else zeros

So a datacard that carries the bundle needs no extra CLI token at all.

The generic SmoothExtendedABCD gets params:aux:<name> but no automatic lookup — its six region dicts do not give an unambiguous (process, channel) pair to build a default name from.

Notes

  • Fully backwards compatible: params:<file.hdf5> and order:N behave as before, and a datacard without the bundle starts from zero as before.
  • Incidental fix: the IsoMT wrapper previously took order from the file as a bare ndarray rather than an int.

Testing

New tests/test_param_model_initial_params.py covers all four resolution paths, plus an unknown bundle name raising. Full suite: 21 passed.

Exercised end to end from WRemnants (setupRabbit.py writing the bundle, rabbit_fit.py consuming it with no params: token): the model logs Using initial parameters from auxiliary bundle 'initial_params_SmoothExtendedABCDIsoMT_Fake_ch0' of the input file (order 3), the starting values match the standalone file bit-for-bit, and the fit converges (edmval 2.6e-13).

🤖 Generated with Claude Code

https://claude.ai/code/session_01N4WA7YjkNDZCubSrjaUWjd

The smooth (extended) ABCD models could only start the fit from pre-computed
polynomial coefficients via a standalone file passed on the command line, which
has to be kept in sync with the datacard by hand. Let the tool that writes the
datacard ship them instead, in an auxiliary bundle of the input file itself.

- auxiliary: add 'initial_params_name' fixing the bundle naming convention
  (initial_params_<model>_<process>_<channel>) and 'read_initial_params' to
  decode a bundle into (params, order)
- smooth_extended_abcd_model: factor the 'params:' token parsing into
  'resolve_params_token' and add the 'aux:<name>' spec next to the file paths
- SmoothExtendedABCDIsoMT: with neither 'params:' nor 'order:' given, look up
  the canonical bundle name and use it if the input file carries one, so no
  extra CLI token is needed. An explicit 'order:N' keeps starting from zero.
- add tests for all four resolution paths

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4WA7YjkNDZCubSrjaUWjd
davidwalter2 added a commit to davidwalter2/WRemnants that referenced this pull request Aug 10, 2026
Getting the initial parameters for the SmoothExtendedABCDIsoMT param model
required running regen_smoothing_params.py separately and passing the resulting
file to rabbit_fit.py via 'params:PATH'. That file has to be kept in sync with
the templates by hand.

Compute the same coefficients while setting up the fit and store them as an
auxiliary bundle in the output file, where rabbit picks them up by itself, so
the fit command needs no 'params:' token at all.

- rabbit_helpers: add 'compute_smoothing_params', the computation previously
  inline in regen_smoothing_params.py, which now calls it and writes the same
  standalone file as before
- setupRabbit: build the extended ABCD fake selector for the fake group, derive
  the coefficients and add them as auxiliary data under the name rabbit looks
  for. Only when the ABCD relation is actually solved in the fit
  (--fakeEstimation none with mt and relIso fit axes), disable with
  --noSmoothingParams
- bump rabbit to the branch adding the auxiliary lookup (WMass/rabbit#148)

regen_smoothing_params.py is kept for deriving the starting values from a
different input file than the one that is fit.

Verified that the stored parameters are bit-identical to the ones from
regen_smoothing_params.py, and that a fit reading them from the input file
converges (edmval 2.6e-13).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4WA7YjkNDZCubSrjaUWjd
@lucalavezzo
lucalavezzo merged commit 4fe971b into WMass:main Aug 12, 2026
23 checks passed
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