I'm loathe to further inflame things, because there is no way to know some of this for sure, but with modern logistics and testing in the silicon world, it's very achievable to take and as part of the manufacturing process run a series of tests on the silicon and motors themselves right at the end of the component manufacturing line. In a case like this you would take a motor right off the line at manufacturing, place it into a test harness of some sort, and measure how much power it drew to hit a certain performance characteristic, or what it output at a set of specific input power. It would be part of a fairly standard quality control program because obviously you want to know that motor is going to turn before you build it into a car. It's pretty typical to have significant deviations from your target spec. It wouldn't be that your motor couldn't hit the same rpm or whatever, it would be that it took a higher power draw to do so, especially at the extremes. So a performance motor might be one that can deliver the output needed to accelerate at the performance speed at the max output of the battery pack, a lower binned motor might need 5-10% more power to deliver the same output. That motor is perfectly good for use in a car without re-work as long as you meet the alternate performance target. Sometimes it's not even performance in this kind of mindset, but something more removed like what amount of heat is generated by this part under these conditions, and you can see non-trivial differences in part to part.
Part numbers are a logistical aid, so that when you get something off the big shelf in the back you know you are getting the right thing, but every motor almost certainly has a globally unique identifier like a serial number or something. Even if you weren't outright binning, you would track the results of all those tests, including the performance/capacity/etc. tests back to this serial number in a manufacturing system. Even as disorganized as Tesla sometimes seems to be it would shock me if they didn't know the serial number, and the measured results of those tests for every motor they have shipped, and be able to match that serial number to a VIN without any trouble at all. Every VIN is probably assigned all the parts it needs by part number and part serial number early on in the process on paper or in the manufacturing system at some point in the process. It wouldn't be that difficult to match up the higher performing motors with a specific vehicle so when it's time attach the motor(s) it's not just go pick one up out of the generic parts bin, it's actually lined up waiting for robot or person in the same order of the cars being manufactured on the line.
All that said, I suspect that Tesla designed a this motor as best they could. These things are typically designed with a model of the yielded parts over hundreds and thousands of parts. A responsible team would model worst case yields, best case yields, etc. Those models and the part design is optimized to deliver the most parts to spec possible, because a fully out of spec part is usually trash. By setting two different levels of usable performance your margin for the natural variation in parts is greatly increased. Engineers always hope to get as many parts as possible that test at the highest spec, but when you are talking about millions and billions of dollars people tend to be less tolerant of 'hope' and more interested in 'correct'. What's going on with the AWD and P models looks a lot like a case where Tesla designed an excellent motor, set a Performance spec, and a lower AWD spec so that they could have a high degree of confidence that virtually every motor that came off the line was sellable, no motors going into the trash/scrap/re-work piles. From what we have seen though, it's clear that the 'worst case' motor yields didn't come to pass, plenty of motors met the Performance spec. We know this because there wasn't a capacity constraint on the performance models, and in fact Tesla as selling and delivering them first. If they had thought that 75% of the motors would meet the performance spec, but in the end only 50% had, they would have pushed the price of the performance model up, or it would have been slower to deliver while motors became the bottle neck. Instead what seems likely is that more motors met the Performance spec than planned (which if true should be a big bonus for the motor design and manufacturing guys) and of course you don't throw those motors away, or store them for a day when you are magically going to sell more P models, you use them, in this case in the AWD. This doesn't mean that 100% of the motors met that spec, so you would still expect to have some percentage of AWD vehicles that wouldn't meet the P spec, say x RPM at Y power.
Over the course of a year you would refine your design, and your tests such that a new part number might emerge, primarily because doing so saves you money. Time in a test harness is measured in price per second. So if you can re-engineer to save $5 worth of time there over 500,000 motors that's real money.
Anyway... short of Tesla manufacturing or design really telling us, this is all speculation, but I wouldn't put all that much faith in the part number arguments, it just isn't that difficult these days to track these things at a much finer grain. I'd be stunned if there wasn't somewhere on every significant part in the car from the motor to the pack a bar code or some similar scannable thing that links up to a highly detailed database with a few orders of magnitude more information about that specific part than we ever see. This is how Tesla can do a recall or service advisory on specific cars, it's not just cars manufactured between the 5th and 20th, it's cars with with battery pack serial numbers between 3-031-931-900 & 3-031-932-467 which happened to be manufactured between the 5th and the 20th.