If you are a resident alien you qualify for a 529 benefit. To determine whether you are a resident alien, please refer to the
IRS guidelines (Topic no. 851, Resident and nonresident aliens). If you are on a F, J, M, or Q visa, you are usually classed as a resident alien for tax purposes after 5 years in the USA. Typically if you did 4 years of undergrad in the US you will qualify for a 529 benefit your second year of graduate school. Going back to your home country during breaks is okay as long as the majority of your time is in the US.