is it a six or eight?
if it's a six, is it blowing black smoke out of the exhaust?
Yes -> check the vacuum line to the map sensor.
No -> Could be a faulty crank angle sensor or coil pack.
If it was doing the same earlier, but at only > 2500 rpm, id tend to think it is a coil pack fault, where one of the coils is breaking down.
Other usual faults could be leads, plugs, jumped timing chain, bad batch of fuel, water in the fuel, low fuel pressure, high fuel pressure, map sensor fault....