Active fault management (AFM) based on federated learning is established to realize ultra-integration of hundreds of microgrids, enabling them to output reference values fast enough during fault ride through (see the Figure, which is reprinted with permission from ref. iEnergy, 4: 453–462, 2022 © 2022 The Author(s)). AFM is first formulated as a distributed optimization problem. Then, federated is used to learning to train each microgrid's neural network. One concern for integrating optimization into power grid fault management and dynamic control is real-time performance because optimization usually takes more time to get reference values than widely used PID feedback control. To address this concern, controller hardware-in-the-loop (HIP) simulation with RTDS simulators is used to demonstrate the real-time performance of distributed-optimization-based fault management algorithms. In the hardware setup, one individual computer exclusively runs one microgrid or PV farm's control algorithm. Real-time simulation results demonstrate that the algorithms can output reference values within 100 ms, which can be considered well enough for fault management and dynamic control.