I don't specifically know about Berkeley, but my experience has been there's always an accelerated track for some students whose parents push the school system to let them into the right classes. At some point in middle school I was bussed to a local high school along with some of my peers to take advanced math not offered in middle school, and in high school all of my math classes were with people 1-2 years older than me.