Transformers implements daberta’s masked softmax using a custom autograd function (they say it is in order to save memory, but I am not entirely sure why that would be because they don’t say what the alternative more memory-consuming option was).
The JIT doesn’t support autograd functions (but there is a symbolic ONNX export if you want that).
One option could be to rewrite this bit as masking using stock autograd functions. This seems seems to work reasonably well for regular multihead attention.
Best regards
Thomas