Imperfections in integrated photonics manufacturing have a detrimental effect on the maximal achievable visibility in interferometric architectures. These limits have profound implications for further photonics technological developments and in particular for quantum photonics technologies. Active optimisation approaches, together with reconfigurable photonics, have been proposed as a solution to overcome this. In this paper, we demonstrate an ultra-high (>60 dB) extinction ratio in a silicon photonic device consisting of cascaded Mach-Zehnder interferometers, in which additional interferometers function as variable beamsplitters. The imperfections of fabricated beamsplitters are compensated using an automated progressive optimization algorithm with no requirement for pre-calibration. This work shows the possibility of integrating and accurately controlling linear-optical components for large-scale quantum information processing and other applications.