Foreigners who went to grad school are very heavily represented in Silicon Valley. Perhaps going all the way for a PhD is not worth it (debatable, some of my CS PhD friends have done incredibly well) but a Masters is definitely a strong path to success.