I am looking for the solution of \begin{align*} \max_{{U}\in\mathbb{C}^{M\times P},\ {U}^H{U}={I}_P } &tr\left[ {U}^H{A}{U}\left({U}^H{B}{U}\right)^{-1}\right], \end{align*} where $P\leq M$, ${A} \in \mathbb{C}^{M\times M}$ and ${B} \in \mathbb{C}^{M\times M}$ are full-rank Hermitian matrices.
I wonder if the solution is a collection of the $P$ generalized eigenvectors associated to the $P$ maximal generalized eigenvalues of the matrix pencil $({A},{B})$. Alternatively, ${U}$ would be a collection of the $P$ eigenvectors associated to the $P$ maximal eigenvalues of the matrix ${B}^{-1}{A}$.
I can only prove it in the case $P=1$, in which case the problem becomes the well-known generalized Rayleigh quotient \begin{align*} \max_{{u}\in\mathbb{C}^{M\times 1},\ {u}^H{u}=1 } & \frac{u^HAu}{u^HBu}, \end{align*} which is maximized by using the dominant generalized eigenvector of $({A},{B})$.
What about the general case $P>1$?
We can solve this for real symmetric matrices, but I'm not sure if the method works all the way for Hermitian matrices. Anyway, we can use Lagrange multipliers method to solve this problem. So, in the real symmetric case the Lagrangian can be written as
$$L = tr\left[ {U}^T{A}{U}\left({U}^T{B}{U}\right)^{-1}\right] - tr \left[ \left(U^T U - I\right) \Lambda \right]$$
where $\Lambda \in \mathbb{R}^{P \times P}$ is symmetric and contains the Lagrange multipliers. To see where the second part comes from, consider the constraint equation $U^TU=I$, which has $P^2$ equations to be satisfied (of which $P^2 - P(P+1)/2$ are redundant). Multiplying each one with $\Lambda_{ij}$ and summing all of them yields
$$ \textbf{1}^T \left[ \left(U^T U - I\right) \circ \Lambda \right] \textbf{1} = tr \left[ \left(U^T U - I\right) \Lambda \right] $$ where $\circ$ is the Hadamard product and $\textbf{1}$ is the vector with all ones. We used the properties of Hadamard product to obtain the result.
We can use the differential form of $L$ w.r.t. $U$ to solve the problem as follows:
$$\begin{align} dL &= tr\left[ d \left({U}^T{A}{U}\right) \left({U}^T{B}{U}\right)^{-1}\right] + tr\left[ {U}^T{A}{U} ~ d \left(\left({U}^T{B}{U}\right)^{-1}\right)\right] - tr \left[ d\left(U^T U \Lambda\right) \right] \\ &= 2 tr\left[\left({U}^T{B}{U}\right)^{-1} {U}^T{A}(dU)\right] - 2 tr \left[ \left({U}^T{B}{U}\right)^{-1} {U}^T{A}{U} \left({U}^T{B}{U}\right)^{-1} {U}^T{B}(dU)\right] \\ &\phantom{=}- 2 tr \left[ \Lambda U^T (dU) \right] \\ \frac{\partial L}{\partial U} &= 2\left({U}^T{B}{U}\right)^{-1} {U}^T{A} - 2\left({U}^T{B}{U}\right)^{-1} {U}^T{A}{U} \left({U}^T{B}{U}\right)^{-1} {U}^T{B} - 2\Lambda U^T \\ &= 0 \end{align}$$
Mutilplying with $U$ from right we get $\Lambda = 0$. So the constraint is not binding. Therefore, $U$ has to satisfy $$ U^T A = {U}^T{A}{U} \left({U}^T{B}{U}\right)^{-1} {U}^T{B} $$ If $B$ has an inverse we get $$ U^T A B^{-1} = {U}^T{A}{U} \left({U}^T{B}{U}\right)^{-1} {U}^T $$ or equivalently $$ B^{-1} A U = U \left({U}^T{B}{U}\right)^{-1} {U}^T{A}{U} $$
Note that the image of the right side of the equation is the column space of $U$. This means image of $U$ must be an invariant subspace of $B^{-1} A$.
If there are finitely many invariant subspaces, an algorithm for finding $U$ can be given as follows:
Of course there might be infinitely many invariant subspaces. In this case you can try to parameterize $U$ and find the parameters that maximizes the trace. For $P=1$, the eigenvector of the largest eigenvalue gives a solution, but there might be infinitely many $U$ that gives the same result.
In general, if $B^{-1} A$ has distinct eigenvalues, then there are finitely many invariant subspaces.
I believe this method also generalizes to Hermitian matrices but you need to be careful when calculating the derivative of the trace, since it changes with complex conjugate transpose operation.