It's easy to prove this is a convex optimization problem, as can be seen in the DCP formulation below. The problem satisfies the linearity constraint qualification. Therefore, the KKT conditions are necessary and sufficient for (global) optimality. Nevertheless, perhaps the KKT conditions can only be solved numerically.
It is easy to enter this problem into a convex optimization modeling tool, such as CVX. Here is a CVX program to solve it. I will assume
Q are column vectors, whose ith elements are $K_i$ and $Q_i$ respectively.
sum(x) <= X
rel_entr function constrains its arguments, hence
x, to be $\ge 0$.
CVX will call a solver, and if the solution status is Solved,
x will be populated with its optimal value. Given the use of the exponential cone, Mosek, which natively supports it, is the preferred solver under CVX for this problem.. Otherwise, install CVXQUAD and its
exponential.m replacement - see http://ask.cvxr.com/t/cvxquad-how-to-use-cvxquads-pade-approximant-instead-of-cvxs-unreliable-successive-approximation-for-gp-mode-log-exp-entr-rel-entr-kl-div-log-det-det-rootn-exponential-cone-cvxquads-quantum-matrix-entropy-matrix-log-related-functions/5598 .
Edit: In lieu of closed-form solutions, Differentiable Convex Optimization Layers, cvxpylayers, in CVXPY allows insertion of the solution of DCP-compliant convex optimization problems, such as this, as a differentiable layer in lieu of nonlinear activation functions - see the blog Differentiable Convex Optimization Layers - CVXPY creates powerful new PyTorch and TensorFlow layers