Suppose energy $E_1$ is recovered from releasing the compression of the magnets, and energy $E_2$ is expended in raising the chamber to the surface. If $E_1 \ge E_2$ then the perpetual motion machine works.
For simplicity replace the magnets with an ideal spring (ie there are no losses due to hysteresis).
Initially the chamber is at the surface with the spring in its relaxed state. The weight of the chamber is greater than the buoyant force on it so it sinks. As it does so the spring is compressed. The volume of the chamber decreases, so the buoyancy force decreases.
When the chamber reaches depth $h$ the water pressure is $\rho gh$ so the force compressing the spring is $F=\rho ghA$ where $A$ is the cross section area of the chamber. The energy stored in the spring is $E_1=\frac12 Fx=\frac12 \rho ghxA$ where $x$ is the amount by which the spring is compressed at this depth.
The spring is then locked in position, and the chamber is raised back to the surface. The work done to raise the chamber against gravity can be recovered from the work gravity does on the chamber as it is lowered. The net work done in raising the chamber is solely due to the reduced buoyancy force caused by the decrease in volume.
The difference in the buoyancy force is $\Delta B=\rho g \times \text{difference in volume of the chamber}=\rho g xA$ . The overall work done to lower then raise the chamber is therefore $E_2=h\Delta B=2E_1$.
Twice as much work is done raising the chamber against the reduced buoyancy as is recovered from the spring. So the process is guaranteed to lose energy regardless of how efficient it is.
Where did the missing energy go?
The situation is similar to a weight $W$ being attached to a spring hanging vertically. When the weight has been lowered gently to its equilibrium position the spring has extended by $x$. The gravitational PE lost by the weight is $Wx$. The elastic PE gained by the spring is $\frac12 Wx$. We've lost half our GPE!
The explanation is that if the weight had been released suddenly and allowed to fall, the weight would reach the equilibrium position with KE of $\frac12 Wx$ while the spring gains elastic PE of $\frac12 Wx$, giving a total energy of $Wx$, which is exactly the gravitational PE lost at this point. (See Where is the energy lost in a spring?)
In this case the missing energy was taken away by the device (or human hand) which lowered the weight gently, removing the KE it would have gained if it had fallen freely. In the case of the sinking magnetic chamber the KE of the piston was (we must presume) removed ("dissipated") by viscous forces in the water, or by friction between the piston and cylinder.
To see that this is correct, imagine the spring is locked at its relaxed length at the surface before it descends to the required depth. No energy has been lost (dissipated) yet. Now the locking mechanism is released suddenly. What happens? Just like the weight released on the spring, the magnetic spring reacts to the sudden force on it and starts oscillating. At its equilibrium compression the chamber has elastic PE of $E_1$ and also KE of $E_1$, giving it a total energy of $2E_1=E_2$. If this KE could be recovered before the spring is clamped at its equilibrium position, then the overall energy $E_2$ expended in raising the chamber back to the surface would equal the energy $2E_1$ extracted. There would be no overall loss or gain of energy.