The magnesium is not really tied to how much Vitamin D you take. You do not need any if there is enough in your diet but most diets are low in magnesium intake. So maybe try a minimum of 200mg but you might need more. If you take too much magnesium, it will cause loose bowels, so keep that in mind. If that is the case, then you just need to cut back on the amount you take.
You should test before you take any Vitamin D if possible.