WorksPhysics and Astronomy
Theory-Informed Quantum Error Mitigation for Shor Order Finding with Fourier Neural Operators
Abstract
Quantum noise distorts the distribution of circuit measurement outcomes, often leaving enough information to infer the algorithm's correct result. To recover this latent information from the noisy distribution in Shor order finding, we introduce a theory-informed quantum error mitigation method. We model how circuit errors shift, broaden, or weaken peaks in the output distribution. These models guide both the generation of synthetic training data and the design of a Fourier neural operator with a learned gain that attenuates or amplifies higher retained Fourier modes. We score each candidate order by averaging the correlations between its ideal distribution and the distributions measured in three circuit executions. The network adjusts these scores to guide the order estimate and determine the weights of a normalized mixture of the ideal distributions. On 1,351 simulated test cases for general modular exponentiation, held out by circuit configuration, exact order recovery rises from 19% to 34%, and the median Jensen-Shannon divergence from the ideal distribution falls by 50%, from 0.64 to 0.32. On 101 Mersenne rotation circuits executed across five IBM quantum processors, a separate model trained and calibrated in simulation increases the number of correct order estimates from 35 to 53. Algorithmic structure can remain recoverable even when noise makes it barely visible.
Introduction
Reliable quantum computation requires preserving the superposition, interference patterns, and entanglement used by the algorithm [21] despite physical noise and imperfect control [13, 25]. Quantum error correction (QEC) detects and corrects errors during computation. It encodes each logical qubit, a qubit of the computation, across multiple physical qubits. Syndrome measurements test whether joint properties of the physical qubits satisfy the constraints specified by the quantum error code without revealing the logical state. The classical outcomes of these measurements form the error syndrome [7, 14, 25]. A decoder is a classical algorithm that uses the syndrome, the code structure, and a probabilistic noise model to infer a likely error and select a correction [23]. Quantum error mitigation (QEM) takes a different approach. It uses measurements from noisy circuit executions to estimate quantities of the ideal circuit, such as expectation values of observables [28]. In this work, we develop a QEM method for reconstructing the ideal output probability distribution from noisy measurements.
Conventional QEC and many QEM techniques describe noise in terms of errors affecting physical qubits, gates, or measurements, such as bit flips, phase flips, gate errors, and readout errors [11, 28]. At the algorithm level, we use known properties of the ideal output to constrain what we infer from noisy measurements. This builds on the use of symmetries and other constraints in error mitigation [3]. The structure of quantum phase estimation has also motivated mitigation methods tailored to that algorithm [20, 22]. For instance, in Shor order finding [26], quantum phase estimation produces an ideal measurement distribution with a periodic comb of peaks whose spacing encodes the order. We model how these errors change the measurement distribution and use the ideal distributions predicted for candidate orders to estimate the order and reconstruct the output distribution. We call this approach theory-informed algorithm-level QEM.
Authors’ Contact Information: Stefano Markidis; Qingxin Yang; Erik Åsgrim; Ivy Peng, Department of Computational Science and Technology, KTH Royal Institute of Technology, Stockholm, Sweden.
Our approach is akin to forward error analysis in classical numerical computation, which traces how perturbations propagate through an algorithm and affect its output [15, 31]. We apply this idea to quantum circuits by modeling how errors during execution change the distribution of measurement outcomes. The theory of the algorithm tells us what patterns to expect in the ideal output, such as regularly spaced peaks or probability concentrated on a subset of outcomes. The error model describes how noise distorts these patterns or introduces competing ones.
In this work, we introduce a neural network approach for algorithm-level QEM in Shor order finding. The inverse quantum Fourier transform (QFT) in the circuit converts the periodicity of modular exponentiation into a comb of peaks in the ideal output distribution. The spacing between these peaks encodes the order and is reflected in the Fourier spectrum of the distribution. This motivates our choice of a Fourier neural operator (FNO) [18], a neural network designed to learn mappings between functions using Fourier layers. The FNO processes measurement distributions from repeated circuit executions. It uses a classical fast Fourier transform (FFT) to compute the Fourier coefficients of the features it extracts from these distributions and applies learned transformations to selected modes. For each candidate order, we compute the ideal output distribution predicted for that order. We assign the candidate a scalar score that measures how closely this distribution matches the measured distributions. The initial score is the average of the correlations with the distributions from individual executions. Higher scores indicate closer agreement. Trained on synthetic data, the FNO predicts how much to increase or decrease each candidate’s score. A model parameter sets the maximum magnitude of this adjustment. We use the revised scores to decide whether to change the initial order estimate. To reconstruct the output distribution, we combine the ideal distributions, giving more weight to candidates with higher revised scores. Figure 1 summarizes the mitigation workflow and shows how synthetic training data, analytical reference distributions, and noisy measurements enter the method.

Figure 1. Overview of theory-informed algorithm-level quantum error mitigation.
The main contributions of this work are as follows.
We introduce an approach to QEM based on models of how errors propagate through a quantum algorithm. For Shor order finding, we model how faults in modular exponentiation, phase errors in the inverse quantum Fourier transform, and readout errors change the distribution of measurement outcomes. These models guide both the generation of synthetic training data and the design of the FNO.
We reconstruct the output as a weighted mixture of the ideal distributions for the candidate orders. Each component retains the peak structure predicted for its order, and the nonnegative weights sum to one, so the
reconstruction is a valid probability distribution by design. On the simulated test set, the median Jensen–Shannon divergence from the ideal output decreases by 50%, from 0.64 for the average of the measured distributions to 0.32 for the reconstructed distribution.
We show that the method improves exact order recovery from 19% to 34% in simulations of general modular exponentiation. On IBM quantum processors, a separate model trained and calibrated entirely in simulation increases the number of correct order estimates from 35 to 53 out of 101 Mersenne rotation circuits. This transfer from simulation to hardware motivates developing mitigation methods for other quantum algorithms based on how errors change their expected output distributions.
Shor Order Finding
We apply the proposed QEM workflow to quantum order finding, the central quantum subroutine of Shor’s factorization algorithm [10, 26]. For an integer and a base coprime to (they have no common divisor greater than one), the modular function repeats as the exponent increases. The quantum circuit encodes this repetition coherently and uses interference to transform it into a comb of peaks in the measured probability distribution. The spacing of these peaks reveals the hidden period and therefore provides the algorithm-level structure targeted by our mitigation method.
The period of the modular sequence is called the multiplicative order of modulo . It is the smallest positive exponent for which the sequence returns to one:
For example, for and , the successive modular powers are 1, 2, 4, 8, 1, . . . , so the sequence repeats after four steps and the order is . The role of the quantum computation is to recover this period from the output distribution.
Once is known, classical arithmetic can often convert it into factors of . If is even and , nontrivial factors are obtained from
For , , and , these calculations give and . If the required conditions are not satisfied, the procedure is repeated with another base. Factorization is therefore reduced to recovering the periodicity of modular exponentiation.
No polynomial-time classical algorithm is known for order finding for general large integers. Shor’s quantum procedure requires a number of operations polynomial in the input size [17, 26]. Figure 2 shows the register-level organization of the quantum subroutine. The -qubit precision register represents possible measurement outcomes, while the -qubit work register, with , stores values modulo . Hadamard gates prepare a uniform superposition of exponents . Controlled modular exponentiation then performs

Figure 2. Shor order finding quantum circuit.
thereby encoding the modular periodicity across the two registers [2, 6, 30]. The inverse QFT then converts this encoded periodicity into the characteristic peak comb observed in the precision register.
The circuit converts the periodicity of modular exponentiation into a measurable peak structure. For an order , the ideal precision-register distribution is concentrated near
The peak spacing determines the order . If divides , each peak coincides with an integer measurement outcome. Otherwise, some peak locations fall between integers, and their probability spreads across neighboring outcomes even in the ideal circuit.
A measured outcome provides an approximation to a fraction whose denominator is related to the order. Shor’s classical post-processing uses continued fractions (a representation of numbers using nested reciprocals) to approximate by a fraction with candidate denominator . It then tests candidate orders using modular exponentiation [26]. When and share a common factor, the recovered denominator can be a proper divisor of , requiring additional outcomes or tests of denominator multiples.
In our experiments, both decoders estimate the order by comparing the candidates in . Each candidate is represented by its analytical distribution , and denotes the true order.
Both decoders use measurements from three separate executions of the same circuit. Keeping the three distributions separate lets the Fourier neural operator assess which features recur and how much they vary across executions because of finite sampling and changes in noise. The raw decoder uses the same three distributions for comparison. We normalize the counts from each execution separately as , where is the count of outcome in execution , , and .
For an empirical or analytical distribution , we subtract the uniform level and normalize the resulting vector. The raw score is the mean correlation with each candidate:
Here, is the Euclidean norm over the outcomes. Uniform distributions are assigned zero vectors, and small norms are regularized numerically. Centering removes the uniform background, while normalization makes the score invariant to a common positive rescaling of the deviations from that background. Each execution contributes equally to the mean score. The raw decoder returns
with score ties resolved in favor of the smaller order. The FNO approach, used in this work, corrects these raw scores.
To study this workflow using circuits compatible with current quantum hardware, we exploit the structure of Mersenne integers. Early experiments demonstrated quantum order finding for small instances, including the factorization of [29], while general-purpose modular exponentiation requires substantially deeper arithmetic circuits [30]. In hardware experiments, and the base is a power of two, . Multiplication by a modulo then becomes a cyclic rotation of the -qubit work register for basis states :
Here, rotates the binary representation of cyclically to the left by positions. This construction preserves the periodic order-finding signal while replacing general modular arithmetic with a shallower rotation-based circuit.
Synthetic and Hardware Datasets
In this work, we generate synthetic datasets using statevector simulation with Monte Carlo sampling of errors. Each trajectory represents one sampled sequence of arithmetic and phase errors. During modular exponentiation, the simulator tracks the work-register value and accumulated phase associated with every exponent . It then transforms the resulting amplitudes and traces out the work register to obtain the precision-register probabilities. For the general dataset, the full inverse QFT is evaluated using a FFT. Probabilities are averaged over 16 trajectories before applying readout errors and multinomial sampling. Each example contains three separate 4,000-shot executions and an analytical target computed with the full inverse QFT. Figure 3 illustrates the general error model.
Figure 3. Application-level error propagation for general modular exponentiation with , , and . A skipped controlled multiplier creates additional harmonics. Stochastic phase errors, asymmetric readout errors, and 4,000-shot sampling further deform the output. Dashed guides mark the ideal order-six peak family.
Synthetic Data for General Order Finding
In ideal modular exponentiation, the work-register label repeats with the order . Exponent states separated by multiples of therefore share the same work-register state and retain their coherence when that register is traced out. The inverse QFT maps these repeated separations into a family of peaks near . When does not divide , the peaks spread over neighboring integer outcomes.
Modular Exponentiation Error Model. The modular exponentiation error model perturbs the controlled multipliers . Writing , a trajectory with multiplier faults alone implements
In the ideal circuit, block multiplies the work-register value by modulo when the control bit . A skipped block performs no multiplication, corresponding to . An incorrect block uses a different multiplier, chosen coprime to so that the operation remains reversible. Between blocks, sampled Pauli X errors flip selected work-register bits, while Pauli Z errors change the signs of amplitudes according to those bits.
One error sequence is sampled for each trajectory and applied to the entire quantum state. Therefore, the random choices are shared across the exponent superposition, rather than sampled independently for each value of . Different trajectories represent different error sequences, whose output probabilities are averaged. Modular fault probabilities increase with work-register width using , where , before probability caps are applied.
These changes affect which exponent states can interfere after the work register is traced out. For a fault trajectory , let be the final work-register label and the accumulated phase. With the full inverse QFT, the probability before readout is
Only exponent states ending in the same work-register state interfere in each amplitude. An arithmetic fault can remove separations supporting the intended peak family and introduce other separations with coherent support. The resulting distribution can contain weakened intended peaks and competing harmonic families.
In Figure 3, , , and the true order is six. Skipping the controlled multiplier gives , which repeats every 12 exponent values. For , the orange distribution consequently contains additional peaks near . These peaks arise from the altered arithmetic map.
Quantum Fourier Transform Error Model. The QFT phase-error model modifies the relative phases in Eq. (9) while leaving the work-register labels unchanged. It applies a stochastic diagonal phase screen with single-control terms proportional to and pair terms proportional to . The coefficients are Gaussian, with pair standard deviations decreasing as . These offsets change constructive interference at the intended harmonics and can attenuate or deform a peak family even when the arithmetic map is correct. The pre-readout distribution is obtained by averaging 16 coherent trajectories containing the selected arithmetic and phase errors. The third distribution in Figure 3 applies this phase model to the faulty arithmetic map, followed by the full inverse QFT.
Readout Error Model. The readout model acts on after the inverse QFT through independent asymmetric bit-flip errors, with separate and probabilities. It mixes outcome probabilities without changing the preceding arithmetic or interference. This mixing need not be local in the integer outcome index. Flipping bit moves an outcome by . Let be the readout transition matrix for execution , with entry giving the probability of recording outcome given outcome before readout errors. The recorded counts follow , with shots per execution. The three executions share but have perturbed readout rates and independent multinomial samples. The rightmost distribution in Figure 3 shows a normalized count distribution after these final two stages.
The dataset contains 9,399 examples from 497 configurations across 26 odd composite moduli in . We exclude prime powers because their prime factors can be recovered efficiently by classical integer root extraction [26]. At most 20 coprime bases are selected per modulus, giving 23 distinct orders between 2 and 48. The precision policy yields .
We alternate between and to give both ranges comparable representation, and cycle through the available orders within each range to avoid concentrating examples on a few orders. A noise channel is a component of the simulation that introduces one class of errors. We use three channels to model arithmetic errors in modular exponentiation, phase errors associated with the inverse QFT, and readout errors. Approximately 84% of the examples combine all three channels to capture their joint effect on the output distribution. For each channel, approximately 5% of the examples activate only that channel to isolate its effect. The remaining 1% have no injected errors and reflect variation from finite sampling alone.
Synthetic Data for Order Finding with Mersenne Moduli
The Mersenne dataset uses a different arithmetic error model for and . In this circuit family, modular multiplication is implemented by cyclic rotation of the -qubit work register. The block controlled by precision qubit rotates by positions, giving
Starting from , the work state repeats after exponent steps.
The arithmetic channel perturbs these rotations through skipped blocks, one-position over- or under-rotations, and erroneous adjacent work-qubit SWAPs. It also includes control-condition toggles, work-register masks, and control-conditioned phase offsets. These faults replace the general model’s incorrect-multiplier mechanism with errors in the rotation implementation. The phase and readout channels retain the forms described above. Every input additionally uses a degree-two approximate inverse QFT, while its clean target uses the full transform.
We use the two-qubit depth and gate count of the corresponding transpiled circuit to adjust how frequently faults are injected in the simulation. When these metrics are unavailable, we base the adjustment on the estimated cost of the logical rotations. Hardware outcome probabilities are not used in this scaling. Each execution independently perturbs the arithmetic and phase parameters, averages 16 trajectories, and applies readout errors and finite-shot sampling. Thus, execution variability also enters the pre-readout distribution in this specialized dataset.
The dataset contains 9,499 examples over 18 configurations, with , selected bases , and orders . Each configuration is generated at and , giving 36 groups sampled cyclically. Approximately 85% of examples combine the stochastic channels, and approximately 5% isolate each channel. The degree-two inverse QFT remains present in every category.
IBM Quantum Computer Dataset
The hardware dataset measures the combined distortions of compiled Mersenne order-finding circuits. It contains 101 circuit configurations and 680 executions on ibm_boston, ibm_kingston, ibm_miami, ibm_pittsburgh, and ibm_torino. The moduli are , with selected bases . Of the 101 circuits, 84 use and 17 use ; the inverse-QFT approximation degree is zero, one, or two. The supplied analytical reference follows the circuit’s configured inverse QFT. It is distinguished from the full-QFT reference used by the FNO candidate set and reconstruction.
Each circuit has five or ten separately recorded executions of 4,000 shots. Runs 1-3 provide three-distribution inputs for all 101 circuits. Runs 4-6 and 7-9 provide two further sets of 35 inputs for circuits with ten executions. The later sets repeat existing circuits and retain the variation between hardware runs. Evaluation uses the network weights and score calibration selected on synthetic data, without hardware fine-tuning.
Quantum Error Mitigation with Fourier Neural Operators
The inverse QFT in Shor order finding produces a pattern of peaks across the measurement outcomes. A classical Fourier transform of the measured distribution represents this pattern through its harmonics. Each Fourier coefficient depends on the distribution across the entire register, so it carries information about the spacing of peaks even when they are far apart. We use an FNO to extract these features from repeated executions and compare them with the analytical distributions used by the raw decoder. Figure 4 shows how the network turns these comparisons into adjustments to the scores for candidate orders.
Figure 4. FNO architecture. (a) The same encoder processes each measured distribution separately. (b) The trunk processes the mean and standard deviation of the resulting features together with the outcome coordinates. (c) The candidate head combines Fourier comparisons with statistics from the raw decoder to adjust the score for each candidate order.
Combining Information from Repeated Executions. The encoder is the part of the network that extracts features from one execution. We scale each by so that the uniform level is one at every register size. At each outcome, we use to compress large peaks and to make small nonzero values easier to distinguish from zero. A learned affine map expands these two values into a larger feature vector. This operation is called a pointwise lift because it applies the same map independently at each outcome. A Fourier block then combines information across outcomes.
Using the same encoder for every execution gives corresponding features a common meaning. At each outcome, we compute the mean and standard deviation of each feature across executions, dividing by the number of executions when computing the variance. The mean describes the average pattern. The standard deviation tells the network whether that pattern is consistent across executions or varies substantially. We append and so the network can distinguish positions while respecting the periodic boundary. A learned projection combines these values at each outcome, and two Fourier blocks process the result. These blocks form the trunk, the part of the network whose output is computed once and reused for every candidate order.
Diffusion and the Design of the Spectral Gain. Diffusion provides an error model for how peak broadening changes a spectrum. Under diffusion, the decay rate of a Fourier component increases with the square of its frequency, so higher harmonics decay faster. This motivates a gain that depends on the Fourier frequency. Amplification can give more weight to harmonics weakened by broadening. Attenuation can reduce the influence of fluctuations introduced by finite sampling. Each block learns the direction and strength of this adjustment from the training data.
A Fourier block transforms its input features with a FFT [18]. At each retained mode, a learned complex matrix combines the features, while the gain multiplies the original coefficients by the same factor for every feature. The block adds these two contributions and transforms them back to the outcome domain. The gain in block is
Here, indexes the retained nonnegative modes. The learned scalar sets the gain profile. A negative gives stronger attenuation at higher modes, and a positive value gives stronger amplification. The parameter keeps the gain between and . The encoder applies this operation to each execution, and the trunk applies it to the combined features.
Each block also applies a learned map independently at each outcome. Its output is added to the Fourier result before the nonlinear activation. During training, dropout randomly sets some feature values to zero. The block then adds its input back through a residual connection and normalizes across the features at each outcome. Keeping the same number of Fourier modes allows the learned matrices to be reused across register sizes.
Adjusting the Scores for Candidate Orders. The candidate head is the part of the network that produces one score adjustment per order. For each candidate, it compares the Fourier coefficients of each trunk feature with those of the centered and normalized analytical distribution from Eq. (5). We compute a normalized complex correlation by multiplying the feature coefficients by the conjugates of the reference coefficients, summing over the selected nonzero modes, and dividing by the product of the two norms over those modes. We regularize small denominators and use the real and imaginary parts separately to retain information about phase alignment.
The head also uses seven quantities from the measurements and circuit dimensions. The mean, standard deviation, minimum, and maximum of the three correlations used by the raw decoder describe how consistently the measurements support the candidate. The gap to the best raw score and the standardized raw score describe its standing among the candidates. The seventh quantity, , expresses the register resolution relative to the scale used to distinguish rational phases. The correlations from the raw decoder use all outcomes, so they can supply information beyond the selected Fourier modes.
We normalize these inputs and pass them to a multilayer perceptron (MLP), a small network that combines its inputs through successive learned maps and nonlinear activations. The same MLP produces one value for each candidate. We subtract the mean across candidates to remove a common offset and compute
The parameter limits the magnitude of the adjustment. The temperature sets the scale of the raw scores while preserving their ranking, and controls how much of the adjustment is applied at each register size. Initializing the final MLP layer to zero makes the network start with the raw ranking.
Reconstructing the Distribution and Estimating the Order. We convert the adjusted scores to weights and use them to combine the analytical distributions:
The weights are nonnegative and sum to one, so the reconstruction is a valid probability distribution by design. The analytical components supply the full peak patterns, including details beyond the Fourier modes used by the network.
We use a switching rule to decide whether to replace the order with the highest raw score. If a different order has the highest adjusted score, we switch to it only when its adjusted score exceeds the adjusted score of the original order by more than the margin . Otherwise, we keep the original order and the full raw ranking. The reconstruction uses the adjusted scores in either case.
Training and Calibration. The training objective rewards assigning weight to the true order and matching its analytical distribution, while penalizing large score adjustments:
The five coefficients set the relative weights of the terms. Cross-entropy rewards weight on the true order. Squared Hellinger distance compares the probabilities, including small ones. The centered, normalized correlation compares deviations from uniformity independently of their overall magnitude. The spectral loss compares Fourier coefficients over the evaluated nonzero modes, dividing the squared discrepancy by the sum of the squared magnitudes of the target coefficients. The final term penalizes the mean squared score adjustment. We train with and apply the switching rule only after training.
Experimental Design
This section presents the data partitions, FNO architecture, training and calibration procedures, and evaluation metrics.
Data Partitioning. We split the synthetic data by circuit configuration , keeping all noisy realizations of each configuration together. For each , we shuffle the configurations and assign approximately 70%, 15%, and 15% to training, validation, and testing, respectively. In the general dataset, these partitions contain 6,622, 1,426, and 1,351 examples from 348, 75, and 74 configurations, respectively. The test set contains 18, 15, 627, and 691 examples at , , , , respectively. Each example contributes equally to the reported test rates. We apply the same splitting procedure to the synthetic Mersenne dataset.
The synthetic test set measures generalization to held-out circuit configurations under the same error models used for training. A modulus can appear in more than one partition. The IBM experiments assess transfer to hardware within the Mersenne rotation circuit family. We train and calibrate a separate model on synthetic Mersenne data, then keep its weights and score calibration fixed during hardware evaluation. Generalization to entirely held-out moduli and controlled tests of noise conditions outside the simulation model require separate evaluation.
FNO Architecture. We train separate models for the general and Mersenne datasets. Each model has 57,538 trainable parameters and uses the same weights at every register resolution within its dataset. At each outcome, the encoder maps the two input features to 16 features, and the projection before the trunk maps the 34 values from the aggregated features and position coordinates to 16 features. Each Fourier block retains modes and uses to bound the spectral gain. After adding the Fourier and pointwise contributions, we apply a Gaussian error linear unit (GELU). This activation lets the block model nonlinear relationships between features. It smoothly attenuates negative values and leaves large positive values nearly unchanged.
For each candidate order, the head computes one complex correlation per trunk feature over modes . The real and imaginary parts of the 16 correlations give 32 values. We combine them with the seven quantities defined previously, apply layer normalization, and pass the resulting 39 values to the shared MLP of dimensions 39 64 64 1. Each hidden layer is followed by GELU and dropout. We initialize the final layer to zero so that training starts from the raw ranking. The spectral term in the reconstruction loss uses up to 128 nonzero Fourier modes to assess finer detail in the reconstructed distribution.
Training and Model Selection. We minimize the objective in Eq. (14) using AdamW (an adaptive gradient optimizer that applies weight decay separately from the gradient update), with batches of eight examples at the same register resolution. Each stratum receives equal total loss weight, and circuit groups within a stratum receive equal weight. A plateau scheduler halves the learning rate with a patience of two validation checks and a minimum rate of . Within each trial, the checkpoint with the highest uncalibrated validation exact-order count is retained, with mean reciprocal rank (MRR), defined below, breaking ties.
Optuna [1] optimizes hyperparameters on the fixed validation split using a tree-structured Parzen estimator sampler. Separate searches for the general and Mersenne datasets select optimization parameters, dropout, the score temperature, correction bound, and loss weights. The architecture, training seed, and group assignments remain fixed across trials. Table 1 reports the selected settings. The implementation uses PyTorch.
| Parameter | General | Mersenne |
| Learning rate | ||
| Weight decay | ||
| Dropout | 0.10 | 0 |
| Gradient clipping norm | 0.5 | 0.5 |
| Raw temperature | 0.11052 | 0.10016 |
| Correction bound | 4 | 4 |
| 4 | 2 | |
| 0.5 | 0.5 | |
| 0.2 | 0.2 | |
| 0.2 | 0.2 | |
| 0.0032514 | 0.0034787 | |
| (0.10, 0.72, 0.94, 1.00) | (0.94, 0.94) | |
| (0, 0.33548, 0.21182, 0) | (0.10011, 0) |
Table 1. Selected optimization, loss, and score parameters. Vector entries follow increasing .
After checkpoint selection, each trial is calibrated on validation data. For each , we search 51 uniformly spaced strengths and switching margins derived from validation score differences. The selected strengths and margins are included in Table 1.
Trial selection prioritizes calibrated validation exact recovery, with MRR and the fraction of spoiled predictions as secondary criteria. The Mersenne search also considers minimum recovery across resolutions. This comparison is separate from checkpoint selection within a training run. Checkpoint weights and calibration are frozen before test evaluation.
Evaluation Metrics and Procedures. Exact order recovery measures how often the decoder returns the true order. Top-3 recovery measures how often the true order has rank at most for example . Mean reciprocal rank (MRR), , summarizes the full ranking. A true order ranked first contributes 1, one ranked second contributes , and so on. Here, is the rank of the true order and is the number of evaluated examples.
We rank candidates using the scores selected by the decision rule, including the raw scores when the switching rule retains the raw ranking. The rank of a candidate is one plus the number of candidates whose score exceeds its score by more than . Tied scores share a rank, and an exact tie for the winning score is resolved in favor of the smaller order. We evaluate the order returned directly by each decoder, before any continued-fraction processing or arithmetic verification. Rates for each use the examples at that resolution, and overall rates pool all test examples.
To see where mitigation helps or hurts, we compare the two predictions for each example. A prediction is retained if both decoders are correct, recovered if only the FNO is correct, spoiled if only the raw decoder is correct, and still incorrect if both are wrong. Each percentage in the outcome matrix uses all evaluated examples at the corresponding as its denominator.
In plots of candidate weights, we exponentiate and normalize for the raw decoder and for the FNO.
We measure how close the reconstructed distribution is to the reference using Jensen–Shannon (JS) divergence. This divergence compares each distribution with their average and is zero when they agree.
With natural logarithms, the divergence is measured in nats and lies between 0 and . Terms with zero probability contribute zero. In the JS divergence plots, the blue series (Raw decoder) shows the divergence of the mean of the three measured distributions , and the orange series (Neural operator) shows the divergence of the FNO reconstruction , both relative to the same reference distribution.
To assess how much the results depend on sampling, we repeat the evaluation at total shot counts . For each , we draw 20 subsamples without replacement, allocating the shots proportionally across the three executions and forming a separate distribution for each execution. The model weights and calibration stay fixed. For each draw, we compute exact order recovery and median JS divergence across examples. The curves average these two statistics over the 20 draws. The bands show the empirical 2.5th and 97.5th percentiles across draws. At , each draw uses all recorded shots and reproduces the original distributions.
We test how well a short list preserves the true order and how often the decoder recovers it from that list. We rank candidates by either their raw correlation scores or a spectral comparison that emphasizes features shared across executions. For the spectral comparison, let . At each nonzero mode of the real FFT, we average over the three pairs of executions. A mode contributes positively when its coefficients are aligned in phase across a pair. We compare the resulting vector with the squared Fourier magnitudes of each centered analytical distribution, , using cosine similarity. This calculation uses the measured distributions directly.
For each , each screening method retains the highest-ranked candidates. True order recall measures how often the list contains the true order. Restricted exact recovery measures how often the decoder returns it. To compute restricted recovery, we take the raw and corrected scores already computed over the complete candidate set and apply the switching rule within the list. Error bars show one binomial standard error, , with each example counted once.
Results
This section presents the results on order recovery and distribution reconstruction, followed by analyses of sampling sensitivity, transfer to IBM hardware, and candidate screening.
Overall Order Recovery and Reconstruction. We first evaluate the effectiveness of FNO-based quantum error mitigation in reconstructing the precision-register distribution and improving order recovery. Figure 5 compares exact-order recovery, top-3 recovery, and JS divergence from the analytical reference distribution across different register resolutions . The FNO improves order recovery at all tested resolutions, with the largest gains at . and . Across all test cases, exact-order recovery increases from 19% to 34%, while the median JS divergence decreases from 0.64 to 0.32. However, at , exact-order recovery reaches only 22%, despite the reduction in JS divergence.
Figure 5. General order-finding results on 1,351 test cases. (a) Exact-order recovery, (b) top-3 recovery, and (c) median JS divergence to the analytical distribution. Error bars indicate the interquartile range.
To determine how the FNO produces these recovery gains while leaving many cases unresolved, Figure 6 separates successful corrections from changes that spoil correct predictions. The FNO retains 238 of the 250 correctly decoded raw cases and recovers 215 initially incorrect cases, while spoiling 12, giving a net gain of 203 correct predictions. At , it recovers 146 cases and spoils only one. At , it recovers 63 cases but spoils 11; both decoders remain incorrect on 531 of the 691 cases (76.8%). The limited recovery at this resolution therefore reflects predominantly unresolved raw errors, with a smaller contribution from spoiled predictions.
Figure 6. Paired exact-order outcomes on the general test set: retained (both correct), recovered (raw incorrect, FNO correct), spoiled (raw correct, FNO incorrect), and still incorrect (both incorrect). Cells show counts and percentages of test cases at each .
Sensitivity to Measurement Shot Count. We next investigate the sensitivity of FNO-based mitigation to the number of measurement shots. Figure 7 shows that increasing improves both order recovery and distribution reconstruction.
Figure 7. Effect of measurement shots on (a) exact-order recovery and (b) median JS divergence. Error bars indicate the 95% resampling intervals.
While the raw decoder remains near 18% exact-order recovery, the FNO increases from 24% at 500 shots to 34% at 12,000 shots. The corresponding decrease in JS divergence indicates that additional measurements allow the FNO to reconstruct the periodic peak structure more accurately. Differently from the raw decoder, the FNO continues to benefit from increased sampling precision throughout the evaluated range.
Peak Reconstruction and Candidate Ranking. We next examine how the FNO changes the reconstructed distribution and candidate ranking. Figure 8 considers an instance with , , , and true order . The case is representative of successfully corrected high-resolution instances, with a JS reduction close to the median for this subset. The noisy executions exhibit a nearly uniform probability background that obscures the analytical periodic peak structure. The FNO reconstruction recovers peaks aligned with the analytical reference distribution, reducing JS divergence from 0.591 to 0.202. This reconstruction increases the probability assigned to the true order from 2.3% to 18.5%, moving from 11th to first in the candidate ranking and replacing the incorrect raw estimate .
Figure 8. Example of FNO-based reconstruction for , , , and true order . (a) Three noisy executions (thin gray lines), their mean (blue), and the analytical reference distribution (gray dashed). (b) FNO reconstruction (orange) and analytical reference (gray dashed). (c) Candidate-order probabilities before (blue) and after (orange) mitigation; the vertical dashed line marks the true order.
Transfer from Synthetic Data to IBM Hardware. We next study transfer from simulation to hardware. The FNO is trained on simulated noisy order-finding circuits with Mersenne moduli and applied to hardware measurements without further training. Since the FNO takes three independent measurement distributions as input, we group the hardware executions into sets of three to evaluate the effect of variability between measurements. Figure 9 compares runs 1–3, covering 101 circuit configurations, with two additional groups covering a subset of 35 configurations. For the complete set, exact-order recovery increases from 35% to 52%, top-3 recovery from 37% to 67%, and mean JS divergence decreases from 0.40 to 0.23. In both additional groups, the FNO correctly recovers five more orders than the raw decoder, while mean JS divergence decreases to approximately 0.23.
Figure 9. Zero-shot transfer of FNO-based mitigation to IBM quantum hardware. (a) Exact-order recovery, (b) top-3 recovery, and (c) mean JS divergence. Each group contains three independent executions per circuit, covering 101 configurations in runs 1-3 and 35 in each subsequent group.
Spectral Candidate Screening. Finally, we investigate whether accurate order recovery requires considering the complete set of candidate orders. This is important because the number of possible orders grows with the modulus , whereas the measured periodic structure may allow the search to be restricted to a smaller set. Figure 10 evaluates two screening strategies, based on analytical correlation and spectral correlation across independent executions, which rank the candidate orders before retaining the top for the final decision. With , both methods retain approximately 93% of the true orders and match the 33.5% recovery rate of exhaustive decoding, which considers 71 candidates on average.
Figure 10. Effect of candidate screening on order recovery. (a) Recall of the true order and (b) exact-order recovery as functions of candidate limit . The dotted line indicates exhaustive decoding. Error bars represent standard errors.
Discussion
The proposed QEM method could serve as a post-processing layer for circuits that use QEC. Residual logical errors can distort the distribution of logical measurement outcomes even after error correction. The QEM layer would use this distribution to estimate the ideal output distribution.
Selective Candidate Search. The order recovery results for general modular exponentiation and Mersenne rotation circuits use exhaustive decoding over candidate orders. The number of candidates therefore grows exponentially with the bit length of . For a fixed network architecture and precomputed analytical distributions, scoring candidates and reconstructing the output distribution costs . The Fourier transforms contribute the term. Comparing the measurements with the analytical distributions and forming their weighted mixture contribute the term.
Restricting the decision to the 32 highest-ranked candidates gives nearly the same recovery rate as exhaustive decoding, even though the true order is omitted in about 7% of the examples. The fraction of shortlists that contain the true order sets an upper bound on recovery, since the decoder can only return an order that it considers.
In the screening experiment, we compute the raw and adjusted scores over the full candidate set before applying the switching rule within the shortlist. To measure the computational savings of screening, the shortlist would need to be generated before FNO scoring, and its generation cost would need to be included. Scoring only the shortlisted candidates changes the gap to the best raw score, the standardization of the raw scores, and the mean subtracted from the MLP outputs. Therefore, recovery under this procedure needs to be evaluated separately.
Continued fractions offer one way to generate candidates directly from the measurements. The denominators of the convergents of provide candidate orders, and including small multiples accounts for cases where a denominator is a proper divisor of the true order. Seifert proposed simultaneous Diophantine approximation for order recovery from partial quantum information [24]. Ekerå developed related methods that use limited classical searches [8, 9]. For error mitigation, the relevant question is how often these methods include the true order when applied to noisy measurements.
Extension to Other Quantum Algorithms. Extending the method requires a model of how errors change the measurement distribution used to infer the algorithm’s result. Quantum phase estimation is a natural extension because it shares the inverse QFT and readout stages with Shor order finding. The corresponding error models can be adapted, while errors in the controlled operations must be modeled for the circuit at hand. The analytical references would describe the peaks expected for candidate eigenphases, with contributions weighted by the input state’s overlap with each eigenspace [6]. The same construction could be used for amplitude estimation based on phase estimation [4].
Quantum walks provide a second example. For a quantum walk, the output distribution gives the probability of finding the walker at each vertex [5, 12]. If noise mainly redistributes probability between neighboring vertices, graph diffusion provides a model for this effect. Starting from the ideal distribution, it spreads probability along the edges of the graph, broadening peaks. Varying the amount of spreading generates training examples with different levels of distortion. Diffusion weakens graph Fourier modes that vary sharply between neighboring vertices. A learned gain could amplify modes weakened by diffusion and attenuate modes dominated by sampling fluctuations.
Conclusions
We developed a theory-informed quantum error mitigation method for Shor order finding. Error propagation models guided network design and synthetic data generation. The method improved order recovery and distribution reconstruction on held-out simulated configurations and on IBM hardware for Mersenne rotation circuits. Further tests should address unseen moduli and noise outside the simulation model.
Future work will extend the hardware dataset to general modular exponentiation and test generalization to larger orders and precision register sizes absent from training. We will assess how often candidate screening retains the true order and how often the decoder recovers it. Experiments with substantially larger precision registers will require sparse representations of the measured distributions. A sparse encoder could compute selected Fourier coefficients directly from these outcomes and their counts. Conditional diffusion [16, 27] and flow matching [19] could also be explored for reconstruction from noisy measurements. Both could operate on the measured distributions or a reduced Fourier representation and produce a normalized mixture of analytical distributions that preserves the peak patterns predicted for candidate orders.
Acknowledgments
This research was funded by the Wallenberg AI, Autonomous Systems and Software Program (WASP) through the project “Machine Learning Methods for Reliable Quantum Computing” and by the Wallenberg Centre for Quantum Technology (WACQT).
References
- [1]Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, and Masanori Koyama. 2019. Optuna: A Next-generation Hyperparameter Optimization Framework. In 25th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. Association for Computing Machinery, 2623–2631. doi:10.1145/3292500.3330701DOI
- [2]Stéphane Beauregard. 2003. Circuit for Shor’s Algorithm Using 2n + 3 Qubits. Quantum Information and Computation 3, 2 (2003), 175–185. doi:10.26421/QIC3.2-8DOI
- [3]X. Bonet-Monroig, R. Sagastizabal, M. Singh, and T. E. O’Brien. 2018. Low-Cost Error Mitigation by Symmetry Verification. Physical Review A 98, 6 (2018), 062339. doi:10.1103/PhysRevA.98.062339
- [4]Gilles Brassard, Peter Hoyer, Michele Mosca, and Alain Tapp. 2002. Quantum Amplitude Amplification and Estimation. In Quantum Computation and Information, S. J. Lomonaco, Jr. and H. E. Brandt (Eds.). Contemporary Mathematics, Vol. 305. American Mathematical Society, 53–74. doi:10.1090/conm/305/05215DOI
- [5]Andrew M. Childs, Richard Cleve, Enrico Deotto, Edward Farhi, Sam Gutmann, and Daniel A. Spielman. 2003. Exponential Algorithmic Speedup by a Quantum Walk. In Thirty-Fifth Annual ACM Symposium on Theory of Computing. ACM, 59–68. doi:10.1145/780542.780552DOI
- [6]Richard Cleve, Artur Ekert, Chiara Macchiavello, and Michele Mosca. 1998. Quantum Algorithms Revisited. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences 454, 1969 (1998), 339–354. doi:10.1098/rspa.1998.0164DOI
- [7]Eric Dennis, Alexei Kitaev, Andrew Landahl, and John Preskill. 2002. Topological Quantum Memory. J. Math. Phys. 43, 9 (2002), 4452–4505. doi:10.1063/1.1499754DOI
- [8]Martin Ekerå. 2021. Quantum Algorithms for Computing General Discrete Logarithms and Orders with Tradeoffs. Journal of Mathematical Cryptology 15, 1 (2021), 359–407. doi:10.1515/jmc-2020-0006DOI
- [9]Martin Ekerå. 2024. On the Success Probability of Quantum Order Finding. ACM Transactions on Quantum Computing 5, 2 (2024), 1–40. doi:10.1145/3655026DOI
- [10]Artur Ekert and Richard Jozsa. 1996. Quantum Computation and Shor’s Factoring Algorithm. Reviews of Modern Physics 68, 3 (1996), 733–753. doi:10.1103/RevModPhys.68.733DOI
- [11]Suguru Endo, Simon C. Benjamin, and Ying Li. 2018. Practical Quantum Error Mitigation for Near-Future Applications. Physical Review X 8, 3 (2018), 031027. doi:10.1103/PhysRevX.8.031027DOI
- [12]Edward Farhi and Sam Gutmann. 1998. Quantum Computation and Decision Trees. Physical Review A 58, 2 (1998), 915–928. doi:10.1103/PhysRevA.58.915DOI
- [13]Google Quantum AI and Collaborators. 2025. Quantum Error Correction below the Surface Code Threshold. Nature 638 (2025), 920–926. doi:10.1038/s41586-024-08449-y
- [14]Daniel Gottesman. 1997. Stabilizer Codes and Quantum Error Correction. Ph.D. Dissertation. California Institute of Technology. arXiv:quant-ph/9705052 doi:10.7907/rzr7-dt72DOI
- [15]Nicholas J. Higham. 2002. Accuracy and Stability of Numerical Algorithms (2nd ed.). Society for Industrial and Applied Mathematics, Philadelphia, PA. ISBN 978-0-89871-521-7. doi:10.1137/1.9780898718027
- [16]Jonathan Ho, Ajay Jain, and Pieter Abbeel. 2020. Denoising Diffusion Probabilistic Models. In Advances in Neural Information Processing Systems, Vol. 33. 6840–6851.arxiv.org/abs/2006.11239
- [17]A. K. Lenstra and H. W. Lenstra, Jr. (Eds.). 1993. The Development of the Number Field Sieve. Lecture Notes in Mathematics, Vol. 1554. Springer, Berlin, Heidelberg. doi:10.1007/BFb0091534DOI
- [18]Zongyi Li, Nikola Kovachki, Kamyar Azizzadenesheli, Burigede Liu, Kaushik Bhattacharya, Andrew Stuart, and Anima Anandkumar. 2021. Fourier Neural Operator for Parametric Partial Differential Equations. In International Conference on Learning Representations. https://openreview.net/forum?id=c8P9NQVtmnO
- [19]Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel, and Matt Le. 2023. Flow Matching for Generative Modeling. In International Conference on Learning Representations. https://openreview.net/forum?id=PqvMRDCJT9tarxiv.org/abs/2210.02747
- [20]Kecheng Liu and Zhenyu Cai. 2025. Quantum Error Mitigation for Sampling Algorithms. arXiv:2502.11285 [quant-ph]
- [21]Stefano Markidis. 2024. What is quantum parallelism, anyhow?. In ISC High Performance 2024 Research Paper Proceedings (39th International Conference). Prometeus GmbH, 1–12.arxiv.org/abs/2405.07222
- [22]Thomas E. O’Brien, Stefano Polla, Nicholas C. Rubin, William J. Huggins, Sam McArdle, Sergio Boixo, Jarrod R. McClean, and Ryan Babbush. 2021. Error Mitigation via Verified Phase Estimation. PRX Quantum 2, 2 (2021), 020317. doi:10.1103/PRXQuantum.2.020317
- [23]David Poulin and Yeojin Chung. 2008. On the Iterative Decoding of Sparse Quantum Codes. Quantum Information and Computation 8, 10 (2008), 987–1000. arXiv:0801.1241 [quant-ph]arxiv.org/abs/0801.1241
- [24]Jean-Pierre Seifert. 2001. Using Fewer Qubits in Shor’s Factorization Algorithm via Simultaneous Diophantine Approximation. In Topics in Cryptology—CT-RSA 2001 (Lecture Notes in Computer Science, Vol. 2020), David Naccache (Ed.). Springer, 319–327. doi:10.1007/3-540-45353-9_24DOI
- [25]Peter W. Shor. 1995. Scheme for Reducing Decoherence in Quantum Computer Memory. Physical Review A 52, 4 (1995), R2493–R2496. doi:10.1103/PhysRevA.52.R2493DOI
- [26]Peter W. Shor. 1997. Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer. SIAM J. Comput. 26, 5 (1997), 1484–1509. doi:10.1137/S0036144598347011
- [27]Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. 2021. Score-Based Generative Modeling through Stochastic Differential Equations. In International Conference on Learning Representations. https://openreview.net/forum?id=KjQy-7N4jTR
- [28]Kristan Temme, Sergey Bravyi, and Jay M. Gambetta. 2017. Error Mitigation for Short-Depth Quantum Circuits. Physical Review Letters 119, 18 (2017), 180509. doi:10.1103/PhysRevLett.119.180509DOI
- [29]Lieven M. K. Vandersypen, Matthias Steffen, Gregory Breyta, Costantino S. Yannoni, Mark H. Sherwood, and Isaac L. Chuang. 2001. Experimental Realization of Shor’s Quantum Factoring Algorithm Using Nuclear Magnetic Resonance. Nature 414 (2001), 883–887. doi:10.1038/414883a
- [30]Vlatko Vedral, Adriano Barenco, and Artur Ekert. 1996. Quantum Networks for Elementary Arithmetic Operations. Physical Review A 54, 1 (1996), 147–153. doi:10.1103/PhysRevA.54.147DOI
- [31]James H. Wilkinson. 1963. Rounding Errors in Algebraic Processes. Prentice-Hall, Englewood Cliffs, NJ.







