Improving my profile for cs phd admissions (math undergrad) I'm a third year math major who is very sure he is not capable of succeeding in a math graduate program, as my GPA is good but not stellar (3.8, will probably fall to around 3.6-3.7). As such, along with my exposure so far (detailed a little below), I want to move to cs for my phd.

I worked as a data scientist for a startup for 7 months, and I'm going to work as a machine learning engineer for another startup part time while doing school part time. I'm in host matching for an internship at Google for the summer. I plan to continue to work part time as a machine learning engineer and go to school part time.

I have done very well on most of my bread and butter mathematics (A- to A+ in my most recent linear algebra, calculus, abstract algebra) but I have done relatively poorly on my midterms for analysis and graph theory and I am expecting a B+ overall for both. I have taken an honors introduction to computing science sequence and I've gotten A's on both. I am taking a undergraduate introduction to machine learning course, and a graduate reinforcement learning course. I plan to continue with math up to measure theory.

My university has a very strong reinforcement learning lab and I plan to start working there in the summer full time if I do not get an internship at Google, or I will take a year off to work in the lab part time and work at the startup part time. I have already communicated this with the lab and the startup and they are fine with it.

What can I meaningfully do to improve my application, assuming that I will have my SOP and reference letters secured by the lab? Is there any must take courses for phd's in this space that are not detailed on the graduate admissions (like real analysis for most physics phd admissions)? 

Also, what are the repercussions to staying at my own university for my graduate degree? I really enjoy it here and my university is quite good at the fields which I want to study, so I would be happy staying here.

My goal is to get into a top 50 phd program, and my pipe dream is to go work at the big research labs (brain, fair, openai, etc).
As far as marks and grades go, that will depend very much on where you apply. Checking the admission requirements for the 'top 50' PhD programs is the best advice I could give there. I'm assuming you're US based given you're referencing GPA, midterms etc, and providing you want to remain in the country looking up admission requirements should be then straightforward (the same would apply in any country with regard to undergrad marks and PhD admission expectations).

As you're intending on moving to computer science, the most important thing to have would be programming experience. Some of the 'exposure so far' that you detail might imply you have done actual coding, but it is not clear. You should definitely explicitly highlight what experience you have there on any application you make (and it would help if you did the same here!) If you are a competent mathematician (or scientist, or engineer for that matter) making the move to computer science should be well within your capabilities but it will, again, depend very much on where you apply as to how much foreknowledge they will expect / require you to have. I myself moved from chemistry research to being a C++ computer game engine programmer and I know plenty of programmers who have started out with degrees / careers in maths, engineering etc before ending up in computer science masters programs. Switching straight into a PhD may have more stringent requirements, but that'd be another thing to check on with the particular places you want to apply to.

There are no professional or academic repercussions as such to carrying out doctoral research in the same place you studied for your undergrad degree. However, moving elsewhere will most likely expose you to new ways of thinking and working, which is generally a good thing where research is concerned!