Vectorized histogramming - #680
Conversation
|
I'm confused.. the native pytorch histogram crashed for large batching or the custom vectorized version? otherwise the speed comparison is pretty good. It's faster than cloud-in-cell for large screen, which justifies its usage? |
It seems that the pytorch histogramdd was the one crashing on GPU because the numbers of the custom vectorized version match with the 'Compare the different methods in Cheetah at the state of this PR' bottom plot. There might be an issue with the histogramdd runs on GPU because the ones that did run were significantly slower than running on CPU. Either way, the custom vectorized histogramming seems to perform better in most usable cases |
|
The main reason why histogramdd is significantly slower in the vectorized case is because it isn't actually vectorized. It flattens the batch dimensions. That was the motivation to do the custom code. The results you show are interesting though. I suggest we merge and then report these observations as an open issue for the future. |
Yes, of course I am aware of that. The case that confuses me is specifically a non-vectorised one. |
I see. I'm not sure what could be causing that behavior for high number of particles. The tradeoff of the new implementation would be: 'native' vectorization which is significantly faster for large batch size (>10) but significantly slower for small batches when N>~50k. I still think it is worth it since the evaluation time is small when the batch size is small anyways, and we gain significant speedup for large batches (where the nominal evaluation time is large) + robustness in MPS GPU evaluations. Further optimization of the vectorized histogramming could be left as a separate future issue. |



Add vectorization for
Screen.readinghistogram (see #351 )Allows fast computation of vectorised histograms when automatic differentiation is not required (model evaluation, for example).
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.