Pairwise absolute differences

I am trying to come up with an efficient implementation for the variogram score, equation (3) in https://journals.ametsoc.org/view/journals/mwre/143/4/mwr-d-14-00269.1.xml:

Here y is the “true” value whereas X is an ensemble forecast. y.shape = (bs, 100000) and X.shape = (bs, 8, 100000) - each forecast is calculated at about 100k points. I’d like to calculate the score without explicitly building a pairwise differences matrix

y_diff = torch.abs(y.unsqueeze(1) - y.unsqueeze(2))  # this will OOM

as that’d entail creating a matrix with 10^10 elements. Any suggestions?