The increase in memory is expected, since you are storing each y_mini output in y alone with the complete computation graphs.
If you want to reduce the memory usage, you could e.g. calculate the loss and gradients using y_mini.
This would free the intermediate tensors (needed to calculate the gradients), as they are currently all stored on the GPU.