RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment. If you were attempting to deepcopy a module, this may be because of a torch.nn.utils.weight_norm usage, see https://github.com/pytorch/pytorch/pull/103001
In the BPM, there is a call to
deepcopy
before passing on the beam down the line: https://github.com/desy-ml/cheetah/blob/b38a654e0e8971d42d40fad4ffd9f92068140267/cheetah/accelerator/bpm.py#L51Unfortunetly, this copy currently inhibits taking gradients of the BPM reading. The reduced example
fails with