If you have a function
$q = K(L)^a L^b$,
then by the product and chain rules, the usual $L$-derivative is
$\frac{\partial q}{\partial L} = a K(L)^{a-1} K’(L) L^b + b K(L)^a L^{b-1}$
If you wanted to find the optimal level of $L$ for this function (since $L$ determines $K$) you would do the procedure above.
You wouldn’t even differentiate with respect to $K$ as once you find the optimal level of $L$, let’s call it $L^\star$, you already know the optimal level of $K$, let’s call it $K^\star$, by the relationship $K^\star = K(L^\star)$.
Moreover, the usual partial $K$-derivative isn’t defined in the above case since $K$ isn’t a “purely” independent variable.
However, there is something called formal derivatives, in which you would ignore the dependence between the variables used as the function’s arguments.
In this case, the formal derivatives would be
$\frac{\partial q}{\partial L} = b K^a L^{b-1}$
$\frac{\partial q}{\partial K} = a K^{a-1} L^b$
This concept of formal derivative is used in the Euler-Lagrange equation from Calculus of Variations.
Whether you take the actual partial derivatives or the formal ones depends on what you want to accomplish.
As a rule of thumb, if you aren’t told to use formal derivatives, take the usual partial derivatives.
The Euler-Lagrange equation is
$\frac{\partial f}{\partial y} - \frac{d}{dx} \frac{\partial f}{\partial y’} = 0$
where the partial derivatives are taken as formal derivatives.
This equation is used to find a continuously differentiable function $y = y(x)$ (over an interval $[a,b]$), which maximizes or minimizes the following functional (a function whose argument is a function and spits out a real/complex number):
$J[y(x)] = \int_{a}^{b} f(x,y(x),y’(x)) dx$
Here $f$ is twice-differentiable in each of its three arguments, and the functional $J[y]$ maps $J:C^{1}[a,b] \to \mathbb{R}$.