Skip to content

Move vpackets to the spectrum solver - #3799

Merged
andrewfullard merged 22 commits into
tardis-sn:masterfrom
andrewfullard:vpackets-spectrum-solver
Nov 4, 2026
Merged

andrewfullard merged 22 commits into
tardis-sn:masterfrom
andrewfullard:vpackets-spectrum-solver

Conversation

@andrewfullard

@andrewfullard andrewfullard commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

📝 Description

Type: 🎢 infrastructure

Moves the vpacket calculations to the spectrum solver. This reverts some of the memory-safe options because we can no longer free the rpacket trackers if vpackets are requested.

Needs tardis-sn/tardis-regression-data#131

🚦 Testing

How did you test these changes?

  • Testing pipeline
  • Other method (describe)
  • My changes can't be tested (explain why)

☑️ Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@tardis-bot

tardis-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

*beep* *bop*

Hi, human.

I'm the @tardis-bot and I noticed that your email is not associated with an ORCID ID in our database.

Please add your email and ORCID ID to the .orcid.csv file in your current branch and push the changes to this pull request.

If you don't have an ORCID ID yet, you can create one for free at orcid.org. ORCID IDs help ensure you get proper credit for your scientific contributions.

The format should be:

email,orcid
your.email@example.com,0000-0000-0000-0000

Runs: ORCID check · comment publisher

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.39655% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.94%. Comparing base (33bcd81) to head (d65af11).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
tardis/spectrum/virtual_packet.py 29.41% 48 Missing ⚠️
tardis/spectrum/base.py 86.66% 8 Missing ⚠️
...t/montecarlo/packets/trackers/tracker_full_util.py 82.35% 6 Missing ⚠️
...transport/montecarlo/modes/nonhomologous/solver.py 55.55% 4 Missing ⚠️
tardis/transport/montecarlo/configuration/base.py 57.14% 3 Missing ⚠️
tardis/visualization/plot_util.py 80.00% 1 Missing ⚠️
tardis/visualization/tools/sdec_plot.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3799      +/-   ##
==========================================
+ Coverage   70.51%   70.94%   +0.43%     
==========================================
  Files         207      207              
  Lines       16064    15845     -219     
==========================================
- Hits        11328    11242      -86     
+ Misses       4736     4603     -133     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrewfullard
andrewfullard marked this pull request as ready for review October 27, 2026 16:56
@tardis-bot

tardis-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

The docs workflow has completed with these results:

  • Build: success

View the documentation preview.

Runs: build and test · publish

Comment thread tardis/simulation/base.py Resolved
Comment thread tardis/spectrum/base.py Resolved
Comment thread tardis/spectrum/base.py Resolved
Comment thread tardis/spectrum/virtual_packet.py Outdated
numba.typed.List
Per-packet virtual packet collections.
"""
vpacket_collections = TypedList()

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.

Can you just make a list of the appropriate size of size no_of_packets? The programmer in me still hates appending to lists where it can be avoided. A quick search came up with this.
https://stackoverflow.com/questions/60186698/create-a-numba-typed-list-without-looping-over-a-python-list

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made it somewhat more readable with a comprehension.

Comment thread tardis/spectrum/virtual_packet.py Resolved
Comment thread tardis/spectrum/virtual_packet.py Resolved
Comment thread tardis/spectrum/virtual_packet.py Resolved
Comment thread tardis/simulation/base.py Outdated
self.iterate(
self.last_no_of_packets, self.no_of_virtual_packets
self.last_no_of_packets,
retain_full_trackers=self.no_of_virtual_packets > 0,

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.

One more question about this. Would we ever want to retain the full tracker without ever intending a virtual packet spectrum? My intuition says yes for diagnosing packet histories for optically thick stuff, especially with the IIP workflow which force virtual packets off.

So I would think the behavior should be - you request the full packet tracker to persist as the user facing flag, and later on if you try to make a virtual packet spectrum but didn't keep the full tracker, you just raise an error and say you need the full tracker at that point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right now, the behaviour is that if you request the full packet tracker OR more than zero virtual packets, you get a tracker out that can be used for virtual packets. The full packet tracker switch works for all workflows. If you try to make a spectrum without a tracker, yep you get an error solve_virtual_packet_spectrum raises ValueError if it's called without retained trackers.

Comment thread tardis/simulation/base.py Outdated
self.transport.rpacket_tracker,
self.no_of_virtual_packets,
)
# Memory: the histories are not needed once the spectrum is solved

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.

Mentioned above, but is this true? Maybe you would want to investigate what packets that interact multiple times are doing. That doesn't seem outlandish to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah. In this case, it's a step too far to just empty out the tracker.

jvshields
jvshields previously approved these changes Oct 27, 2026
jvshields
jvshields previously approved these changes Oct 27, 2026
Comment thread tardis/spectrum/base.py Resolved
Comment thread tardis/spectrum/base.py Resolved
Comment thread tardis/spectrum/virtual_packet.py Resolved
Comment thread tardis/visualization/sdec/util.py Outdated

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.

Hard to track - is this code moved somewhere else? If it's gone why don't we need it anymore? It's not obviously vpacket specific.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not technically relevant to this PR, but the file is not referenced anywhere.

@connor-mcclellan

Copy link
Copy Markdown
Contributor

Approved pending regression data checks passing - waiting for the cache to update now

@andrewfullard
andrewfullard enabled auto-merge (squash) November 4, 2026 19:56
@andrewfullard
andrewfullard merged commit db480c5 into tardis-sn:master Nov 4, 2026
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants