SF has pretty lenient tenancy laws but even then, if someone stops paying rent, you can evict them.
If you are both leasing from the landlord you have equal rights and actually only the landlord can evict.
If you are the master leaseholder and your roommate is subleasing then you have many of the obligations of a landlord.. which means you actually have a lot of regulations to comply with that will probably trip you up if your lessee is both malicious and litigous. Especially if the sublease was established without a contract.
Usually you can get away with it bcause the kinds of people who just stop paying rent are deadbeats and won't challenge.