We can encode a qubit in the energy levels of a quantum system. Relaxation and other dissipation processes lead to decay of the fidelity of this stored information. Is it possible to preserve the quantum information for a longer time by introducing additional drives and dissipation? The existence of autonomous quantum error correcting codes answers this question in the positive. Nonetheless, discovering these codes for a real physical system, i.e., finding the encoding and the associated driving fields and bath couplings, remains a challenge that has required intuition and inspiration to overcome. In this work, we develop and demonstrate a computational approach based on adjoint optimization for discovering autonomous quantum error correcting codes given a Hamiltonian description of a physical system. We implement an optimizer that searches for a logical subspace and control parameters to better preserve quantum information. We demonstrate our method on a system of a harmonic oscillator coupled to a lossy qubit, and find that varying the Hamiltonian distance in Fock space—a proxy for the control hardware complexity—leads to discovery of different and new error correcting schemes. We discover what we call the 3 code, realizable with a Hamiltonian distance d=2, and propose a hardware-efficient implementation based on superconducting circuits.1 MoreReceived 11 August 2021Revised 4 December 2021Accepted 7 March 2022DOI:https://doi.org/10.1103/PRXQuantum.3.020302Published by the American Physical Society under the terms of the Creative Commons Attribution 4.0 International license. Further distribution of this work must maintain attribution to the author(s) and the published article's title, journal citation, and DOI.Published by the American Physical SocietyPhysics Subject Headings (PhySH)Research AreasAdiabatic quantum optimizationMachine learningQuantum error correctionQuantum information processing with continuous variablesPhysical SystemsSuperconducting qubitsQuantum Information