Conversation
|
I think in this case the code readability is even slightly improved. Considering the speed up is only 200 ns per call, and the number of calls not that large, the lack of a visible overall speedup is not surprising. Despite this, I think we can and should merge this. |
There was a problem hiding this comment.
Pull Request Overview
This PR improves performance by replacing various PyTorch transpose operations with the faster .mT property. Based on benchmarking, .mT is the fastest transpose operation in PyTorch for matrix transposition.
- Replace
torch.transpose()and.transpose()calls with.mTacross multiple files - Update code formatting to use single-line expressions where applicable
- Add performance documentation to contribution guidelines
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_statistics.py | Replace .T with .mT in test covariance calculation |
| cheetah/utils/statistics.py | Use .mT for transpose in weighted covariance matrix computation |
| cheetah/utils/kde.py | Replace .transpose() with .mT in kernel density estimation |
| cheetah/track_methods.py | Update transpose operations in transfer matrix calculations |
| cheetah/particles/particle_beam.py | Replace transpose operations in particle transformation |
| cheetah/accelerator/screen.py | Update transpose usage in beam reading methods |
| cheetah/accelerator/element.py | Use .mT in first-order transfer map tracking |
| cheetah/accelerator/dipole.py | Replace transpose in dipole transfer map calculations |
| cheetah/accelerator/cavity.py | Update transpose operations in cavity tracking |
| CONTRIBUTING.md | Add performance guidance for transpose operations |
| CHANGELOG.md | Document performance improvements |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Christian Hespe <christian.hespe@desy.de>
|
These results are really weird ... especially because the |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.






Description
Sub- / replacement PR for #538.
We've seen that the fastest transpose operation in PyTorch seems to be
x.mT.Motivation and Context
Types of changes
Checklist
flake8(required).pytesttests pass (required).pyteston a machine with a CUDA GPU and made sure all tests pass (required).Note: We are using a maximum length of 88 characters per line.