celineteller:

But, as I have a completely independent forward passes, how the two computation graph are accumulated to calculate the gradients for all parameters ?


Based on your description I don’t think they are completely independent, since you are summing them at one point. Autograd will handle them as a standard addition and will backpropagate through the addition as seen here:
x = torch.randn(1, requires_grad=True)
lossX = x * 2

y = torch.randn(1, requires_grad=True)
lossY = y * 3

out = lossX + lossY
out.backward()
print(x.grad)
print(y.grad)

Note that the loss calculation could of course be more complicated than in this simple example.