There are papers stating a smaller batch size might generalize better, and it’s not uncommon to see the effect.
This paper 317 is an example.
Is the loss using the larger batch size eventually decreasing?
PS: You can post code using three backticks. I’ll edit your code for readability reasons.