"We have a series of identical pumps, and only the hot ones are foaming. Why is this?"
Initially, this seems contrary to all logic. Higher temperatures will typically lower the viscosity of the oil. Normally, a thinner oil will have a lower tendency to foam because air bubbles will rise out of the oil more rapidly (actually less aeration), and foam bubbles will have a thinner oil wall, which will break more easily.
Foaming is usually caused by:
More than likely the oil isn’t foaming because it is hot, but rather the oil is hot because it is foaming. Still, the root cause of the foaming must be determined. Consider that the foam is displacing the oil, and the equipment (bearing, gear, etc.) is being starved of oil and creating the heat.
The root cause of the foam is likely an oil level or contamination issue. Adding more anti-foam additive usually does not work and may make matters worse.
In most cases, an oil change or a partial drain and refill will be necessary. A flush may be required as well if some type of contamination is the root cause. Since this can get expensive for large systems, reconditioning of the lubricant may be considered. However, this does not always work and will probably only be a stay of execution rather than a pardon.
Be sure to resolve the root of the problem before performing a drain and flush. If cross-contamination with another oil is the issue, address the solution with fluid identification (color-coding) and training. Mechanical issues might be due to the tank design, oil return-path geometry or suction-side piping air leaks.
While troubleshooting a foaming problem can be challenging, you should be able to identify and correct the root cause through a process of elimination.