"pedestal should read magnetic north and your gps true north."
Not surprising at all, since GPSes can be set up to read EITHER true or magnetic north. In my experience, that's a setup option on all of them.
But a 40 degree difference far exceeds the maximum that can be explained by any setup choices, unless someone has incorrectly programmed in a huge deviation setting manually, or the autopilot has had its memory corrupted.
I would check the settings (variation, deviation, true/mag) in the autopilot and if possible do a complete reset on it. Then make sure the magnetic compass in it has been properly calibrated, typically this requires making one or two slow and even 360-degree circles with the boat.
Most likely though, there is SOMEthing magnetic near the fluxgate sensor that the autopilot is using, or the sensor is installed incorrectly. If there's still nothing wrong--it is defective.
Take a hand compass on board the boat. See what it reads in the cockpit. Now move down near the fluxgate sensor for the autocompass, and see if the hand compass also goes 40 degrees out of whack. If it does--there's something interfering with both of them. (And the hand compass SHOULD be disturbed somewhat when it gets real close to the fluxgate sensor, in any case.)