This major release comes with significant overhauls of some core components of Cheetah. Highlights include an overhaul of the tracking system to support second-order tracking and transfer map/tensor caching; clearer tracking methods names; improved reliability of the gradients computed through Cheetah; a more PyTorch-like typing behaviour; and overall speed improvements of up to 7x in some cases.
🚨 Breaking Changes
Segment.set_attrs_on_every_element_of_typehas been renamed toSegment.set_attrs_on_every_element, and made more general, with theelement_typeargument being optional and renamed tofilter_type. (see #476) (@jank324, @cr-xu)- Cheetah Modules (
Element,Beam,Species) no longer automatically change the device and dtype of passed parameters. Instead, the user is expected to make sure that the device and dtype of parameters and Modules match. This is more in line with how Modules included in PyTorch operate. (see #538, #552) (@jank324, @Hespe) - Add support for Python 3.14, and remove support for Python 3.10, as well as increase the minimum required versions for some dependencies. (see #582) (@jank324)
- The tracking system has been widely overhauled. As part of this overhaul we renamed the tracking method
"cheetah"to"linear"and"bmadx"to"drift_kick_drift". The existing methods"cheetah"and"bmadx"have been fully deprecated and will no longer work. Cheetah will raise an informative error for a number of releases to give users time to adapt their code. (see #476, #596) (@jank324, @Hespe, @cr-xu)
🚀 Features
- Implement second-order tracking for
Drift,DipoleandQuadrupoleelements, and add a convenient method to set tracking methods for an entire segment. This comes with an overhaul of the overall tracking system. (see #476) (@cr-xu, @jank324, @Hespe) Cavitynow supports travelling wave cavities in addition to standing wave cavities via thecavity_typeargument (see #286) (@zihan-zh, @jank324)- Documented PyTorch
compilefor improved speed (see #390) (@ax3l) - Beam classes now account for dispersion. Dispersion correction is included in the Twiss and emittance computations. Dispersion arguments are added to
from_parametersandfrom_twissbeam initialisation methods. (see #540) (@cr-xu) - Add convenience methods to
Segmentfor getting an ordered list of all element names and the index of a specific element by its name (see #534) (@roussel-ryan, @jank324) - First- and second-order transfer maps are now cached resulting in potential speed-ups of up to 10x and more (see #532, #565) (@jank324)
- Methods for creating
ParticleBeaminstances from distributions via stochastic sampling now make sure that the statistics of the generated particles match the desired distribution (see #546) (@cr-xu) BPMelements now support misalignments (see #533) (@roussel-ryan, @jank324)- Speed up tracking by replacing some PyTorch operations with faster alternatives (see #538, #558, #555, #556, #563, #561) (@jank324, @Hespe)
- New
CombinedCorrectorelement that combines the functionality ofHorizontalCorrectorandVerticalCorrector(see #589) (@jank324, @amylizzle)
🐛 Bug fixes
- Shorten
__repr__ofSegmentfor large lattices to prevent debugging slowdowns (see #529) (@Hespe) - Fix typo saying Bmad in Elegant import method docstring (see #531) (@jank324)
- Remove division by zero in
Cavityfor off-crest phase (see #549, #550) (@Hespe) - Fix issue with
SpaceChargeKickwhere the particle species was not preserved (see #560) (@austin-hoover, @jank324) - Fix bug that caused beams to revert to electron species when tracking through
Cavityelement, resulting in unexpected acceleration behaviour when tracking non-electron species through multipleCavityelements. (see #570) (@jank324, @hjkim-iris, @Copilot) - Fix issue where branching in the computations could "hide" gradients w.r.t. to some inputs under certain conditions, leading to incorrect gradient computations. (see #553) (@jank324, @Hespe)
🐆 Other
- Add a speed benchmarking workflow of tracking through the ARES lattice (see #527) (@Hespe)
- Add tests that track through every subclass of
Elementfor all permissibledtypesanddevicecombinations (see #499) (@Hespe) - Fix false dtype in
Screendocumentation (see #544) (@jp-ga) - Fix an issue where running the plot tests on Windows (most notably on the recently upgraded GitHub Actions Windows runners) would sporadically fail with a
_tkinter.TclError: Can't find a usable init.tcl in the following directorieserror, by forcing the matplotlib backend toAggwhen running tests on Windows. (see #567) (@jank324) - Temporarily removed
flake8-blackfromformatAction because it causes issues with the latestblackversion. This has since been reinstated. (see #569, #575) (@jank324) - Fix typo in README (see #581) (@jank324)
- Update ARES LatticeJSON file to match the latest properties in Cheetah (see #588) (@cr-xu, @jank324)
🌟 First Time Contributors
- Zihan Zhu (@zihan-zh)
- Austin Hoover (@austin-hoover)
- @hjkim-iris