Assuming modelB’s loss was calculated without the usage of modelA’s parameters, you won’t be able to directly update modelB using this loss and could instead e.g. copy the gradients from modelB to modelA manually (and update modelA afterwards).
However, you would have to make sure this approach actually makes sense.