Hi,
If you’re not running with creat_graph=True, then the backward runs with autograd disabled.
If you need to enable it locally you can use with torch.enable_grad():. Also I would advise you to use autograd.grad here to get the gradient more easily:
            local_net = nn.Sequential(nn.Linear(2,3)) # This will contain random weights. Is it expected?
            with torch.enable_grad():
                output = local_net(input)
                loss = nn.MSELoss()
            grad_weight_cu = autograd.grad(loss, local_net[0].weight)[0]