Skip to content

Rotations and Couplings#104

Merged
denehoffman merged 31 commits intomainfrom
development
Apr 19, 2026
Merged

Rotations and Couplings#104
denehoffman merged 31 commits intomainfrom
development

Conversation

@denehoffman
Copy link
Copy Markdown
Owner

@denehoffman denehoffman commented Apr 19, 2026

Some pretty big changes here, a lot of QoL but also some new amplitudes (and some major changes to existing ones).

  • Add semantic keys to amplitudes
    • This allows users to instantiate two amplitudes in an identical way and have them count as the same amplitude, when previously an error would be thrown unless you reused the same object.
  • Add some new expression-related functions (powi, powf, pow (for general complex powers), cis (complex phases from an angle), sqrt, exp, sin, cos, and log (natural).
    • Note: no compilation optimization implemented on these functions yet
  • Added a VariableScalar amplitude that can turn any Variable into an amplitude that returns its cached value, plus a helper method on variables to turn them into one (currently added as an extension trait, I might change this later).
  • Replaced Piecewise amplitudes with more generic lookup table amplitudes (these can use parameters as bin values, replicating piecewise amplitudes, but they can also use constants to be a pure lookup table. Also supports linear interpolation!).
  • Updated BreitWigner amplitude to have a non-relativistic version as well as a version without Blatt-Weisskopf barrier factors. I also changed the convention to use a unit numerator.
  • In this vein, I rewrote the mechanics behind a lot of the helper functions, extended barrier factors to L=8, and added a bit more control over the operation of the important functions.
  • Added a Voigt amplitude
  • Added helper functions for calculating Wigner D-Matrix elements, Clebsch-Gordan coefficients, and Wigner 3-j symbols
  • Added amplitudes which expose these helper functions.
  • Overhauled variables by removing Topology and replacing it with Reactions. Now the user should fully specify the reaction in terms of all the particles, and angles/boosts etc. can be directly calculated given this schema. Reactions also have built-in expression generators for helicity/canonical amplitude terms.
  • Added an (un)polarized photon SDME amplitude
  • Added methods to visualize the compiled form of expressions
  • Use enums to specify Kopf K-Matrix channels rather than ambiguous integer values

…ants of Breit-Wigner amplitude and change normalization in numerator to unity

BREAKING CHANGE: the normalization of standard relativistic Breit-Wigner amplitude is now unity.
…ting 3j symbols, Clebsch-Gordan coefficients, and Wigner d/D matrix elements
…ty objects with str/repr and make them use the current active mask when applicable
@denehoffman
Copy link
Copy Markdown
Owner Author

Looks like I have a few errors that are mostly due to not using the most recent Rust version in my local development setup...

For some reason, on my local system, the value ended in 4 which was
close enough to the checked value ending in 2. On GitHub, the evaluation
ends in 6, so this test failed. I'm guessing this is just the slight
parallel summation error that can't be avoided, and my system has a
different number of cores. In the future, we might check with different
parallelism settings to make these a bit more robust, as it is some
tests might outright fail on some systems even though the results are
compatible.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

❌ Patch coverage is 76.18718% with 1374 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.56%. Comparing base (b230206) to head (28ee696).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/laddu-amplitudes/src/spin_factors.rs 58.64% 251 Missing and 5 partials ⚠️
crates/laddu-core/src/amplitudes.rs 62.45% 207 Missing and 10 partials ⚠️
crates/laddu-amplitudes/src/lookup_table.rs 76.41% 168 Missing and 16 partials ⚠️
crates/laddu-core/src/utils/reaction.rs 80.80% 115 Missing and 33 partials ⚠️
crates/laddu-core/src/amplitudes/ir.rs 62.13% 92 Missing ⚠️
crates/laddu-amplitudes/src/flatte.rs 66.49% 55 Missing and 9 partials ⚠️
crates/laddu-amplitudes/src/breit_wigner.rs 74.77% 51 Missing and 5 partials ⚠️
crates/laddu-core/src/utils/kinematics.rs 78.60% 30 Missing and 13 partials ⚠️
crates/laddu-core/src/utils/angular_momentum.rs 89.15% 30 Missing and 6 partials ⚠️
crates/laddu-amplitudes/src/voigt.rs 73.64% 27 Missing and 7 partials ⚠️
... and 18 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #104      +/-   ##
==========================================
- Coverage   77.88%   77.56%   -0.32%     
==========================================
  Files          54       67      +13     
  Lines       22291    26526    +4235     
  Branches    21659    25866    +4207     
==========================================
+ Hits        17361    20576    +3215     
- Misses       4545     5511     +966     
- Partials      385      439      +54     

☔ View full report in Codecov by Sentry.
📢 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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 19, 2026

Merging this PR will degrade performance by 86.09%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 30 improved benchmarks
❌ 40 regressed benchmarks
✅ 69 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
evaluate_local/n4k[separable@4096] 804 µs 936.2 µs -14.11%
evaluate_local/n4k[non_separable@4096] 597.7 µs 665.2 µs -10.15%
optimized/n32k[partial@32768] 24.5 ms 19.2 ms +27.99%
evaluate_local/n4k[partial@4096] 689.9 µs 788.2 µs -12.47%
weighted_gradient_sum_partial/n32k[partial@32768] 24.5 ms 19.1 ms +28.09%
optimized/n4k[partial@4096] 3.2 ms 2.5 ms +28.16%
eventwise_baseline/n32k[partial@32768] 6.6 ms 7.4 ms -10.04%
weighted_gradient_sum/n32k[non_separable@32768] 26.4 ms 21 ms +26.01%
eventwise_baseline/n4k[non_separable@4096] 4.5 ms 3.6 ms +26.21%
weighted_gradient_sum_partial/n4k[partial@4096] 3.1 ms 2.5 ms +27.83%
evaluate_local/n32k[partial@32768] 5.3 ms 6.1 ms -12.18%
evaluate_gradient_local/n32k[partial@32768] 76.8 ms 68.3 ms +12.35%
evaluate_gradient_local/n32k[non_separable@32768] 24.2 ms 16.2 ms +49%
eventwise_baseline/n32k[non_separable@32768] 37.1 ms 28.9 ms +28.16%
evaluate_local/n32k[separable@32768] 6.2 ms 7.1 ms -13.72%
evaluate_gradient_local/n4k[non_separable@4096] 3.1 ms 2.1 ms +48.21%
weighted_gradient_sum/n4k[non_separable@4096] 3.4 ms 2.7 ms +25.75%
evaluate_gradient_local/n4k[partial@4096] 9.6 ms 8.6 ms +12.3%
optimized/n32k[separable@32768] 21.8 ms 16 ms +35.85%
eventwise_baseline/n32k[separable@32768] 7.4 ms 8.4 ms -11.64%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing development (28ee696) with main (b7d3466)

Open in CodSpeed

@denehoffman
Copy link
Copy Markdown
Owner Author

I honestly think codspeed is overstating the regression because a bunch of microbenchmarks have been added up by percentage. I changed a few things to improve some of the other benchmarks, but this didn't actually effect the regressing ones. I expect a small hit on pre-evaluation just because we're doing more complex handling of angles, but I think I'm going to release this now and worry about the small performance differences in the next patch.

@denehoffman denehoffman merged commit ff975e5 into main Apr 19, 2026
13 of 16 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.

1 participant