I think I know what is happening here. All the maps are shuffled to memory, but when the last map is shuffled, it just happens that the memory limit is reached and a memory to disk merge is triggered and all the output touches the disk. As a result, spill counter is the same as map output records. A simple fix would be to increase the number of maps so that the last few maps reside in memory and so the assert condition is met.
I will fix this as a part of