Releases: desy-ml/cheetah
Releases · desy-ml/cheetah
Release list
0.8.4
🚨 Breaking Changes
DirtyNameWarnings are now suppressed whensanitize_nameis explicitly set toFalse(see #658) (@jank324, @Hespe)
🚀 Features
- Improve the speed of
SpaceChargeKickby up to 2x by replacing its custom Cloud-in-Cell implementation with the new general implementation (see #653) (@jank324) - Implement
Undulatortransverse focusing effect on charged particle beam (see #659) (@Hespe) - Add
Segment.partition_atmethod to divide aSegmentinto subcells before and after a given namedElement(see #666) (@Hespe, @jank324) - Add
Segment.with_consecutive_elements_mergedmethod to merge consecutive elements of the same type, and a.mergemethod toElementsubclasses to merge two elements of the same type. (see #667) (@jank324)
🐛 Bug fixes
- Fix
Sextupolenot being skippable if its tracking method is set tolinear(see #655) (@Hespe) - Fix issue where
ParticleBeam.randomly_subsampledmethod would not be stochastic if therandom_stateargument was not passed. This also fixes a test failure introduced by changes on the MPS backend in PyTorch 2.13. (see #655) (@jank324, @Hespe) - Fix a bug where some magnet names that are invalid identifiers (i.e. cannot be used with the
segment.element_namesyntax) would not be sanitised correctly (e.g. when they start with a digit). (see #658) (@jank324, @Hespe) - Fix KDE stability issue leading to NaNs (see #660) (@jp-ga)
- Methods of
ElementandSegmentthat internally construct new instances no longer emitDirtyNameWarnings (see #669) (@Hespe)
🐆 Other
0.8.3
🚨 Breaking Changes
- Change default
methodofScreenfrom"histogram"to"cloud-in-cell"(see #625) (@roussel-ryan, @cr-xu, @jank324)
🚀 Features
- Allow special characters in quoted names in
use lineexpressions from Fortran namelist-based lattice files created by Elegant and Bmad (see #637) (@cr-xu) - A new
Superimposedelement was added that allows zero-length elements like BPMs to be superimposed in the centre of another element (see #591) (@jank324, @phys-cgarnier) - Add all missing off-diagonal terms to the
from_parametersandtransformed_tomethods of allBeamsubclasses (see #635) (@cr-xu, @jank324) - Implement a new differentiable Cloud-In-Cell (CIC) method for n-D charge deposition and add it to
Screen. The new method is up to two orders of magnitude faster than the existing and previously only differentiable optionkdemethod. (see #625) (@roussel-ryan, @cr-xu, @jank324) - Add a
metadataproperty to elements, allowing users to store arbitrary, serialisable annotations that are not used in simulation, such as control-system addresses and PV names. (see #646) (@cr-xu, @jank324, @Hespe, @roussel-ryan)
🐛 Bug fixes
- Fix an issue where off-diagonal elements are not included in the conversion from
ParameterBeamtoParticleBeam(see #635) (@cr-xu)
🐆 Other
- Limit
UNVECTORIZED_NUM_ATTR_DIMSto only those attributes with more than 0 dimensions and adddefining_featuresto beam classes like already implemented for element classes. (see #627) (@cr-xu, @jank324)
🌟 First Time Contributors
- Christopher Garnier (@phys-cgarnier)
0.8.2
🚀 Features
- All plotting functions in
Segmentnow accept an optional axes or figure object with an interface loosely mimicking that of Seaborn. If they are passed one, they use it, otherwise they create one themselves. Either way, they return the axes or figure they used. (see #604) (@jank324)
🐛 Bug fixes
- RPN parsing was made more robust to missing whitespace in expressions, and arc trig expressions were added to infix parsing. (see #585) (@amylizzle)
- Fix issue, where the first example in the gradient-based optimisation notebook from the docs would not run because the
k1of the quadrupoles was set to0.0, which causes the gradients to be undefined (see #588, #603) (@jank324, @cr-xu) - Update the elegant conversion to include missing dipole attributes, converting
hgaptogapandfinttofringe_integral. (see #624) (@cr-xu) - Update the
to_openpmd_particlegroupconversion to useintfor status and adddetach()before tensor to numpy conversion. (see #629) (@roussel-ryan) - Fix an issue where negative length elements are incorrectly removed by the
Segment.without_inactive_zero_length_elementsmethod (see #633) (@cr-xu) - Patch emittance
NaNand0.0conditions, which caused Twiss parameters to beNaNorinfunder some conditions. (see #639) (@jank324)
🐆 Other
0.8.1
🚨 Breaking Changes
NoVisualizationWarningwas renamed toVisualizationWarningto be more general, and can now be thrown for other visualisation issues as well. (see #610) (@amylizzle, @jank324)
🚀 Features
- Update to (default)
3d-assetsversion 1.2.0 withRBendandCombinedCorrectormodels (see #605, #610) (@jank324) - Add option to dynamically specify the branch or tag of the
3d-assetsrepository to use when generating 3D meshes (see #618) (@jank324) - Converter to load Elegant SDDS beam distributions (see #612) (@cr-xu, @jank324)
- Improve efficiency of 3D rendering of large lattices by using the
Sceneclass instead ofMeshconcatenation (see #610) (@amylizzle) - New warning about elements with a length of 0.0 not being 3D rendered to-scale (see #610) (@amylizzle, @jank324)
🐛 Bug fixes
- Fixed rotation orientation of dipoles and quadrupoles when rendering 3D models (see #610) (@amylizzle)
- Fix bug when reading
nullfields from LatticeJSON files (see #619) (@alekseevpavel04)
🐆 Other
- The copyright years were updated to 2026 (see #608) (@jank324)
- Fix format issue caused by new
blackversion (see #611) (@jank324)
🌟 First Time Contributors
0.8.0
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
0.7.5
🚀 Features
- Add support for elements (especially
Drift) with negative length (see #480) (@Hespe) - Warnings are now available in the top-level namespace so that they can be referenced as e.g.
cheetah.PhysicsWarningto shortenfilterwarnignscode. (see #497) (@jank324) - Add the ability to the Bmad and Elegant converters to parse expressions that access properties from other elements (see #501, #498) (@amylizzle, @jank324)
- Update the Elegant converter to allow element names with colon as well as the definition of reversed beamlines with a minus sign. (see #504) (@cr-xu, @jank324)
Segments can now conveniently be reversed with theSegment.reversedmethod (see #504) (@jank324)- New feature for generating 3D models of lattices and viewing them (see #352, #502, #511) (@jank324, @chrisjcc, @SuchethShenoy)
🐛 Bug fixes
- Fix various
dtypeanddevicepertaining toParticleBeam,SpeciesandSpaceChargeKick(see #485, #486, #490, #491) (@Hespe, @jank324, @adhamrait) - Remove incorrect implementation of
splitfromHorizontalCorrectorandVerticalCorrector(see #480) (@Hespe)
🐆 Other
- Updated contributor list and funding strings in README and on docs index page (see #487) (@jank324)
- Add a Binder and link to
cheetah-demos(see #482) (@smartsammler, @jank324) - PyTorch is now configured to use only deterministic algorithms during tests, preventing intermittent test failures (see #480) (@Hespe)
- Make README example more copy-paste friendly, and generally improve it and the simple intro notebook in the docs. (see #493, #496) (@jank324, @ax3l)
- Fix comparison tests to work with new PyPI release of Ocelot. Remove Twiss tests where they are not needed. Increase tolerances where Cheetah and Ocelot follow slightly different models. (see #513, #519) (@jank324, @cr-xu, @Hespe)
🌟 First Time Contributors
- Julian Gethmann (@smartsammler)
- Arjun Dhamrait (@adhamrait)
- Christian Contreras-Campana (@chrisjcc)
- Sucheth Shenoy (@SuchethShenoy)
0.7.4
🚀 Features
- The new warning system was extended to have more specific subclasses of
PhysicsWarningto allow for better and easier filtering of warnings (see #415) (@Hespe, @jank324) - Implement an infix notation parser for Bmad and Elegant converters, fixing a potential security issue where
eval()could be called on user input. (see #412) (@amylizzle) - Improve numerical stability of the
base_rmatrixandbase_ttensorfunctions (related to #469) (see #474) (@Hespe, @jank324) - Minor speed improvements in
base_rmatrixandbase_ttensorby reducing memory allocations for constants, and skipping rotation computations when the present tilt has now effect. (see #474) (@Hespe, @jank324)
🐛 Bug fixes
- Fix issue that
base_rmatrixhas large error for smallk1values even for double precision (see #469) (@cr-xu) - Rework the covariance computation in
ParticleBeam.as_parameter_beamto fix an issue that caused the covariance to be computed incorrectly for vectorised beams (see #471) (@cr-xu, @jank324, @Hespe) - Unrecognised element properties in Bmad and Elegant lattice files now print a warning instead of exiting with an
AssertionError(see #415) (@amylizzle, @jank324) - A bug was fixed that caused the Bmad and Elegant importers to incorrectly parse
;line endings and comments starting with#(see #415) (@Hespe, @jank324) - The
santize_namesparameter is now correctly passed toBPMandMarkerelements when converting from Elegant (see #473) (@amylizzle)
0.7.3
🚨 Breaking Changes
- The default resolution of all plotting functions on
Segmentis nowNone, i.e. element-wise. For most lattices this will only result in faster plotting, but note that it is possible that your plots look slightly different, especially if your lattice is short or has few elements. (see #459) (@jank324, @Hespe) - Cheetah now requires
torch>=2.3(see #461) (@jank324) - Combine the
num_grid_points_{x,y,tau}arguments ofSpaceChargeKickinto thegrid_shapetuple. Fixes the cloning ofSpaceChargeKick. In addition, thegrid_extend_*properties were renamed togrid_extent_*(see #418) (@Hespe, @jank324) - Warning messages, which were previously just printed are now produced using the
warningsmodule, brining with it all the features of the latter. (see #450) (@Hespe, @jank324)
🚀 Features
- Add
KQUADandCSRCSBENDelement names to Elegant converter (see #409) (@amylizzle) - Add
Sextupoleto Bmad, Elegant, and Ocelot converters (see #430) (@Hespe) - Implement convenience method for quickly setting attributes for all elements of a type in a
Segment(see #431) (@jank324) - Add a method to
ParticleBeamthat lets you subsample a particle beam with fewer particles and the same distribution (see #432, #465) (@jank324) Segmentnow has new functionsbeam_along_segment_generatorandget_beam_attrs_along_segmentfor easily retrieving beam objects and their properties. The plot functions have been refactored to use these, and two functionsplot_beam_attrsandplot_beam_attrs_over_latticewere added for straightforward plotting of different beam attributes in a single line of code. (see #436, #440) (@jank324, @amylizzle)Beamsubclasses now track theirsposition along the beamline (see #436) (@jank324)- There is a warning now when converting elements from Elegant or Bmad that have names which are invalid for use with the
segment.element_namesyntax, and add a convenience method for explicitly converting these names to valid Python variable names. (see #411) (@amylizzle, @jank324) - Rotation matrices are no longer computed twice for forward and backward phase space rotations (see #452) (@Hespe)
🐛 Bug fixes
- Fix issue where
Dipolewithtracking_method="bmadx"andangle=0.0would outputNaNvalues as a result of a division by zero (see #434) (@jank324) - Fix issue in CI space-charge tests (incorrect beam duration in non-relativistic case) (see #446) (@RemiLehe)
- Fix issue that passing tensors with
requires_grad=Truedoes not result in gradient tracked particles when usingParticleBeam.from_parametersinitialization (see #445) (@cr-xu) - Fix import of
CustomTransferMapfrom Elegant. The affine phase-space component was previously not carried through (see #455) (@Hespe) - Provide more default values for parameters in the Elegant conversion, where elements without length
lfor example broke the converter. (see #442) (@cr-xu) - Functions using
Sextupole.splitandSextupole.plotno longer raise an error (see #453) (@Hespe)
🐆 Other
- Bmad is no longer actively run in the test workflows, and comparisons to Bmad are now done on static pre-computed results from Bmad. This also removes the use of Anaconda in the test workflow. (see #429, #431) (@jank324)
- The PyTorch pin to
<=2.6was removed, as the issue withabort trap: 6was caused by Bmad is no longer actively used in the test workflow (see #429, #431) (@jank324) - There was a temporary pin
snowballstemmer<3.0for the docs build because of an issue with the latest release. It has since been unpinned again because the release was yanked. Refer to sphinx-doc/sphinx#13533 and snowballstem/snowball#229. (see #436, #438) (@jank324) - Assert that the last row of a predefined transfer map is always correct when creating a
CustomTransferMapelement (see #462) (@jank324, @Hespe) - Minimum compatible versions were defined for all dependencies, and tests were added to ensure that the minimum versions are compatible with Cheetah. (see #463) (@Hespe, @jank324)
- Add a
pytestmarker for running tests on all subclasses ofElement. The marker automatically detects if an MWE has not yet been defined for a subclass and alerts the developer through a test failure. (see #418) (@Hespe, @jank324)
🌟 First Time Contributors
- Copilot 🤖
0.7.2
🚨 Breaking Changes
- Replace the
Segment.plot_reference_particle_traceswith a clearer visualisation in the for ofSegment.plot_mean_and_std. This also changes the plot generated by theSegment.plot_overviewmethod. (see #392) (@RemiLehe) - The order of the pixels in
Screen.readingwas changed to start from the bottom left instead of the top left. This is now consistent with theScreen.pixel_bin_centersandScreen.pixel_bin_edgesproperties. (see #408) (@jank324)
🚀 Features
- Implement
splitmethod for theSolenoidelement (see #380) (@cr-xu) - Implement a more robust RPN parser, fixing a bug where short strings in an Elegant variable definition would cause parsing to fail. (see #387, #417) (@amylizzle, @Hespe, @jank324)
- Add a
Sextupoleelement (see #406) (@jank324, @Hespe)
🐛 Bug fixes
- Fix issue where semicolons after an Elegant line would cause parsing to fail (see #383) (@amylizzle)
- Fix Twiss plot to plot samples also after elements in nested (see #388) (@RemiLehe)
- Fix issue where generating screen images did not work on GPU because
Screen.pixel_bin_centerswas not on the same device (see #372) (@roussel-ryan, @jank324) - Fix issue where
Quadrupole.tracking_methodwas not preserved on cloning (see #404) (@RemiLehe, @jank324) - The vertical screen misalignment is now correctly applied to
yinstead ofpx(see #405) (@RemiLehe) - Fix issues when generating screen images caused by the sign of particle charges (see #394) (@Hespe, @jank324)
- Fix an issue where newer versions of
torchonly accept atorch.Tensoras input totorch.rad2deg(see #417) (@jank324) - Fix bug that caused correlations to be lost in the conversion from a
ParameterBeamto aParticleBeam(see #408) (@jank324, @Hespe)
🐆 Other
- Temporarily limit
torchdependency to2.6or lower to avoidabort trap: 6error with2.7(at least on macOS) (see #419) (@jank324)
🌟 First Time Contributors
- Amelia Pollard (@amylizzle)
0.7.1
🚨 Breaking Changes
- The
incomingargument ofSegment.plot_overviewis no longer optional. This change also affects the order of the arguments. Fixes an exception that was raised by an underlying plot function that requiresincomingto be set. (see #316, #344) (@Hespe) - Python 3.9 is no longer supported. This does not immediately break existing code, but might cause it to break in the future. (see #325) (@jank324)
- The covariance properties of the different beam classes were renamed from names like
cor_xandsigma_xpxto consistent names likecov_xpx(see #331) (@jank324) - The signature of the
transfer_mapmethod of all element subclasses was extended by a non-optionalspeciesargument (see #276) (@cr-xu, @jank324, @Hespe) ParticleBeam.plot_distributionallows for Seaborn-style passing ofaxsand returns the latter as well. In line with that change for the purpose of overlaying distributions, thecontourargument ofParticleBeam.plot_2d_distributionwas replaced by astyleargument. (see #330) (@jank324)- The default values for
total_chargein both beam classes are no longer0.0but more sensible values (see #377) (@jank324) ParameterBeam._muandParameterBeam._covwere renamed toParameterBeam.muandParameterBeam.cov(see #378) (@jank324)
🚀 Features
ParticleBeamnow supports importing from and exporting to openPMD-beamphysics HDF5 files andParticleGroupobjects. This allows for easy conversion to and from other file formats supported by openPMD-beamphysics. (see #305, #320) (@cr-xu, @Hespe)- Add
marker,quadrupoleandcsbendelement names to the Elegant converter (see #327) (@jank324) - Add Python 3.13 support (see #275) (@jank324)
- Methods
to_parameter_beamandto_particle_beamhave been added for convenient conversion betweenParticleBeamandParameterBeam(see #331) (@jank324) - Beam classes now have the
mu_tauandmu_pproperties on their interfaces (see #331) (@jank324) - Lattice and beam converters now adhere to the default torch
dtypewhen no explicitdtypeis passed (see #340) (@Hespe, @jank324) - Add options to include or exclude the first and last element when retrieving a
Segment.subcelland improve error handling (see #350) (@Hespe, @jank324) - Add support for particle species through a new
Speciesclass (see #276, #376) (@cr-xu, @jank324, @Hespe) - Various optimisations for a roughly 2x speed improvement over
v0.7.0(see #367) (@jank324, @Hespe)
🐛 Bug fixes
- Fix issue where a space before a comma could cause the Elegant and Bmad converters to fail (see #327) (@jank324)
- Fix issue of
BPMandScreennot properly converting thedtypeof their readings (see #335) (@Hespe) - Fix
is_activeandis_skippableof some elements not being boolean properties (see #357) (@jank324)
🐆 Other
- Test tolerances were adjusted reduce the chance of random test failures (see #309, #324) (@Hespe, @jank324)
- The copyright years were updated to 2025 (see #318) (@jank324)
- The broken institution logo rendering in the documentation has been fixed (see #318) (@jank324)
- Added
pyproject.tomlto conform with PEP 660 as enforced as of pip 25 for editable installs (see #334) (@jank324) - Add TUHH logo to contributing institution logos (see #338) (@jank324)
- The tests for backward-mode differentiation with space charge was improved by checking the accuracy of the gradients (see #339) (@RemiLehe)
- A tests for forward-mode differentiation with space charge was added (see #339) (@RemiLehe)
- Link to different ImpactX example in test docstring (see #341) (@ax3l)
- Add link to the new Discord server (see #355, #382) (@jank324)
- Fix typo that said "quadrupole" in a dipole docstring (see #358) (@jank324)
- Type annotations were updated to the post-PEP 585/604... style (see #360) (@jank324)
- Add badge to the README for the number of downloads from PyPI (see #364) (@jank324)