It depends on what you mean by the whole groupset. A pair of shifters, RD, FD, Crankset, Cassette, chain and possibly brake levers if the shifters you are replacing are combo shifter/brake lever and the new shifters aren't (M4000 exists in both separate and integrated controls
AFAIK). If you're going to swap in a 9-speed cassette, go for it. You won't have any problems. Otherwise, the 9 speed shifter won't work with an 8-speed cassette.