You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm currently attempting some circuit modelling and was looking at taking gradients through circuit models using SAX. I've found that the default KLU backend raises an error when computing forward gradients, or gives an incorrect result for reverse differentiation, while the FG backend works correctly in both cases. I think these issues may be coming from the klujax.solve and/or klujax.coo_mul_vec functions based on some preliminary testing of klujax.
Here is a minimal example using a single coupler as a circuit and measuring the power on the output ports, looking to determine how output power changes with the coupling parameter:
importsaxfromsax.modelsimportcouplerimportjaximportjax.numpyasjnpnetlist= {
"instances": {"coupler0": "coupler"},
"connections": {},
"ports": {"in0": "coupler0,in0", "in1": "coupler0,in1", "out0": "coupler0,out0", "out1": "coupler0,out1"}
}
models= {"coupler": coupler}
circuit, _=sax.circuit(netlist, models, backend='klu', return_type='sdense')
defmodel(coupling: float=0.5) ->jax.Array:
s, ports=circuit(coupling=coupling) # run the circuit models_fwd=s[ports['in0'], [ports['out0'], ports['out1']]] # extract the forward scattering parametersreturnjnp.abs(s_fwd) **2# report the power transmission
Hi, I'm currently attempting some circuit modelling and was looking at taking gradients through circuit models using SAX. I've found that the default KLU backend raises an error when computing forward gradients, or gives an incorrect result for reverse differentiation, while the FG backend works correctly in both cases. I think these issues may be coming from the
klujax.solve
and/orklujax.coo_mul_vec
functions based on some preliminary testing ofklujax
.Here is a minimal example using a single coupler as a circuit and measuring the power on the output ports, looking to determine how output power changes with the coupling parameter:
With
backend='fg'
:With
backend='klu'
:Do you know if there is a solution for this?
The text was updated successfully, but these errors were encountered: