"a bunch of debt"? PhD students in STEM fields, at least in the US, can usually get a PhD without taking on additional debt. Also, many programs that don't offer a master's degree program will still let you graduate with a master's if you're a few years into a PhD program and decide to bail.