This is a question that gets asked often but there's never really been a comprehensive reference for the info. The info here applies to hubs from any YZ model used in a YZ400/426/450. Thanks to Bob Russell at RTR Precision Wheel Lacing for helping collect this.
Here's how it works out:
The front hub is the same from 1997 to 2001. Uses 20mm bearings. It can be identified by the four cast reinforcement ribs running across the hub.
2002 and up use the same hub. This hub also uses 20mm bearings. It is smooth across the center, with no ribs, and has a larger diameter at that point.
Early Front hubs can be used on 2002 and up by using the 2001 spacers . 2002 hub can be used on earlier bikes by using 2002 and up spacers.
This information applies to all YZ models from 125-450F.
1998 and earlier use the same rear hub, casting number 2VN00 on the hub. Uses 20mm bearings. These will not fit 1999 and later bikes because the axle is too small.
1999 and up use the same rear hub, casting number 5ET. Use 22mm bearings. Any of these can be used in any '99-'08 model by using the spacers from the year model bike the wheel will be used in. There are four different sets of these, each matching up with a change in the swing arm. You need two for each wheel. They're the same on both sides:
Rear wheels from 125's and 250F's have a 1.85" wide rim. All others have a 2.15" wide rims.
Use the spacers that match the year of the bike the wheel will be fit to, and any '99 or later rear wheel will work on any '99 or later YZF.
Some have asked about the fact that the drive side bearing and seal on the '06 up hubs are different than the brake side, or than the bearings on earlier hubs. The bearings are the same dimensions as the earlier hubs, however, and have no bearing (pun unintentional) on their interchangeability with other YZ rear wheels.
Bearing info for '97-up front wheels, and '99-'08 rear wheels:
Front - 6904-2RS - 20mm ID x 37mm OD x 9mm
Right Rear - 60/22-2RS - 22mm ID x 44mm OD x 12mm
Left Rear - 62/22-2RS - 22mm ID x 50mm OD x 14mm
This information applies to rear wheels from YZ and WR models. YZ fronts will fit WR's, but will not drive the odometer, and YZ spacers must be used.