  Computer-automated design and discovery have led to high-performance
nanophotonic devices with diverse functionalities. However, massively
multi-channel systems such as metasurfaces controlling many incident angles and
photonic-circuit components coupling many waveguide modes still present a
challenge. Conventional methods require $M_{\rm in}$ forward simulations and
$M_{\rm in}$ adjoint simulations -- $2M_{\rm in}$ simulations in total -- to
compute the objective function and its gradient for a design involving the
response to $M_{\rm in}$ input channels. By generalizing the adjoint method and
the recently proposed augmented partial factorization method, here we show how
to obtain both the objective function and its gradient for a massively
multi-channel system in a single simulation, achieving
over-two-orders-of-magnitude speedup and reduced memory usage. We use this
method to inverse design a metasurface beam splitter that separates the
incident light to the target diffraction orders for all incident angles of
interest, a key component of the dot projector for 3D sensing. This formalism
enables efficient inverse design for a wide range of multi-channel optical
systems.
