Metrics functional precision_recall inconsistent results for large input
BUG metrics.functional.classification.precision_recall
I have encounter weird bug, when using functional metrics for very large input (~10^7).
My assumption is, that for very large inputs, pytroch-ligthning cuts the input and uses only part of it.
While for n=10^6 precision and recall metrics work as expected, with n=10^7 I receive inappropriate values
In the notebook, I've created an experiment which shows the problem.
def experiment(n):
  """
   Calculates precision and recall with fixed propability distribution for preds. Only size if the input is changed
  """
  target = torch.cat([torch.ones(n), torch.zeros(n)]).long()
  preds = torch.cat([
      torch.ones(int(n * 0.6)),
      torch.zeros(int(n * 0.4)),
      torch.ones(int(n * 0.4)),
      torch.zeros(int(n * 0.6)),    
  ])
  return pl.metrics.functional.classification.precision_recall(
    preds,
    target,
    class_reduction='none'
  )
###########################
n1 = int(10e6)
experiment(n1) # => (tensor([0.6000, 0.6000]), tensor([0.6000, 0.6000])) Proper results for our probabilities
n2 = int(10e7)
experiment(n2) # => (tensor([0.5000, 0.5000]), tensor([0.5000, 0.5000])) Wrong results
# Both experiments should produce exactly the same results. Only difference is the input size.
To Reproduce
Experiment can be also found here PrecisonRecallBug
Expected behavior
Both experiments produce the same precision and recall values
Environment

CUDA:

GPU:

Tesla K80


available:         True
version:           10.1


Packages:

numpy:             1.19.5
pyTorch_debug:     True
pyTorch_version:   1.7.0+cu101
pytorch-lightning: 1.1.8
tqdm:              4.41.1


System:

OS:                Linux
architecture:

64bit



processor:         x86_64
python:            3.6.9
version:           #1 SMP Thu Jul 23 08:00:38 PDT 2020