In the trailer for Star Wars Rebels season 2, we can see that Captain Rex survived the Clone Wars and most probably deserted. As a captain of the 501st reporting directly to Anakin Skywalker, he and the rest of the battalion knows the attack on the Jedi Temple is to be led by Darth Vader. Once he meets the Sith Lord in the flesh, it is impossible he would not recognise the Republic's poster boy he fought alongside for 3 years.
So the question is: Was Rex still there when Order 66 was executed, or did he desert before that? If he is indeed aware of who Darth Vader is, then I think it has major implications as I think he'll eventually mention it to Ahsoka.
imo, he likely deserted only after Order 66, as: 1) he had demonstrated conviction in the values of the Republic he was supposedly defending, so it's unlikely he would abandon it 2) he's somewhat close to Anakin, so there's nothing to emotionally shatter his blind loyalty...yet 3) his inhibitor chip is likely undamaged.
I think what made him lose his loyalty is the events of the Republic's fall and the Empire's rise, but at a more gradual pace, eventually shaking him up. Ofc, all these are pure conjecture, but what do you think?
Edit: Just saw this video. It appears that Captain Rex and a few others had their inhibitor chips removed, as pointed out in the video. Still not convinced he deserted before or upon Order 66 and did not execute it, though. It's still pure conjecture as to when exactly he removed the inhibitor chip, I think