I am new here, so this is my first post and I have a question to ask. I am a non-EU citizen working with an international organization here in Geneva. I have been accepted to a master program at the University of Bern, and I am probably going to start the course this autumn. As I am already in the country, I am obviously not going to apply for a visa; so I wanted to know what is the procedure to hand back the carte de legitimation and receive a student permit in its place. Also, how soon should I start this procedure? I am considering handing back the carte de legitimation at the beginning of September, and I start my course in mid-September.

...As I am already in the country, I am obviously not going to apply for a visa...

I am not sure it's so "obvious". You might need to apply for a visa anyway, as your CDL is independent from a student visa. Your best bet is to contact the authorities in Bern and ask them how to proceed: