There seems to be ample [1] data [2] about [3] this.
1: https://www.glassdoor.com/Salaries/san-francisco-senior-soft...
2: http://www.payscale.com/research/US/Job=Senior_Software_Engi...
3: http://www1.salary.com/CA/San-Francisco/Software-Engineer-II...
In any case, somebody who thinks this represents a significant slice of the Silicon Valley workforce is living in a bubble. For every engineer making >$500k, there are many thousands making <$200k, at the thousands of other tech companies in the Bay Area that aren't Google/Amazon/Facebook/Apple. While the $500k engineer has every incentive to stay in SV, that has no bearing on the vast majority of engineers.
I have heard that at FB and Google, a very small percentage of engineers got special stock awards a couple years ago that could put them in that range. But most top performers at these places at the senior/staff level are more in the 175-350 range.
Other than that, the only engineers making that kind of money got lucky in a startup lottery.
I doubt Apple, Amazon, or even Facebook pay that much on any regular basis, but I wouldn't rule out someone getting an outsized offer during a machine learning (or other flavor of the month) hiring frenzy.
[1] https://www.glassdoor.com/Salary/Google-Staff-Software-Engin...