I get equal gradients (up to floating point precision) using your model and this example script for different number of accumulation steps:
import torch
import torch.nn as nn
import torch.nn.functional as F

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 32, 3, 1)
        self.conv2 = nn.Conv2d(32, 64, 3, 1)
        self.dropout1 = nn.Dropout(0.25)
        self.dropout2 = nn.Dropout(0.5)
        self.fc1 = nn.Linear(9216, 128)
        self.fc2 = nn.Linear(128, 10)
    
    def forward(self, x):
        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.relu(x)
        x = F.max_pool2d(x, 2)
        x = self.dropout1(x)
        x = torch.flatten(x, 1)
        x = self.fc1(x)
        x = F.relu(x)
        x = self.dropout2(x)
        x = self.fc2(x)
        output = F.log_softmax(x, dim=1)
        return output

model = Net()
N = 50
x = torch.randn(N, 1, 28, 28)
target = torch.randint(0, 10, (N,))
criterion = nn.NLLLoss()
model.eval() # disable dropout

# raw run
out = model(x)
loss = criterion(out, target)
loss.backward()
grads_ref = [param.grad.clone() for param in model.parameters()]

# gradient accumulation
model.zero_grad()
nb_steps = 5
step = int(x.size(0)/nb_steps)
for i in range(0, x.size(0), step):
    print(i, i+step)
    x_ = x[i:i+step]
    out = model(x)
    loss = criterion(out, target)
    loss = loss / nb_steps
    loss.mean().backward()

grads = [param.grad.clone() for param in model.parameters()]

# compare
for g1, g2 in zip(grads_ref, grads):
    print((g1 - g2).abs().max())

> tensor(1.9325e-08)
  tensor(1.5600e-08)
  tensor(2.1886e-08)
  tensor(3.5390e-08)
  tensor(4.6566e-09)
  tensor(1.8626e-09)
  tensor(1.6764e-08)
  tensor(7.4506e-09)

You could also check, if your code yields the same gradients to narrow down the difference between the different approaches.
Note that I had to disable dropout in order to compare the results. Otherwise the randomly dropped activations wouldn’t allow for the comparison.