The Early & Late 2013 models use a different proprietary SSD connector. You cannot interchange them. I believe the 2012 Retina model uses the same proprietary connector as the Early 2013 model, but whether the SSDs are fully interchangeable is another matter.
Even if you could, sometimes those Macs will refuse to boot into macOS with a different SSD installed (I know it is crazy, but I've personally experienced it). macOS has some code in it which will refuse to work if the wrong SSD is installed. Some Apple SSDs can be used in other models, but there is no way to tell which ones since the SSDs appear physically identical.
FYI, the SSD connector on the Late-2013 to 2015 MBPros are physically the same, but not all of those SSDs will work on another Mac even within that range due to restrictions within macOS (a non Apple OS may work perfectly fine though).