Derivative of Lagrangain with respect to A parameter is not zero?

I have a very peculiar problem. I have a semi-definite problem. My problem is

$$ min. t $$
$$ s.t. L>=0, $$
$$ A>=0,$$
$$ L=[K.A,\tau;\tau^T,t-m]$$
$$ A.M=Y_M$$
$$A.I=I$$
$$ norm(A,‘fro’)^2 <=r $$
And the computed dual is
$$ max. -1/(4\rho)norm(T+X.K-U.(M+I),‘fro’)^2-<U,Y_M+I>-2x^T
\tau-\rho
r+\theta
m$$
$$ T>=0,X>=0;$$
$$Z=[X,x;x^T,\tau]>=0$$
where Z is the dual variable of L and X is the dual variable of L=[K.*A,\tau;\tau^T,t-m] and T is the dual variable of A.

I check this many times mathematically but when I check it using cvx ( which returns dual variables) its optimal value does not mach with primal( even if cvx exits with solved problem and duality gap on the scale of e-6). Unfortuantely the dual variables in cvx does not satisfy KKT condition, esp, with respect to A.
I coded primal in cvx :

 cvx_begin sdp
    variable   A_uu(n_u,n_u) symmetric
    variable   A_uq(n_u,n_q) 
    variable   A_lu(n_l,n_u)
    variable   A_lq(n_l,n_q)
    variable   A_qq(n_q,n_q) symmetric
    variable   A_ll(n_l,n_l) symmetric
    variable   tVar
    dual variable drho;
    dual variable U_uu;
    dual variable Z;
    dual variable T;
    dual variable U;
    expression B
    expression A 
    
    A = [A_ll,A_lu,A_lq;A_lu',A_uu,A_uq;A_lq',A_uq',A_qq]; 
    B = [Yl*Yl',Yl*ONEQ';ONEQ*Yl',ONEQ*ONEQ'];   
    minimize (tVar)
    subject to 
       T:A>=0;
       U:[A_ll,A_lq;A_lq',A_qq]==B;
       Z:[K .* A,ONED-beta_Var+eta_Var;(ONED-beta_Var+eta_Var)',2*tVar/lambda-m ]>=0;
       U_uu:diag(A_uu)==ONEU;
       drho: norm(A,'fro')<=r;
cvx_end 
dualObj=-(1/(4*drho)*norm(T+X.*K-U2.*CM)^2+trace(U2'*C_lq)+2*tau'*x+drho*r-0.5*lambda*m)
norm(2*drho*A-(T+X.*K-U2.*CM),'fro') % checking derivative of Lagrangian with respect to A is zero or not?

Derivative of Lagrangian with respect to A is not zero? What is wrong?

I asked the correctness of dual of this problem in http://math.stackexchange.com/questions/1083280/is-the-dual-of-this-semi-definite-problem-derived-correctly. But till now, no one answered it. I check it many times. I will appreciate any help. Thanks.

Sorry, this one’s too complicated. I don’t have time to re-derive the dual. But given your error in the previous question, and the fact that CVX was proven correct, I would suggest that the issue is with your dual derivations.

@mcg, Thank you. I updated the question in math.stackexchange with dual derivation of the above problem. Is it possible that CVX(or the underlying solvers) scales some variables, which results in this problem? Or you are completely sure that dual derivation is incorrect?

Obviously there can be bugs. But remember: CVX often converts problems to their dual form before solving them, for efficiency reasons. If CVX’s handling of duals were extremely buggy, that would fail far more often than it does. I’m putting my money on CVX.

So you consider scaling as a bug and CVX isn’t buggy. Thank you