Room-temperature photonic logical qubits via second-order nonlinearities

Recent progress in nonlinear optical materials and microresonators has brought quantum computing with bulk optical nonlinearities into the realm of possibility. This platform is of great interest, not only because photonics is an obvious choice for quantum networks, but also as a promising route to quantum information processing at room temperature. We propose an approach for reprogrammable room-temperature photonic quantum logic that significantly simplifies the realization of various quantum circuits, and in particular, of error correction. The key element is the programmable photonic multi-mode resonator that implements reprogrammable bosonic quantum logic gates, while using only the bulk χ(2) nonlinear susceptibility. We theoretically demonstrate that just two of these elements suffice for a complete, compact error-correction circuit on a bosonic code, without the need for measurement or feed-forward control. Encoding and logical operations on the code are also easily achieved with these reprogrammable quantum photonic processors. An extrapolation of current progress in nonlinear optical materials and photonic circuits indicates that such circuitry should be achievable within the next decade. Photonic quantum computation via bulk optical nonlinearities presents challenges, due to the weakness of nonlinearity and the difficulties in doing without feed-forward control. Here, the authors propose an all-unitary approach that is based on a triply-resonant cavity with a time-dependent drive.

A ny attempt to build coherent quantum hardware is met with the relentless deleterious influence of the environment. To combat it, all of today's nascent quantum computers must be cooled to cryogenic temperatures. Superconducting quantum circuits require dilution refrigerators to eliminate thermal noise 1,2 , and ion trap processors are cooled to <10 K to reduce collisions with stray gas molecules 3 . This need for cooling poses a problem for many potential applications of quantum information processing; it greatly reduces the prospects for portable devices, and significantly impacts the cost and practicality of large-scale deployment as repeaters and routers for communication networks. Even optical circuits that employ single-site defects (e.g., color centers or rare-earth impurities) require cryogenic temperatures to reduce thermal line broadening [4][5][6] . So too do linear optics schemes that employ detectors as their sole nonlinear element (in this case to avoid the overhead incurred by inefficient detection) 7,8 .
At present, there are only a few platforms that appear to have the potential for quantum processing at both room temperature and pressure [9][10][11][12] . We explore photonic circuits that employ bulk optical nonlinearities as their nonlinear element is a particularly promising one. Bulk nonlinear elements not only do not suffer from thermal excitation, but due to their size they are less affected by thermal broadening. Until recently, the possibility of realizing quantum devices with bulk nonlinearities seemed remote, due both to the weakness of these nonlinearities and the problem of wave-packet distortion [13][14][15][16][17][18] . Substantial progress in the effective strength of the material nonlinearities, the introduction of ultraconfining cavities [19][20][21] , and a relatively simple solution to wavepacket distortions [22][23][24] have changed that outlook.
Achieving the physical technology to implement nonlinear photonic quantum circuits is not the only challenge to realizing room-temperature quantum logic. For practicality, one must implement this logic using the strongest available nonlinearity, the leading-order χ (2) nonlinear susceptibility, and for efficient room-temperature operation the logic and error correction circuits should avoid measurements or feed-forward control. Two basic approaches to information processing with photons are possible. The first is the use of single-or dual-rail encoding in which each mode contains no more than one photon 25 . While this has the advantage that all circuit constructions from the welldeveloped qubit model can be employed, this leads to complex circuits even for correcting the loss of a single photon. The smallest code for this purpose uses five modes (ten for dual-rail encoding) 26,27 . While there is little work on minimal circuits for correcting the five-qubit code, from circuits for the seven-qubit Steane code, we estimate that it requires a least nine additional modes and >30 CNOT gates. The alternative is to use bosonic codes that employ multiple photons per mode, but in this case it is far from obvious what gates and circuits are required to implement the error correction, let alone how to realize these gates with a χ (2) interaction. While explicit error correction procedures for bosonic codes have been elucidated [28][29][30][31][32] , they all involve non-demolition or photon-number-resolving measurements. It is not yet known how to construct the unitary multiphoton operations required to replace such measurement using only a χ (2) nonlinearity, or the complexity of doing so. The only unitary circuit that has been explicitly constructed to date to correct a bosonic code is in the form of a 40-layer neural network using an idealized χ (3) medium 33 .
Here, we propose an approach for implementing all-unitary, and thus room-temperature, quantum logic on multimode multiphoton states using only a fixed χ (2) nonlinearity. This paradigm, which employs as its basic module a single triply-resonant cavity with a time-dependent drive, significantly reduces the complexity of the physical circuits required to implement multiphoton quantum logic in general, and error correction in particular. The joint operation performed on the three modes by the module is controlled by the time-dependent drive. In this way, the module is able to perform a wide range of three-mode multiphoton gates. We demonstrate the power of this approach by explicitly constructing a measurement-free error-correcting circuit for a two-mode bosonic code. This circuit requires just two of our three-mode modules, along with some controllable linear elements. Our compact unitary circuits do not employ any measurements or feed-forward control, which makes them particularly useful for fast quantum routers and repeaters. However, measurements will certainly be required to read out a message or the results of a computation. Fortunately, it is straightforward to use unitary circuits in general, and our processor in particular, to enable high-fidelity measurements at room temperature, even when only inefficient detectors are available. To do so, it is enough to use a unitary circuit to map a single photon to a sufficiently large number of photons that can then be detected. This amplification can be implemented rapidly using a doubling process. First a χ (2) nonlinearity is used to convert one photon in one mode 1 to two photons in a second mode via downconversion. Second, a frequency conversion process (which employs a χ (2) and a classical pump) is then used to transfer each of the two photons back to the first mode. Repeating this photondoubling cycle provides exponentially fast amplification. Since measurements are only to be used at the end of a computation, the additional overhead for amplification remains small. Thus, while we do not analyze this measurement method in detail here, it is clear that the lack of efficient photon detectors is not an obstacle to room-temperature quantum information processing.
In the next section, we describe the control Hamiltonian realized by the driven triply-resonant cavity that forms our basic processing module and give examples of important gates that can be implemented by the module. Then we show how a full error correction process can be built from a small number of these multiphoton gates. Lastly, we discuss the materials science and fabrication challenges that must be addressed, in order to realize our loss-correction circuit. By extrapolating the rate of progress in these areas over the past decade, we estimate a timeline for demonstrating this circuit.

Results
A controllable three-mode cavity. We consider three resonant modes of a cavity in a χ (2) medium, with respective mode operatorsâ,b, andĉ, and frequencies ω a , ω b , and ω c . We neglect any dissipative dynamics until later sections, where we discuss hardware implementations. The cavity is driven by a coherent classical pump with frequency ω p . We depict it in Fig. 1, in which the pump may be a microwave frequency electric field or an optical drive. By choosing the frequencies to satisfy ð1Þ the χ (2) medium couples the modes via the Hamiltonian in which χ is the coupling rate of the χ (2) nonlinearity, g(t) is the coherent amplitude of the classical pump, and we have moved to the rotating frame of the oscillators. Since Schrödinger's equation contains H/ℏ, it is the rates χ and g(t) that determine the dynamics. If we measure time in units of 1/χ then all rates are divided by χ, and the dynamics is determined by in which we have defined p(t) = g(t)/χ. Thus up to a scaling of time, the dynamics is entirely determined by the rate parameter p (t). We will not have to introduce any additional rate parameters (and thus any additional timescales) until we consider loss in the section on hardware considerations. In that section, we will express our rate parameters in terms of the physical parameters of realistic devices. Note that the second term inĤ nl ðtÞ, which is controlled via the amplitude of the pump, is merely a linear coupling between modesb andĉ. This interaction cannot by itself generate a universal set of quantum gates 34,35 . It turns out, however, that it can do so when combined with the time-independent frequencydoubling interaction.
We denote the number of photons in the three modes respectively by n a , n b , and n c , and the corresponding operators for the photon number byn a ,n b , andn c . Since the Hamiltonian commutes with 2n a þn b þn c , the value of that observable is preserved. The Hamiltonian cannot, therefore, mix subspaces defined by different integer values of 2n a + n b + n c . Nevertheless, it does provide complete control within each subspace by virtue of the fact that the repeated commutators ofâb y2 andb yĉ generate a complete Lie algebra for all such subspaces 28,[36][37][38] . It is this fact that provides the power of our processing unit.
In general, to implement quantum gates between the three modes, we will need to generate a set of distinct evolutions, one for each of the 2n a þn b þn c ¼ const subspaces. We can do that with a single control pulse, as for each subspace, there are many choices for p(t) that generate the same unitary operation. We can use numerical search methods to find a control function p(t) that simultaneously generates the required evolution for each of the set of subspaces. Naturally, we wish to find the control that implements a given gate in the shortest time, a challenge solved as described below.
Lastly, the modes of this quantum processor will need to be actively coupled to the waveguides that carry the quantum states to be processed. Otherwise, the process of capturing the content of the waveguides will be too slow due to the necessarily high quality factor of the modes of the processor. To actively couple the cavity modes to the waveguides, we envision using the method given in Heuck et al. 23 .
Compiling unitary operations. To find the control pulse p(t) required to implement a given unitary operation, we employ numerical search methods, an approach often referred to as optimal control [39][40][41] . We introduce a parameterization for p(t) as a piecewise-constant signal in which the duration of each interval is variable. This parameterization is essential because the alwayson frequency-doubling component of the Hamiltonian necessitates optimizing the length of the pulse. In order to avoid unphysical pulses, we constrain both the duration and amplitude of each interval by the use of sigmoid functions. The full expression for the resulting unitary operation iŝ and v = {X l , P l , T l : l = 1, …, N} is the set of parameters that defines the pulse. The parameters fX l : X l 2 Rg and fP l : P l 2 Rg are related to the quadrature of the pulse, which is constrained to the interval [−1, 1] by arctan, while the fT l : T l 2 Rg are related to the duration of each segment, which is constrained to the interval [0, Δτ]. We fix the number of piecewise-constant intervals, s, as well as the relative unitless time scale Δτ. Consistently good performance is obtained even with s < 60. This permits the use of standard automatic differentiation tools, without the need for approximations, such as GRAPE 40 . Our parameterization also has the advantage that it does not allow for pathological pulses. Once we have obtained a piecewise constant control function for a given gate, we use GRAPE and standard regularization techniques to smooth out the pulse, ensuring it has both reasonable bandwidth and power. Throughout the optimization, the robustness of the control to calibration errors is verified. The time scale Δτ is shortened until a threshhold is reached at which the control pulse is no longer robust. The above approach to generating control functions, together with a number of symbolic optimizations, will be presented in detail in a related tutorial 39 .
Examples of programmable gates. Through the use of our implicitly constrained optimal control method, we can perform with high fidelity any gate that keeps 2n a + n b + n c constant. If the length of the control pulse is unconstrained, and dissipation is neglected, we can achieve fidelities arbitrary close to unity. For gates reported here, we constrain the duration of the control pulses as much as possible before reaching unitary fidelities <0.999. In later sections considering hardware implementations, we also describe the effects of dissipation. Here, we describe a number of important unitary operations that fulfill that Fig. 1 The triply-resonant nonlinear cavity. The χ (2) medium enables the joint control of three modes. We denote the mode operators respectively byâ,b, andĉ. The χ (2) medium enables frequency doubling fromb toâ, and a three-way interaction between modesb,ĉ, and the control field. The control field is either a a classical microwave drive, E p (t), or b a classical optical drive of envelope p(t). This three-way interaction is effectively a linear interaction between modesb andĉ that is controlled by the classical drive. The combination of the fixed frequency-doubling interaction and the controlled linear interaction allows extensive control of the joint nonlinear evolution. This evolution conserves the quantity 2n a + n b + n c , in which n a , n b , and n c are the occupation numbers of the respective modes. We also depict the relative values of the frequencies of the three modes; in a, the frequencies of modesb andĉ are separated by the much smaller frequency of the microwave drive. constraint, some of which are also depicted in Fig. 2. More general unitary operations can be performed by reshuffling the modes of the three-mode processors, as seen in later sections. Given the long cavity lifetimes requires for these operations, reshuffling necessitates rapid catch, and release of photons from and into the connected waveguides, e.g., by using active control as done in Heuck et al. 23 .
Throughout the following paragraphs, we will use the notation n a n b n c j i to denote a Fock state with n a , n b , and n c photons in modesâ,b, andĉ, respectively.
We begin with the Toffoli Gate, which is a three-qubit non-Clifford gate, distinguished by the fact that together with just the single-qubit Hadamard gate it enables universal quantum circuits 42,43 . Of particular relevance for our purposes is the fact that it usually requires six two-qubit CNOT gates to implement 44,45 , while our realization requires only a single application of the three-mode processor. We realize the gate in the Hadamard basis (i.e., our gate is a phase gate with two control qubits) for photonic qubits encoded in a single-or dual-rail configuration. In this basis, the Toffoli unitary maps all joint Fock states to themselves except for the state 111 j i to which it applies a π phase.
We also define a conditional routing gate as one that swaps the state of two modes depending on the state of a third mode. This class of gates is useful for breaking down conditional multi-qudit operations into smaller units. We first route the target mode to a particular waveguide, based on the state of the control mode, and we perform the appropriate single-mode quantum operation in the new physical location of the target mode. Such routing is indispensable, if our goal is to avoid measurements in error-correcting circuits, as measurements usually require hardware at cryogenic temperatures. Typically, a non-demolition measurement is performed by entangling the required information with an ancilla, and performing a demolition measurement on the ancilla. The result, a classical bit, is then fed forward through a classical computer that decides what quantum operation to perform next. We avoid the measurement and classical decisions through coherent quantum feedback 46,47 , where we simply perform a multimode quantum gate conditioned on the ancilla. The realization for the routing gate suggested below is what we use in our bosonic error-correcting circuit, but other setups are feasible as well. Below n a n b n c j idenotes a Fock state with n a , n b , and n c photons in modesâ,b, andĉ, respectively. Theĉ mode is the control, theb mode is the input, andâ andb are the possible outputs: When used in the error-correcting circuits described in later sections, modeĉ will contain an ancillary photon on which routing will be conditioned, while modeb will contain one of the Fig. 2 The control pulses implementing the three gates that are used to build our error correction circuit. The top row shows the real and imaginary parts of the control pulses for each gate. The following rows show how the populations of the modes evolve under each gate for a given initial state. The optimizer produces pulses p(t) such that each of the desired transformations leads to constructive interference at the exact same time. Shorter pulses are possible, at the expense of higher power and bandwidth requirements 39 , up to a point at which the pulse is too short to perform even a single complete oscillation in a subspace defined by an integer value of 2n a + n b + n c . ARTICLE NATURE COMMUNICATIONS | https://doi.org/10.1038/s41467-020-20417-4 two modes of our multimode bosonic code. A second processor will be used for other modes.
Focusing further on the error-correcting functionality, we need a gate that can correct for photon loss in a codeword. For the code we employ, we require the gate to preserve the states 001 j i, 021 j i, and 041 j i, and accomplish the mapping This operation is necessary for reverting photon loss in the code mode stored inb, while storing information about the occurrence of that loss in modeĉ. Again, we will need two threemode processors, each acting on one of the modes making up our error-correcting code. Each of the physical modes of the code will be stored in the correspondingb oscillators.
To complete our error correction circuit, we use a gate that entangles two modes. We require this operation because one of the code words is an entangled state, and the loss of a photon breaks this entanglement. This gate provides the mapping 011 j i7 ! 011 j i; ð15Þ This gate is also a symmetrizing operation for the state of the modesb andĉ. It is these two oscillatorsb andĉ that will contain the two modes of our error-correcting code. The above gates are only a few of the many operations that the triply-resonant cavity processor can perform. Among these gates are those important for the processing of unprotected singlephoton states, and operations that enable unitary modification and number-resolved measurements on modes with more than one photons, including bosonic codes. Importantly, these operations are performed with a single use of the triplyresonant cavity, while otherwise they would require complete circuits with multiple discrete operations. This leads to drastically simpler overall circuits, at the expense of requiring this more sophisticated and difficult to fabricate triply-resonant optical resonator.
Measurement-free error correction. We demonstrate the versatility of our control protocol by constructing an errorcorrecting circuit around the three-mode processor. The circuit we obtain is not only simple and short, but it also does not require any measurement operations or classical feed-forward control.
We choose the following code, encoding a single qubit in two separate (spatial) bosonic modes, whose logical states are given by This two-mode code allows correction for the loss of a single photon from either mode. For a channel that has a 10% probability of a single-photon loss for each mode this implies an 81% chance of transmission without error, 18% chance of transmission with a correctable error, and a 1% chance of transmission with an uncorrectable error. We choose this code because it is possible to perform the correction process with operations that conserve the quantity 2n a + n b + n c , so long as one is judicious in choosing these operations. We must first consider the effect of a photon loss on the code. The loss of a photon on the first mode is described by the action ofâÎ. This transforms the initial code state C Similarly, the loss of a photon from the second mode produces the error state E 2 j i ¼ α 21 j i þ β 03 j i. For each of these two errors, we need to perform a different correction procedure. Typically, this is achieved by a non-demolition measurement that projects the state of the system onto either the logical subspace or one of the error subspaces, followed by a unitary correction operation conditioned on the measurement result. We sidestep these requirements by using coherent control. We employ two quantum ancillas, initialized to contain single photons, on which routing gates will be conditioned. Thus, our correction procedure involves the following steps. First, we put the information about the presence of an error in the ancillas by using two conditional pumping gates acting in parallel (the code modes are each placed in ab mode, while the ancillary photons are in the correspondinĝ c modes), resulting in the following transformation of the overall ancillas-code state: where F 1 j i ¼ α 22 j i þ β 40 j i and F 2 j i ¼ α 22 j i þ β 04 j i. The feedforward solution would have measured the ancillas and performed different operations depending on the measurement, but as already mentioned that would be slow and require additional cooled hardware and classical decision circuitry. Instead, we perform the following unitary operation (as before, the left multiplier in the tensor product c 1 c 2 j idenotes the content of the ancillaryĉ modes of each of the two processors, and C j i Fig. 3 Our minimal architecture for error correction of bosonic codes, readily expandable to larger tasks. The circuit depicted can be used to correct a single-photon loss using a two-mode bosonic code. The circuit consists of two cavity processors, which for the most part process each mode of the code separately, and a small network of reprogrammable beam splitters and delay lines. These are used to reroute states between the modes of processors as necessary. Each cavity processor is also capable of performing many multi-qubit gates for single-and dual-rail encoded qubits, as well as preparing and manipulating higher-number Fock states. The network of programmable beam splitters between the processors and the delay lines can also be expanded to a fully connected network, enabling universal rerouting between the three modes of each processor for generalpurpose quantum computation. The programmable beam splitters can be implemented as Mach-Zehnder interferometers (as shown in the inset) with two 50/50 beam splitters and a programmable delay (the orange medium in the diagram). Classical electronics will be necessary to ensure the pacing of various operations in this device, but no feedback or decision circuitry is necessary, as the approach is measurement free. denotes the two modes of the error-correcting code, stored in thê b oscillators of the two processor): Without the ancillas, this operation would be impossible as it would break the bijectivity of the unitary operator by mapping many states to one. The conditional routing gates are crucial for the performance of this operation-depending on the ancillas, they route the modes containing the code to different spatial modes that perform F 1 j i7 ! C j i and F 2 j i7 ! C j i independently and in parallel. The conditional routing gates then ensure that all three paths end up in the same spatial modes at the end of the circuit. The error-correcting circuit can be seen in Fig. 3 as a suggested physical layout, and in Fig. 4 as a sequence of abstract gates.
Encoding operation. Encoding a qubit in the two-mode code is particularly simple using the three-mode processor. To do so we have to perform the operation 00 j i7 ! 22 j i; ð25Þ Given that we already have access to the entangling gate, encoding can be done by putting the unprotected photonic qubit in cavityĉ and putting ancilla photons in cavitiesâ andb. Then, we perform the partial encoding gate thus mapping the state α 1 j i þ β 0 j i inĉ to the precursor of the two-mode code α 11 j i þ β 20 j i inâ andb. As before, here n a n b n c j i denotes a Fock state with n a , n b , and n c photons the modesâ,b, andĉ of a single processor. Turning this into the complete code state requires a simple application of the entangling operation already discussed above. These two operations preserve the constant of motion 2n a þn b þn c and as such can Fig. 4 The error-correcting circuit, unrolled in time. The horizontal axis represents the flow of time, depicting how a pair of triply-resonant cavities is being used. This circuit would be executed on the hardware depicted in Fig. 3. The main drawing is the sequence of operations that we need to perform in parallel in the two triply-resonant cavities, in order to perform the error correction. After placing the code and ancilla modes in the appropriate cavity modes, we accomplish the initial pumping and routing gates. After that, we need to shuffle the ancillary modes by releasing them in the appropriate waveguides. The spatial modes into which the code states are moved depend on the state of the ancillas, thanks to the conditional routing gates. As the ancillas contain information about the presence of photon-loss errors, this lets us perform operations conditioned on the loss of a photon, by performing the two conditional branches in parallel in different physical locations of the circuit. The conditional routing gates then act in reverse, ensuring that all spatial modes end in the same location, without breaking the bijectivity required for any quantum circuit. The various spatial modes employed can be seen in the bottom insets of the figure. Supplementary Figure 1 provides a more detailed rendition. Importantly, as seen in Fig. 3, we do not need 12 triply-resonant cavities as depicted above, rather only 2 cavities with a network of waveguides and programmable beam splitters 72 that can route the spatial modes as necessary, so that each cavity can be used repeatedly. The gate pictographs are taken from the Font Awesome icon set. be compiled to a single control pulse performed in a single triplyresonant cavity.
Two-qubit logical operations. Single-qubit rotations in the logical space of the two-mode code can be realized by using our threemode processors, as such rotations do preserve 2n a + n b + n c . Moreover, two-qubit logical operations can also be performed. For instance, consider a CPHASE gate, which together with the singlequbit rotations form a universal set. We need to perform the operation while mapping all other combinations of 22 j i; 40 j iþ 04 j i ffiffi 2 p n o 2 to themselves. Our three-mode processor can perform this operation by acting on just two of the four modes making up the two logical qubits. If we index each mode as, e.g., j2 i 2 j i j2 k 2 l i, we need to act only on modes j and k, by first transferring them to modes b and c of the cavity, and designing a pulse to perform the operation while mapping all of 000 j i, 002 j i, 020 j i, 004 j i, 040 j i, 024 j i, 042 j i, and 044 j i to themselves. The overall CPHASE operation on the four physical modes forming the two logical qubits takes the form, where the underlined modes are the ones that are manipulated inside of a three-mode processor. Notice that a phase is gained only in the first row, where both of the modes in the processor (the underlined modes) have two photons. Such an operation can be performed directly by our processors or, if shorter and simpler control pulses are desired, by first using the χ (2) interaction to upconvert them to lower photon numbers.
Comparison with other approaches. Comparisons with other codes and types of hardware require care because the various systems have significant differences. Nevertheless, we elucidate how our control protocol substantially reduces the depth of a typical circuit and removes the need for entire classes of expensive operations. As discussed in the introduction, error correction procedures have been proposed for bosonic codes, but these require non-demolition or photon-numberresolving measurements, and it has not yet been described how such measurements can be replaced by unitary operations generated by a χ (2) nonlinearity. We can however, compare our circuit to the explicit correction circuit presented in Steinbrecher et al. 33 . One way to compare the efficiency of circuits is to examine how long each takes relative to the characteristic unit of time for the given hardware. The circuit we have constructed above requires six gates, for a total of 40 units of time (relative to the χ (2) coupling strength), and four transfers in and out of cavities. The correction circuit employing the quantum optical neural network (QONN) architecture 33 , which is the closest analog of our hardware, requires 40 layers, resulting also in 40 units of time, but since it uses a χ (3) rather than a χ (2) medium, the nonlinearity is significantly weaker, so that the circuit takes longer in real time. Furthermore, the QONN circuit requires 40 transfers in and out of the nonlinear cavities (one for each layer), ten times more than our architecture.
One can instead implement photonic quantum logic by using only the vacuum and one-photon Fock states to encode qubits (i.e., a single-or dual-rail encoding). The smallest errorcorrecting code in this setting requires five physical qubits 26 . The logic required to determine the error syndrome for this code requires 16 CNOT gates and 4 auxiliary qubits 27 . The auxiliary qubits can either be measured, in which case the error can be determined using a classical computer, or a unitary circuit could process the auxiliary qubits and perform the correction [48][49][50][51][52] . For each of the 16 different values of the four-bit syndrome, a unitary correction circuit would need to perform a different correction operation. This requires quite a large number of ancillas and CNOT gates, as discussed in the introduction. Our roomtemperature design thus represents a dramatic reduction in circuit size and duration. We also emphasize that using allunitary processes, which is the approach we take here, provides a practical advantage; doing so avoids the need to introduce additional amplification and classical feedback circuitry.
Competing with "active" gate-based approaches to measurement-fee error correction, is the use of continuous autonomous QEC [53][54][55][56][57] . In that family of protocols, one needs to design an exotic dissipator, usually through reservoir engineering, which provides an irreversible evolution from the error-space back the code space.
Hardware prospects. We will introduce a less abstract model of our triply-resonant cavity design, in order to better describe the materials science and fabrication challenges it faces. This model also lets us give physical values for the unitless durations we have found above for our control pulses. We will start by describing the physical realization for theâb y2 and pðtÞb yĉ terms in the Hamiltonian. Naturally, these terms requires the presence of eigenmodesâ,b, andĉ. The corresponding field operators would be (e.g., for theâ mode) where we used the magnetic field and the electric displacement in order to keep the quantization consistent in the nonlinear regime [58][59][60] . The b(r) and d(r) eigenmodes can be computed from classical electromagnetism and are normalized to R μ À1 0 jbj 2 dr ¼ 1 and R ε À1 0 n À2 jdj 2 dr ¼ 1. The overall Hamiltonian of the system will bê where n is the index of refraction (consult 60 for its complete treatment as a tensor with dispersion). The field operators are the sum of field operators for the modesâ,b, andĉ, as well as the field from the classical laser pulse p(t). The first two terms from the Hamiltonian simply give us the harmonic oscillator terms, which we eliminate by moving to the corresponding rotating reference frames. The last term provides the nonlinear interactions in which we are interested. For simplicity, we first consider the undriven case, i.e., p(t) = 0. The driven case is discussed in Supplementary Note 3. Expanding the nonlinear term and eliminating the nonresonant terms leaves us witĥ where ∫ nl denotes integration only over the nonlinear medium and i, j, and k denote the appropriate field components to integrate, depending on the nonlinear material being employed. Thus, V shg is the mode volume considered in second-harmonic generation (SHG) experiments. For simplicity, we are not acknowledging frequency and space dependencies in the refractive index n, and we are not specifying the components of the χ (2) tensor being employed. This does not change the result we are pursuing. The coupling rate in this nonlinear Hamiltonian imposes the units of time for the control pulses described in the previous section. This characteristic time needs to be compared to the cavity lifetimes, typically expressed through the Q factor as τ ¼ 2Q ω a . This lets us introduce the following figure of merit for the characteristic number of operations before the environment destroys our quantum state Considering some recent SHG on-chip experiments (a Q~10 7 in refs. 61,62 and a V shg $ 800 μm 3 $ 2000 λ 3 n 3 with a 70 μm-radius micro-ring in refs. 63,64 , at λ a ≈ 750 nm) in a typical nonlinear optics material like lithium niobate (χ ð2Þ $ 31 pm V ), we obtain values N~0.03, which is still too low for practical use. With Q factors and mode overlaps in SHG experiments following a Moore's law (the recent progress is explored in Supplementary Note 4) and new designs lowering mode volumes by orders of magnitude [19][20][21]65 , N-the number of elementary quantum operations within the cavity lifetime-could very well grow by orders of magnitude and reach tens to hundreds over the next decade. N is related to a typical figure of merit in SHG experiments-the conversion efficiency 66 which has seen impressive improvements in the last decade (see Supplementary Note 4). With a Q~2 × 10 8 , which is achievable in principle 67 , a mode volume of V $ 10 À3 λ 3 n 3 , (see refs. 20,68 for progress in mode confinement), and χ ð2Þ $ 100 pm V , which is between the values for lithium niobate and gallium arsenide, we achieve N~2000 which is enough for error correction. Moreover, new fabrication techniques for thin-film materials enable much stronger effective nonlinearities than what has otherwise been achieved on-chip. While such techniques have not been explored extensively in the optical regime, these results are an encouraging indication that similar progress may well be possible for nonlinear optical materials.
To explore how such future hardware may perform, we compare the lifetime of an encoded (protected) photonic qubit to an unprotected single-rail qubit living in the same hardware. The time scale will be set by the Q factor of the cavities under consideration; however, in order to present physical values for the parameters we will set Q~2 × 10 8 at λ a~7 50 nm, which is well within the thermorefractive theoretical limit 67 . In Fig. 5, we compare the performance of our error-correcting protocol to that of an unprotected single-rail qubit, and see that the error-correcting threshold is N~2000, a very demanding value which we are nonetheless optimistic about given the experimental results cited earlier. Typically for non-asymptotic codes, to achieve fault tolerance this lower-level code will have to be concatenated with an asymptotically growing stabilizer code, akin to the surface code or quantum LDPC codes and one of the many techniques for achieving non-Clifford gates (e.g., through magic states) will have to be employed. The versatility of our control protocol provides for a system agnostic to these higher-level architectural decisions.
Lastly, we need to consider the implementation of the timedependent control pulses. In the electrical regime, the control pulse can be modulated by standard microwave electronics in CMOScompatible hardware 69 . In the optical regime, the control pulse would have to be modulated by wave shaping through expressing the pulse in terms of its Fourier decomposition 70 . Intermediate regimes are also possible, in which we can modulate a THz electric field, by placing optically actuated Auston switches next to our triply-resonant cavities 71 . Active control will be necessary for loading and unloading photons from these long-lived cavities, e.g., by following methods proposed in Heuck et al. 23 .
It is important to note that one can balance the three considerations discussed in this section: the duration, power, and bandwidth of the control pulse. When the values of all these quantities can be expressed in characteristic units close to unity, the optimization problem is well conditioned and easier to solve. Such are the control pulses we have shown (e.g., their amplitudes, bandwidths, and durations are ≲10). However, if our hardware requires short pulses (e.g., due to low Q factor), but permits high power, we can nudge the solution in this direction by reparameterizing the optimization problem 39 .

Discussion
It is accepted in the quantum computing community that any prospective purely photonic architecture for quantum information Fig. 5 Logical qubit lifetime at the "break even" regime where it begins to outperform unprotected qubits. In blue, we see the decay of a single photon, i.e., an unprotected single-rail qubit. In orange, we see the decay of our two-mode code if we do not perform any correction operations-it decays faster as it contains a higher number of photons. The green line represents the decay of the encoded qubit in the presence of periodic correction operations. The infidelity of the correction operations due to photon loss that can happen during the operation is taken into account. The figure represents a lower bound for the performance of our protocol, with beneficial higher order effects being neglected in order to simplify the simulation. The "break even" point is achieved at V shg $ 10 À3 λ 3 n 3 , Q~2 × 10 8 , and χ ð2Þ $ 100 pm V for λ a~7 50 nm. Waveguide losses are neglected, as they would be insignificant compared to the rest of the operations.
processing would face significant challenges due to the weak photon-photon interactions available even in the best materials and resonators. Nonetheless, the present work, building upon more than a decade of theory developments on cavity-enhanced optical nonlinear interactions, shows that the monumental hardware requirements have already been nearly achieved in disparate experiments. It is an outstanding challenge to incorporate, in a single device, a record-high Q-factor cavity, together with extremely confined mode volumes, and fabrication-enhanced χ (2) materials. However, progress over the last decade-for example, the 10 8 -fold improvement in the efficiencies of SHG-inspires confidence that this herculean task can very well be achieved within the next decade.
Moreover, our work, for the first time, shows that a single elementary photonic device can be reprogrammed on the fly to perform a set of diverse unitary operations, drastically lowering circuit complexity and depth. We have shown its applicability for typical single-and dual-rail encoded qubits, as well as its versatility in processing multiphoton Fock states. We showcased the flexibility of our control paradigm by devising an explicit errorcorrecting circuit for a bosonic code and the application of multiqubit logic gates on top of that code. This is the first proposal for photonic logical qubits that includes compact encoding and correcting circuitry. Furthermore, the circuit we have designed does not require any measurement operations or feed-forward classical control, offering significant simplifications compared to a typical small stabilizer code, and opening the door for extremely fast, compact, room-temperature quantum repeaters.

Data availability
The digitized control-pulse examples in this manuscript can be readily reproduced in most optimization toolkits (e.g., Qutip and Tensorflow under Python, or SciML and Flux under Julia). Upon request, the authors can provide these waveforms and example scripts under each of the aforementioned frameworks that produce equivalent waveforms.

Code availability
As mentioned in the data availability statement, standard optimization toolkits were used for the creation of the control pulses and example scripts, using these frameworks can be provided upon request or found in the documentation of the aforementioned frameworks.