I’m unfortunately not familiar with cvxpylayers, but as @iffiX mentioned, the input shape of Xval and/or Yval seems to be wrong.
Based on your code it seems tou are trying to pass these tensors directly to the loss function, i.e. without a DataLoader. Could the batch size be missing? If not, I would recommend to check the shapes and make sure which shapes are expected.