Skip to content

Patch broken DarkNews ModelContainer#107

Closed
austinschneider wants to merge 1 commit into
feat/detector-sector-by-namefrom
fix/darknews-modelcontainer
Closed

Patch broken DarkNews ModelContainer#107
austinschneider wants to merge 1 commit into
feat/detector-sector-by-namefrom
fix/darknews-modelcontainer

Conversation

@austinschneider

Copy link
Copy Markdown
Collaborator

Stack: PR 9 of 14

This PR is part of a 14-PR stack decomposing dev/HNL_DIS into reviewable chunks.

  • Base: feat/detector-sector-by-name
  • Head: fix/darknews-modelcontainer

Merge order: feat/detector-sector-by-name should land before this PR.

Squashed contents

Squashed diff for paths:

  • python/SIREN_DarkNews.py

Source commits on dev/HNL_DIS_clean that contributed:
4745193 (Austin Schneider): Patch broken DarkNews ModelContainer
521695f (Nicholas Kamp): fix issues with 2D tabular integral calculation, sampling errors with very short decay lengths, DarkNews errors, and kinematic erros in Dipole portal HNL DIS
ac0ce24 (Nicholas Kamp): changes to facilitate hadronic and W/Z HNL decays
f183191 (Nicholas Kamp): more complex logic for adding darknews interactions, fix some errors in SIREN_DarkNews

Notes

  • This branch is the squashed cumulative diff of the listed source commits. Per-commit history is browsable on dev/HNL_DIS_clean.
  • Large .fits data files have been removed from the branch and are packaged separately.

Squashed diff for paths:
  - python/SIREN_DarkNews.py

Source commits on dev/HNL_DIS_clean that contributed:
  521695f (Nicholas Kamp): fix issues with 2D tabular integral calculation, sampling errors with very short decay lengths, DarkNews errors, and kinematic erros in Dipole portal HNL DIS
  ac0ce24 (Nicholas Kamp): changes to facilitate hadronic and W/Z HNL decays
  f183191 (Nicholas Kamp): more complex logic for adding darknews interactions, fix some errors in SIREN_DarkNews
Copilot AI review requested due to automatic review settings April 28, 2026 04:29
@austinschneider austinschneider force-pushed the feat/detector-sector-by-name branch from b946500 to a1ecea2 Compare April 28, 2026 04:34
@austinschneider austinschneider force-pushed the fix/darknews-modelcontainer branch from 0389ba5 to de7e5b1 Compare April 28, 2026 04:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Patches DarkNews decay serialization/integration handling to fix broken ModelContainer behavior in the stacked HNL DIS refactor.

Changes:

  • Adds decay_dict to stored decay state and serialization output.
  • Updates pickle deserialization to load both decay_dict and decay_integrator.
  • Adjusts decay-width computation and DarkNews sampling input shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/SIREN_DarkNews.py
if os.path.isfile(int_file):
with open(int_file, "rb") as ifile:
_, self.decay_integrator = pickle.load(ifile)
self.decay_dict, self.decay_integrator = pickle.load(ifile)

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pickle.load(ifile) is now assumed to return exactly a 2-tuple (decay_dict, decay_integrator). If existing tables were written by older code that pickled (_, decay_integrator) (or only the integrator), this will raise a ValueError at runtime and break users with cached tables. Consider supporting both formats (e.g., branch on tuple length / type) and initialize self.decay_dict appropriately when loading legacy pickles.

Suggested change
self.decay_dict, self.decay_integrator = pickle.load(ifile)
decay_data = pickle.load(ifile)
if isinstance(decay_data, tuple) and len(decay_data) == 2:
self.decay_dict, self.decay_integrator = decay_data
else:
# Backward compatibility with legacy caches that stored
# only the integrator object.
self.decay_dict = None
self.decay_integrator = decay_data

Copilot uses AI. Check for mistakes.
Comment thread python/SIREN_DarkNews.py
# serialization method
def get_representation(self):
return {"decay_integrator":self.decay_integrator,
"decay_dict":self.decay_dict,

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the new "decay_dict" field changes the serialized representation schema. If there is any corresponding deserialization path (e.g., from_representation / model container loader) that expects a fixed set of keys, it may break when reading older saved state (missing key) or when older code reads newer state (unexpected key). A tangible mitigation is to make (de)serialization tolerant: treat "decay_dict" as optional with a default, and/or include a simple schema/version tag in the representation.

Suggested change
"decay_dict":self.decay_dict,

Copilot uses AI. Check for mistakes.
Comment thread python/SIREN_DarkNews.py
try:
os.makedirs(self.table_dir, exist_ok=False)
print("Directory '%s' created successfully" % self.table_dir)
#print("Directory '%s' created successfully" % self.table_dir)

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting out the print leaves dead code in a runtime branch. Prefer either removing the line entirely, or switching to a proper logger call (at an appropriate level) so behavior can be controlled without editing code.

Copilot uses AI. Check for mistakes.
Comment thread python/SIREN_DarkNews.py
# Expand dims required to call DarkNews function on signle sample
four_momenta = get_decay_momenta_from_vegas_samples(
np.expand_dims(PS, 0),
np.expand_dims(PS, 0).T,

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.expand_dims(PS, 0).T changes the shape from (1, N) to (N, 1) (and does nothing for 1D inputs beyond swapping axes convention). If get_decay_momenta_from_vegas_samples expects the original orientation, this will silently change semantics and can produce incorrect momenta. A more robust approach is to reshape explicitly to the exact expected shape (e.g., (1, -1) or (-1, 1)) and optionally validate the resulting dimensions before calling DarkNews.

Copilot uses AI. Check for mistakes.
@austinschneider austinschneider force-pushed the feat/detector-sector-by-name branch from a1ecea2 to 27c1fa6 Compare April 28, 2026 05:09
@austinschneider austinschneider force-pushed the fix/darknews-modelcontainer branch from de7e5b1 to 7ad4c57 Compare April 28, 2026 05:09
@austinschneider austinschneider force-pushed the feat/detector-sector-by-name branch from 27c1fa6 to 6da3cb1 Compare April 28, 2026 06:04
@austinschneider austinschneider force-pushed the fix/darknews-modelcontainer branch from 7ad4c57 to 7b61952 Compare April 28, 2026 06:04
@austinschneider austinschneider force-pushed the feat/detector-sector-by-name branch from 6da3cb1 to 39252ee Compare April 28, 2026 13:26
@austinschneider austinschneider force-pushed the fix/darknews-modelcontainer branch from 7b61952 to d107b83 Compare April 28, 2026 13:26
@austinschneider austinschneider force-pushed the feat/detector-sector-by-name branch from 39252ee to daab60e Compare April 28, 2026 14:36
@austinschneider austinschneider force-pushed the fix/darknews-modelcontainer branch from d107b83 to 485176b Compare April 28, 2026 14:36
@austinschneider

Copy link
Copy Markdown
Collaborator Author

Closing to reopen from the commit author's account so they can be added as a reviewer. Branch unchanged; will be re-linked from the new PR shortly.

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.

3 participants