  We propose a novel optimization scheme designed to find optimally correctable
subspace codes for a known quantum noise channel. To each candidate subspace
code we first associate a universal recovery map, as if the code was perfectly
correctable, and aim to maximize a performance functional that combines a
modified channel fidelity with a tuneable regularization term that promotes
simpler codes. With this choice optimization is performed only over the set of
codes, and not over the set of recovery operators. The set of codes of fixed
dimensions is parametrized as the complex-valued Stiefel manifold of the same
dimension: the resulting non-convex optimization problem is then solved by
gradient-based local algorithms. When perfectly correctable codes cannot be
found, a second optimization routine is run on the recovery Kraus map, also
parametrized in a suitable Stiefel manifold via Stinespring representation. To
test the approach, correctable codes are sought in different scenarios and
compared to existing ones: three qubits subjected to bit-flip errors (single
and correlated), four qubits undergoing local amplitude damping and five qubits
subjected to local depolarizing channels. Approximate codes are found and
tested for the previous examples as well pure non-Markovian dephasing noise
acting on a $7/2$ spin, induced by a $1/2$ spin bath, and the noise of the
first three qubits of IBM's \texttt{ibm\_kyoto} quantum computer. The fidelity
results are competitive with existing iterative optimization algorithms, with
respect to which we maintain a strong computational advantage, while obtaining
simpler codes.
