Since increasing my vitamin D, I no longer have GI issues with magnesium. High intake of Vitamin D can deplete magnesium. Maybe start with a lower amount a few days after you start increasing Vitamin D? Magnesium is so important! Nearly as many people are subclinically deficient in magnesium as they are in Vitamin D.
Keep experimenting with different types of magnesium. Chelated magnesium oxide has been fine for me. Chelation makes it more bioavailable. Too much M glycinate gives me trouble too. I do a combo of a small amount of M citrate in an electrolyte drink, and one 250 mg pill of M oxide at night.