Introduction

For the past 10 years, there has been a strong renewed interest in optical computing. The reasons are three-fold: (1) the exploration of alternative hardware approaches for essential applications like neural networks; (2) a mismatch between future computing resources demand and hardware progress due to an impending slowdown of Moore’s law; and (3) improvement of optical hardware1. A paradigmatic example is that of a fully connected neural network implemented in multi-layer networks of Mach-Zehnder interferometers2. Several important classes of computing frameworks are, however, still missing their matching optical computing hardware, and one of them is probabilistic computing3,4. In probabilistic computing (p-computing), probabilistic bits (p-bits) replace the deterministic bits of conventional computing, while still sharing the use of basic logic gates that can be assembled to construct more complex circuits5,6. The framework of stochastic logic allows for the creation of “invertible” logic circuits (circuits that cannot only produce an output from some input but can also take the output to go back to the inputs)5. This makes p-computing especially suitable for solving complex optimization problems7,8,9,10 and for simulating physical systems, like the Ising Hamiltonian, which represents a collection of spins with arbitrary (linear) inter-spin coupling11,12,13. Furthermore the use of p-computing has been demonstrated for a wide array of different applications, including Bayesian inference14, Boltzmann networks15, classical annealing,16, quantum Monte Carlo17, machine learning quantum many-body systems18 and generative neural networks19.

Concurrently, there has been a significant interest in leveraging optics and other physical platforms for the determination of ground states in Ising Hamiltonians, a technique commonly referred to as coherent Ising machines20. A pioneering study proposed the utilization of injection-locked laser systems to map Ising models21. Subsequently, the proposition and experimental realization of networks of coupled optical parametric oscillators (OPOs) emerged22,23,24, with implementations reported in refs. 11,25,26,27,28. Additionally, alternative approaches in optics and photonics have been considered to solve Ising problems29,30,31,32, with special attention to solving NP-hard problems (which scale exponentially with system size) with coherent Ising machines33,34. The goal of these studies is to realize OPO networks described by the general Ising Hamiltonian of the form

$$E=-\frac{1}{2}\sum_{i,j}{\sigma }_{i}{J}_{ij}{\sigma }_{j}-\sum_{i}{h}_{i}{\sigma }_{i},$$
(1)

where J is the coupling matrix between different spins, represented by \(\overrightarrow{\sigma }\) and \(\overrightarrow{h}\) is the magnetization (Zeeman) vector. It is important to note, that the aforementioned studies only considered Ising Hamiltonians without a local magnetic field (\(\overrightarrow{h}=0\)). Coherent Ising machines are a prime candidate for implementing p-computing in the optical domain since a network of p-bits can be mapped to an Ising Hamiltonian5. However, to fully unlock the potential of p-computing in optics, coherent Ising machines that can only consider the coupling J are insufficient. This can be readily understood by considering even a simple logic gate, such as the AND gate, which, when implemented with stochastic logic, necessitates a non-zero Zeeman term. It is therefore important to develop strategies that incorporate a Zeeman term, with realizations as different dissipative circuits reported in the literature35,36. A recent experiment37 showed that injecting a vacuum-level bias field in an OPO cavity could be used to control its steady-state distribution, akin to the action of a magnetic field on a single spin. This provides a new strategy to include a Zeeman term with external coherent fields.

Here, we propose an optical platform for p-computing that consists of networks of coupled and biased OPOs to emulate arbitrary stochastic logic circuits. Our method relies on a three-step process that maps a stochastic logic problem to the dynamics of a biased OPO network. The process starts with (1) a logic truth table listing all possible outcomes of the logic gate or task; (2) converting that truth table into an equivalent Ising model (including a non-zero Zeeman term); and (3) finding an equivalent OPO network that realizes the corresponding Ising Hamiltonian (see Fig. 1). The motivation for our proposal of OPOs as optical hardware for p-computing is twofold: On one hand, the nature of p-bits to randomly fluctuate between either 0 or 1 is reminiscent of the OPO (a nonlinear, stochastic, and dissipative system) feature to choose its steady state randomly between two possible phases (often called  ± 1). On the other hand, networks of OPOs have been shown to map their steady-state configurations to the ground states of Ising Hamiltonians, which has garnered significant interest in the optical computing community22. The main innovation of our work is to realize the Zeeman term by biasing each node of the OPO network (paving the way for an all-optical realization without the need for dissipative circuits), which is a key ingredient in realizing all-purpose stochastic logic circuits.

Fig. 1: Illustration of the three-step conversion process.
figure 1

a We take the truth table from a (basic) digital logic gate and map it to a network of p-bits (b)). b Network of p-bits switching between two states randomly with some given probability. c A network of p-bits describing the gate is equivalent to an Ising model (where each spin can be either in the spin-up or spin-down state, see the black arrows) with a coupling term (J) and a local magnetic field (\(\overrightarrow{h}\)). d We then find the ground state of the Ising model by looking at the steady state of a network of (i.e. coupled) optical parametric oscillators (OPOs) that are biased by an injected field. The biasing operation results in a slanted potential (see the sketch inside the circles) experienced by the OPO.

Results and discussion

We now demonstrate why such a bias field indeed allows for the determination of the Ising ground state. Physically the bias field is a coherent field injected into the OPO cavity at the signal frequency. It influences the OPO’s steady state by displacing the initial vacuum state from its mean value of zero (which gets amplified to choosing one of two possible steady states with equal probability) to non-zero mean value, which then gets amplified to a tunable (by strength of the bias field) binomial probability distribution. Our starting point is the set of stochastic differential equations describing the OPO dynamics, which are rigorously equivalent to the density matrix formulation of degenerate parametric oscillation in the presence of a bias field38:

$${{\rm{d}}}{c}_{i}= \left(p-1-{c}_{i}^{2}-{s}_{i}^{2}\right){c}_{i}{{\rm{d}}}t+\varepsilon \left(\sum_{j}{g}_{ij}{c}_{j}+{b}_{i}\right){{\rm{d}}}t \\ +\frac{1}{{A}_{s}}\sqrt{\frac{1}{2}+{c}_{i}^{2}+{s}_{i}^{2}}{{\rm{d}}}{W}_{c},$$
(2)
$${{\rm{d}}}{s}_{i}=\left(-p-1-{c}_{i}^{2}-{s}_{i}^{2}\right){s}_{i}{{\rm{d}}}t+\varepsilon \sum_{j}{g}_{ij}{s}_{j}{{\rm{d}}}t+\frac{1}{{A}_{s}}\sqrt{\frac{1}{2}+{c}_{i}^{2}+{s}_{i}^{2}}{{\rm{d}}}{W}_{s}.$$
(3)

Here, ci is the in-phase and si the quadrature component of the ith OPO, p the pump, the saturation amplitude As is the field amplitude at a pump rate p = 2, dWc and dWs are two independent Gaussian noise processes and ε controls the overall strength of coupling gij and bias bi. Note that we have chosen the bias to be in phase with ci. In the following, we demonstrate how the OPO network finds the ground state of the Ising model including a Zeeman term. To this end, we neglect the noise terms, since we are interested in the mean fields at steady state. As a first step, we note that also in the multi-OPO case, the quadrature component is zero si = 0  i, just like it is for a single OPO above threshold pumping22. The second step is to look at the overall photon decay rate22 at the steady state (dci = dsi = 0), defined as (note that we have already used the fact here that si = 0):

$$\Gamma =\sum_{i}\left(p-{c}_{i}^{2}\right).$$
(4)

We can calculate Γ by expanding ci into orders of ε, since we assume a small magnitude for each gij and bi

$${c}_{i}={c}_{i}^{(0)}+\varepsilon {c}_{i}^{(1)}+\ldots ,{{\rm{with}}}$$
(5)
$${c}_{i}^{(0)}=\sqrt{p-1}{\sigma }_{i}\quad {{\rm{and}}}\quad {c}_{i}^{(1)}=\frac{1}{2(p-1)}\left(\sqrt{p-1}\sum_{j}{g}_{ij}{\sigma }_{j}+{b}_{i}\right),$$
(6)

where the spin configuration is given by σi = ± 1. We arrive at the components for the expansion of the in-phase component ci [Eq. (6)] by iteratively solving Eq. (2). From this, the overall photon decay rate then readily follows as

$$\Gamma =N-\varepsilon \left(\sum_{i,j}{g}_{ij}{\sigma }_{i}{\sigma }_{j}+\frac{1}{\sqrt{p-1}}\sum_{i}{b}_{i}{\sigma }_{i}\right),$$
(7)

which is largest if the OPO network is in the ground state of the Ising Hamiltonian, assuming that we replaced \({g}_{ij}\to \frac{1}{2}{J}_{ij}\) and \({b}_{i}\to \sqrt{p-1}{h}_{i}\).

However, simply solving the system described by Eqs. (2) and (3) is not sufficient for finding the ground state due to heterogeneity of the amplitudes ci. This is due to improper mapping of the objective functions by the loss landscape39. We fix this by adding an additional dynamic error field ei, resulting in the following set of equations of motion40:

$${{\rm{d}}}{c}_{i}= \left[\left(p-1-{c}_{i}^{2}-{s}_{i}^{2}\right){c}_{i}+\varepsilon {e}_{i}\left(\sum_{j}{J}_{ij}{c}_{j}+{F}_{h}{h}_{i}\right)\right]{{\rm{d}}}t \\ +\frac{1}{{A}_{s}}\sqrt{\frac{1}{2}+{c}_{i}^{2}+{s}_{i}^{2}}{{\rm{d}}}{W}_{c},$$
(8)
$${{\rm{d}}}{s}_{i}=\left[\left(-p-1-{c}_{i}^{2}-{s}_{i}^{2}\right){s}_{i}+\varepsilon {e}_{i}\sum_{j}{J}_{ij}{s}_{j}\right]{{\rm{d}}}t+\frac{1}{{A}_{s}}\sqrt{\frac{1}{2}+{c}_{i}^{2}+{s}_{i}^{2}}{{\rm{d}}}{W}_{s},$$
(9)
$$\frac{{{\rm{d}}}{e}_{i}}{{{\rm{d}}}t}=-\beta \left({c}_{i}^{2}-a\right){e}_{i}.$$
(10)

Here, ei is an auxiliary field that helps us homogenize the amplitudes (with target a) from the different OPOs to reduce the number of stable local minima, β controls the rate of change in ei and Fh is the bias amplitude.

To show that the aforementioned system of coupled OPOs is indeed a viable tool to implement stochastic gates, we now consider three representative fundamental gates: The first is the AND gate, which allows for the multiplication of two 1-bit numbers. The second is the half-adder that can take two 1-bit numbers and outputs the resulting sum and a carry-bit. The third is the full-adder that can take two 1-bit numbers and a carry-bit and outputs the resulting sum plus a carry-bit. The truth table associated with each of the three gates are the possible spin configurations of the corresponding Ising Hamiltonian’s ground state with three, four, and five spins respectively41,42,43. In each case, both the bits on the input and output sides of the binary logic truth table are represented by OPOs in the same network. In Fig. 2 we show a detailed description of how the AND gate can be implemented in a stochastic logic framework and the time evolution of the occupation probability for a certain spin configuration for the three gates under consideration (for the complete description of the HA and FA gates, see Supplementary Note 3). We observe that after some time the spin configuration in each OPO network represents a ground state of the Ising Hamiltonian with approximately equal probability, while simultaneously no OPO network is in an excited state. A detailed analysis of other basic logic gates as well as a demonstration of the universality of the NOR and NAND gates is provided in Supplementary Note 1. We note here that an OPO network can thus (in principle) perform any arbitrary computing task that can be represented by a logic circuit. In addition to the possibility of general computing, there is also the opportunity to implement invertible logic, i.e. the ability to go through logic circuits from output to input5. This insight now allows us to go one step further and construct more complex stochastic logic circuits, allowing us to solve difficult combinatorial optimization problems.

Fig. 2: Fundamental p-gates implemented with a biased coupled OPO network.
figure 2

a Truth table of the AND-gate. b Corresponding Ising Hamiltonian with three spins. c All possible spin configurations of the Hamiltonian depicted in b with their corresponding energy E. The ground states reproduce the correct logic from the truth table. df We plot the occupation probability of all possible states (meaning all possible combinations of the spin state represented by the phase of the OPO steady state) as a function of cavity round trips. The color denotes whether the state is a ground state (green) or an excited state (orange) of the corresponding Ising Hamiltonian.

As a first example, we choose a particular problem that has been established as an appropriate testing ground for probabilistic computing: semiprime factorization. Given a number, we aim to find the two prime numbers that, when multiplied, are equal to this number. This problem is of great interest since no polynomial time algorithms on classical computers have been discovered so far, making it for example the basis of several cryptographic systems44. We show in Fig. 3a a possible implementation of a logic circuit that takes 2 numbers and outputs their product (see Supplementary Note 5 for a more detailed description of the procedure to find this circuit). Conventionally this circuit works one way from top to bottom. However, the framework of stochastic logic allows us to clamp the output to the number we want to factorize (details of the clamping procedure are found in Supplementary Note 2) in order to find the factors as the ground state of the associated Ising Hamiltonian (shown as an inset in Fig. 3a). This Hamiltonian can be automatically generated by stitching together the Hamiltonians of the basic gates we demonstrated in Fig. 2. We want to emphasize that this procedure scales linearly with the number of bits required to represent the integers involved. While it can seem a bit wasteful that we solve for both factors at the same time, we note here that our invertible stochastic logic circuit is explicitly constructed to express the whole product of two primes. Thus, it is unavoidable to get the solution for both primes at the same time. Furthermore, we point out that we gave an example of a general constructive method to map most computing problems (as long as they can be cast as a logic circuit) into a network of OPOs.

Fig. 3: Solving the semiprime factorization problem with a coupled and biased network of OPOs.
figure 3

a Digital logic circuit that multiplies two 3-bit numbers (X and Y in their binary representations, respectively), resulting in Z (binary representation). The lines interconnecting the gates are represented by auxiliary spins in the Ising Hamiltonian. The inset shows the corresponding Ising Hamiltonian with coupling J at the top and Zeeman term \(\overrightarrow{h}\) at the bottom (see Supplementary Note 6 for a more detailed plot). b Time evolution of the in-phase component (ci) of coupled and biased OPOs with J and \(\overrightarrow{h}\) originating from the 6-bit multiplier circuit. The steady state of this configuration represents the ground state of the Ising Hamiltonian, solving the factorization problem.

To demonstrate that our network of coupled and biased OPOs can indeed find the ground state of the Hamiltonian depicted in Fig. 3a we now factorize 2491 = 47 × 53. Since both multiplicands are 6-bit numbers, altogether 12 OPOs (in conjunction with 84 OPOs representing the interconnects in the circuit) allow us to read out the solution. In Fig. 3b we show the trajectory of the in-phase components (c) of each OPO in the network and observe that the spin configuration given by σi = ci/ci settles into the ground state of the Ising Hamiltonian. The solution to the semiprime factorization problem is then encoded by the spin configuration in a binary representation. As a rule of thumb, we observe that the number of cavity round trips required to find the ground state stays independent of the number of OPOs involved. For example, with a 80 MHz repetition rate laser (as used in a recent study37) one loop around the OPO cavity is approximately 3.75 m long. It then takes 0.125ms to perform 10,000 cavity round trips. In Supplementary Note 4, we show a comparison to an established solving method.

We show our approach’s flexibility by also solving a different NP-complete problem with a coupled and biased OPO network: boolean satisfiability (SAT). More concretely, we consider the 3SAT problem, in which we want to find configurations (\(\overrightarrow{x}\)) that satisfy a conjunction of clauses (here, 91 clauses) of exactly three terms, which may or may not be negated. For instance, one such clause may take the form \({x}_{i}\vee {x}_{j}\vee \overline{{x}_{k}}\), where denotes the logical “or” and \(\overline{{x}_{i}}\) represents a negation. A simple example problem with 2 clauses and 4 variables is \(\left({x}_{1}\vee \overline{{x}_{2}}\vee {x}_{4}\right)\wedge \left({x}_{2}\vee \overline{{x}_{3}}\vee \overline{{x}_{4}}\right)\), with denoting the logical “and”. Figure 4a depicts the logic circuit for one clause of the 3SAT problem, with the output clamped to 1 so that the invertible logic property of p-computing allows for finding the state of \(\overrightarrow{x}\) that satisfies this clause. Between the variables xi and the OR gates, we put either a COPY or NOT-gate, depending on whether the variable is or is not negated in the clause. We note here that p-computing is especially suited to solve the 3SAT, since we only have linear overhead to represent the problem as an Ising Hamiltonian, stemming from Nspins = Nvariables + 4Nclauses. Here, Nspins (resp., NvariablesNclauses) is the number of spins (resp., variables, clauses). A detailed analysis of the employed gates akin to Fig. 2 can be found in the SI.

Fig. 4: Solving the Boolean satisfiability (SAT) problem.
figure 4

a The digital logic circuit of one clause in the 3SAT problem, i.e. x1 x2 x3 = 1 (left) with the corresponding Ising Hamiltonian (right). b Temporal evolution towards the steady state of the in-phase component (c, blue lines) of 384 coupled and biased OPOs with J and \(\overrightarrow{h}\) originating from the 3SAT problem with 20 variables and 91 clauses. From the steady state, we can read off one solution to the 3SAT problem. The orange line plots the evolution of the percentage of clauses satisfied.

Figure 4b shows the in-phase component’s (c) time evolution in an OPO network configured to solve the ‘uf20-01.cnf’ SAT problem (a common benchmark example) with Nvariables = 20 and Nclauses = 9145. Plotted is also the percentage of satisfied clauses as a function of time and observe that a configuration of variables that satisfies all clauses is found before the steady state is reached. This can be attributed to the fact that the OPOs representing the variables are already in the correct state while the states of OPOs representing the interconnects in the circuit are still changing their state. We note that the parameters in the full set of equations describing the system of coupled and biased OPOs, including amplitude heterogeneity correction [Eqs. (11)–(13)], require careful tuning for the system to find the ground state of the Ising Hamiltonian. An intuitive guideline for selecting these parameters is to ensure that the pump strength p and the overall coupling strength ε are balanced. This balance prevents the system from being dominated solely by the pump, where the coupling bias field becomes negligible, or by the coupling and biasing alone. Additionally, the bias amplitude Fh should be set so that the coupling J and the magnetic field \(\overrightarrow{h}\) are balanced. The rate of change β in the auxiliary field \(\overrightarrow{e}\) also needs to be chosen carefully. This ensures that the amplitude heterogeneity correction neither overtakes the evolution to the steady state nor fails to guide the system effectively to the ground state of the Ising Hamiltonian.

Conclusions

To conclude, we propose an approach that allows for the implementation of arbitrary stochastic logic circuits in a network of coupled and biased OPOs, working closely along the lines of experimentally demonstrated technology. We successfully tested the approach numerically for a representative set of basic logic circuits and ubiquitous problems in combinatorial optimization. Our study paves the way for an optical implementation of p-computing for the potentially high-speed solution of ubiquitous combinatorial optimization problems.

For an experimental realization of our approach, we envision a set-up similar to the one used in the first successful experiment on applying a bias field to an OPO37. Combining it with a single fiber-ring cavity then provides the missing ingredient: coupling between the (time-multiplexed) OPOs through feedback and measurement11. Furthermore, we need the capability of modulating the amplitude of the bias at the repetition rate of the laser (which is 80MHz in the set-up of a recent study37). Ultimately, however, we anticipate the coupling between different OPOs to be performed fully optically by e.g. linear programmable nanophotonic processors for great speed and energy efficiency46. Generally, p-computing would also profit from massively parallel, ultrafast, and tunable random bit generation using a physical source for the randomness47.

Methods

Here we provide details on the numerical implementation of the stochastic differential equations governing the time evolution in a network of coupled and biased OPOs:

$${{\rm{d}}}{c}_{i}= \left[\left(p-1-{c}_{i}^{2}-{s}_{i}^{2}\right){c}_{i}+\varepsilon {e}_{i}\left(\sum_{j}{J}_{ij}{c}_{j}+{F}_{h}{h}_{i}\right)\right]{{\rm{d}}}t \\ +\frac{1}{{A}_{s}}\sqrt{\frac{1}{2}+{c}_{i}^{2}+{s}_{i}^{2}}{{\rm{d}}}{W}_{c},$$
(11)
$${{\rm{d}}}{s}_{i}=\left[\left(-p-1-{c}_{i}^{2}-{s}_{i}^{2}\right){s}_{i}+\varepsilon {e}_{i}\sum_{j}{J}_{ij}{s}_{j}\right]{{\rm{d}}}t+\frac{1}{{A}_{s}}\sqrt{\frac{1}{2}+{c}_{i}^{2}+{s}_{i}^{2}}{{\rm{d}}}{W}_{s},$$
(12)
$$\frac{{{\rm{d}}}{e}_{i}}{{{\rm{d}}}t}=-\beta \left({c}_{i}^{2}-a\right){e}_{i},$$
(13)

where ci and si denote the in-phase and quadrature component of the ith OPO respectively, p is pump, the saturation amplitude As is the field amplitude at a pump rate p = 2, dWc and dWs are two independent Gaussian noise processes (with zero mean and variance Δt [the step-size for numerically solving the stochastic differential equations]) and ε controls the overall strength of coupling gij and bias bi. The auxiliary is ei, with its associated rate of change β, and Fh controls the bias amplitude.’

To solve these stochastic differential equations, we employ the Milstein method48 since we found it to be sufficiently accurate while still allowing for high-throughput simulations compared to higher-order methods. As we are interested in the probability of finding ground states of Ising Hamiltonians, we need to be able to compute many trajectories at high speed. We achieve this by parallelizing our computations with PyTorch to get all the trajectories with one time evolution.