
\section{Readout and feedback configurations}
The readout frequency is set to $\omega_{\mathrm{RF}}=\omega_{\mathrm{r}} - \chi$ to maximize the phase difference in cavity transmission between qubit in $\ket{0}$ and $\ket{1}$. The JPA is tuned to $\omega_{\mathrm{RF}}$ by the combination of external flux biasing and a continuous-wave pump tone that bends the JPA resonance, as described in Ref.~\onlinecite{Riste12}. In contrast to this previous work, here we use a single generator for pump, measurement and local oscillator in order to maximize phase stability. A phase shifter on the RF arm is used to maximize the phase-sensitive amplification [Fig.~S3(a)]. Another phase shifter at the output side maximizes the in-phase signal after IQ demodulation. An additional circulator between cavity and JPA is used to further suppress leakage of the pump into the cavity (Fig.~S1).
\begin{figure*}
\includegraphics[width=1.44\columnwidth]{FigS1_Riste_120712}
\caption{Experimental setup. The key components of the feedback loop are highlighted in red. A Tektronix AWG5014 generates modulation envelopes for measurement and deterministic qubit pulses. The readout signal is amplified with a JPA at base temperature, a HEMT (Caltech CITCRYO 1-12) at $3~\mathrm{K}$, and two GaAs FET amplifiers (Miteq AFS3) at room temperature prior to demodulation to baseband ($0~\mathrm{Hz}$ intermediate frequency). The demodulated signal is amplified (Stanford Research Systems SR445A) and then split. One arm is sent through a low-pass filter (Mini-Circuits BLP-5+, DC-$5~\mathrm{MHz}$ passband) to an analog input of an ADwin Gold processor, and the other to the data acquisition card (AlazarTech). The ADwin compares the input voltage to the optimum threshold for discriminating between $\ket{0}$ and $\ket{1}$. Depending on the feedback logic programmed into it, the ADwin sends a trigger to the Tektronix AWG520 when the input is above/below the threshold. The triggered AWG520 produces the modulation envelope for a $\pi$ pulse sent via the input line, closing the feedback loop.}
\end{figure*}

The ADwin samples the readout signal once, at a variable delay following a trigger from an arbitrary waveform generator (Tektronix AWG5014). This delay is adjusted in $100~\mathrm{ns}$ steps to maximize readout contrast between states prepared with and without a $\pi$ pulse on the $0\leftrightarrow1$ transition. For multiple feedback instances, the timing for each measurement is separately optimized. Once these timings are set, a routine (repeated every $\sim5$~min), determines the optimum threshold for digitizing the readout signal. This voltage is then used to assign $H$ or $L$ to the measurement in any feedback cycle. For $\mathrm{Fb}_0~(\mathrm{Fb}_1)$, the ADwin triggers another arbitrary waveform generator  (Tektronix AWG520) to produce a $\pi$ pulse when the outcome is $L~(H)$. Pulse timings and signal delays in the feedback cycle are illustrated in Fig.~S2.


\begin{figure*}
\includegraphics[width=2\columnwidth]{FigS2_Riste_120712}
\caption{Feedback loop latency. The AWG5014 modulates the RF tone to generate a $400~\mathrm{ns}$ measurement pulse reaching the cavity at $t=0$. The black curve is a sketch of the photon population inside the cavity, which reaches $\sim45$ photons at $t=0.4~\mu\mathrm{s}$. We estimate a critical photon number $n_\mathrm{crit}\approx150$ and inverse measurement rate $\Gamma_m^{-1}=26~\mathrm{ns}$ at steady state~\cite{Gambetta06}. The ADwin, triggered by the AWG5014, measures one channel of the output homodyne signal (red: qubit in $\ket{0}$, blue: $\ket{1}$), delayed by $\sim200~\mathrm{ns}$ due to the low pass filter at its input side. After comparison of the measured voltage at $t=0.6~\mu\mathrm{s}$ to the reference threshold, the AWG520 is conditionally triggered at $t=2.54~\mu\mathrm{s}$, resulting in a $\pi$ pulse (Gaussian, $\sigma=6~\mathrm{ns}$, total length $24~\mathrm{ns}$), reaching the cavity at $2.62~\mu\mathrm{s}$. The ADwin acquisition (and the triggered $\pi$ pulse) can be shifted by $\pm0.1~\mu\mathrm{s}$ to maximize readout fidelity. The measurement pulse for another feedback cycle or final readout reaches the cavity at $t=2.8~\mu\mathrm{s}$.}
\end{figure*}

\section{Measurement of the transmon populations}
\begin{figure}
\includegraphics[width=\columnwidth]{FigS3_Riste_120712}
\caption{The two readout configurations employed  and the associated histograms for the three lowest-energy transmon levels. (a) Sketch in phase space of the coherent states corresponding to the first three transmon levels. The amplified quadrature, chosen by tuning the RF-pump phase difference, is either I or $\mathrm{I'}$, giving the histograms in (b) and (c), respectively. (b) Optimum discrimination between $\ket{0}$ and $\ket{1}$. This choice is used in $M_0$ and in all the measurements which are part of a feedback sequence to maximize the single-shot readout fidelity. (b) Readout configuration making $\ket{1}$ and $\ket{2}$ indistinguishable, as their respective coherent states have equal projection onto the $\mathrm{I'}$ axis. This configuration is used in the final measurement of every sequence to accurately extract the level populations, as described in the text.}
\end{figure}
Whereas readout for feedback maximally discriminates between $\ket{0}$ and $\ket{1}$ from single measurements, the final readout, used to quantify the reset error $P_{\mathrm{err}}$, relies on the average of thousands of runs. Due to leakage from the qubit subspace, the output voltage $V_{\mathrm{H}}$ also depends on $P_{\ket{2}}$. The average measurement is related to the populations as~\cite{Bianchetti10}
\begin{figure*}
\includegraphics[width=2\columnwidth]{FigS4_Riste_120712}
\caption{Transmon population dynamics showing residual excitation. Populations (a) $P_{\ket{0}}$, (b) $P_{\ket{1}}$, and (c) $P_{\ket{2}}$ as a function of time following preparation in $\ket{0}$ (red), $\ket{1}$ (blue), and $\ket{2}$ (green). The combined fit of the master equation model to these data gives the transition rates and steady-state populations shown in Fig.~1.}
\end{figure*}
\begin{equation}
\label{eq:readout_2eq}
\avg{V_{\mathrm{H}}} =  \avg{V_{\ket{0}}} P_{\ket{0}} +  \avg{V_{\ket{1}}} P_{\ket{1}} +  \avg{V_{\ket{2}}} P_{\ket{2}},
\end{equation}
 where the $\avg{V_{\ket{i}}}$ are the mean values of the distributions in Fig.~S3. 
When $\avg{V_{\ket{1}}} \neq \avg{V_{\ket{2}}}$, as in Fig.~S3(a), the measurement of $\avg{V_{\mathrm{H}}}$ is not sufficient to extract the three populations. Two possible strategies to obtain two additional equations are: 1) repeating the sequence, but swapping two of the populations prior to measurement 
in order to obtain different $\avg{V'_\mathrm{H}}$, $\avg{V''_\mathrm{H}}$; 2) analyzing the full time-domain response of the cavity~\cite{Bianchetti10}. We use a different approach, taking advantage of the degree of freedom in the relative phase between RF and pump, to extract $P_{\ket{0}}$ with the minimum number of measurements. As shown in Fig.~S3(b), the phase between RF and pump is chosen to maximize overlap between the histograms for $\ket{1}$ and $\ket{2}$. Making $\avg{V_{\ket{1}}}=\avg{V_{\ket{2}}}$, and assuming $\sum_{i=0}^2P_{\ket{i}}=1$ (as justified below), simplifies Eq.~(\ref{eq:readout_2eq}) to
\begin{equation}
\label{eq:readout_1eq}
\avg{V_{\mathrm{H}}} =  P_{\ket{0}} \avg{V_{\ket{0}}} + (1-P_{\ket{0}}) \avg{V_{\ket{1}}},
\end{equation}
with $P_{\ket{0}}$ as the only unknown. To measure $P_{\ket{1}}$, we transfer this population to $\ket{0}$ with a $\pi$ pulse, making $\avg{V_{\mathrm{H}}} = P_{\ket{1}} \avg{V_{\ket{0}}} + (1-P_{\ket{1}}) \avg{V_{\ket{1}}}$. Similarly,
to measure $P_{\ket{2}}$, we transfer this population to $\ket{0}$ with two consecutive $\pi$ pulses, the first on $1\leftrightarrow2$ and the second on $0\leftrightarrow1$. 
The amplitudes $\avg{V_{\ket{0}}}, \avg{V_{\ket{1}}}$ and $\avg{V_{\ket{2}}}$ are calibrated by preparing the corresponding states. To do this, we initialize to $\ket{0}$ as best we can ($P_{\ket{0}}=99.3\%$) by performing a measurement (used for postselection~\cite{Riste12,Johnson12}) and then applying the required $\pi$ pulses. Values for $\avg{V_{\ket{0}}}$, $\avg{V_{\ket{1}}}$ and $\avg{V_{\ket{2}}}$ are estimated from $\sim10\,000$ shots each. As shown in Fig.~S3(b), $\avg{V_{\ket{1}}}$ and $\avg{V_{\ket{2}}}$ are matched to better than $1\%$. The sum of the extracted populations shown in Figs.~S4(a-b) averages to $99.7\%$ and $99.5\%$ over the temporal evolutions starting from $\ket{0}$ and $\ket{1}$, respectively. For initial state $\ket{2}$ [Fig.~S4(c)], leakage to the third excited state is relevant under $50~\mu\mathrm{s}$. In most cases, however, $P_{\ket{2}}$ is limited to a few percent, justifying the truncation of the model to the lowest three transmon levels. 



\section{Model for measurement and feedback}
The readout errors $\epsilon^M_{i}$, indicating the probability of a wrong result $M$ for the pre-measurement state $\ket{i}$, are extracted from the histograms in Figs.~2 and S3, using the result of the fit in Fig.~S4 to account for the transmon equilibration between $M_0$ and $M_1$~\cite{Riste12}. The data yield the values $\epsilon_0^L=0.3\%, \epsilon_1^H=0.7\%$. By analogy with Ref.~\onlinecite{Riste12}, we approximate the errors with $\epsilon^L_0\sim p^L_{00}$ and $\epsilon^H_1\sim p^H_{01}$ (notation defined in the main text). Combining these with the best-fit values for Fig.~S3, $p^L_{00}+p^H_{10} = 0.4\%$ and $p^H_{11}+p^L_{01}=1.4\%$, we estimate the remaining errors $p^H_{10}=0.1\%$, $p^L_{01}=1.0\%$.

\begin{figure}
\includegraphics[width=\columnwidth]{FigS5_Riste_120712}
\caption{Fast reset using multiple instances of $\mathrm{Fb}_0$. The measurement sequence is illustrated in Fig.~4, with (a) $\theta = \pi$, and (b) $\theta=0$. At any $\tau_{\mathrm{init}}$ $P_{\mathrm{err}}$ decreases by a factor $\sim 3$ with one instance of $\mathrm{Fb}_0$ compared to passive initialization (Fig.~4). Two or three iterations add only a modest improvement. An additional decrease in error by a factor $\sim 2$ at short $\tau_{\mathrm{init}}$ is obtained with a $\pi$ pulse on the $1\leftrightarrow2$ transition preceding the third instance (purple). This pulse corrects for the leakage of population to $\ket{2}$, occurring for short $\tau_{\mathrm{init}}$. The last feedback round brings this population back to $\ket{0}$. Solid curves are given by the model, using the parameters extracted from Figs.~1 and 2 and assuming perfect pulses.}
\end{figure}

\section{Comparison of feedback protocols}
A double round of feedback tends to equalize the initialization error for different input states (Figs.~3 and S5). Augmenting the protocol to three or more rounds only marginally affects the residual difference, which is mainly due to leakage into $\ket{2}$. When a $\pi$ pulse is repeatedly applied on the $0\leftrightarrow1$ transition [Figs.~3(a) and S5(a)], this leakage depends on the fraction of time that $\ket{1}$ is populated, which increases at shorter $\tau_{\mathrm{init}}$. Therefore, $P_{\ket{2}}$ can exceed its steady-state value, leading to increased $P_{\mathrm{err}}$. We address this problem by inverting the populations in $\ket{1}$ and $\ket{2}$ after two iterations of $\mathrm{Fb}_0$. This brings the population, previously in $\ket{2}$, within reach of a third instance of $\mathrm{Fb}_0$. This strategy is only effective when $P_{\ket{2}}>P_{\ket{1}}$, explaining why a residual error of $\sim3\%$ is observed at long $\tau_{\mathrm{init}}$, when, after two rounds of feedback, $P_{\ket{1}}\approxP_{\ket{2}}$. Similarly, the repeated initialization in $\ket{0}$ without periodically applying a $\pi$ pulse [Figs.~4(b) and S5(b)] limits the escape probability to the excited states, as evident from the reduced error at short $\tau_{\mathrm{init}}$.

