Manuscript Offprint
arXiv:2611.02370State Synthesis with an NP oracle
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
In this note, I describe a quantum algorithm that prepares an arbitrary state to inverse exponential precision in polynomial time by making queries to an NP oracle, assuming one can directly query entries of the state vector corresponding to . The previous best upper bound on the complexity class required by an oracle for this task was PP. I provide evidence that NP is the best possible upper bound by showing that any quantum algorithm using a P oracle, or even a P/poly oracle, requires exponentially many queries. I also discuss some implications of this result for the QMA search-to-decision problem and unitary synthesis.
1 Introduction
The state synthesis problem was first studied by Aaronson [Aar16], and asks how many queries a quantum algorithm needs to make to some classical boolean function such that approximately prepares an arbitrary state . The circuit corresponding to should be the same for every state, but the function is allowed to arbitrarily depend on . This problem is motivated by asking if the complexity of preparing any state can be reduced to the complexity of implementing some classical boolean function. A natural question to ask is then how weak can we make , in terms of its complexity, such that we could efficiently prepare an arbitrary ? This is the central question considered in this note. Let us assume a meta-oracle (or just ) can directly query entries of to any desired bits of precision, since in general the amplitudes may even be uncomputable. The main result is as follows.
Theorem 1.1. There exists a quantum algorithm running in poly time such that, for every -qubit state , there exists an oracle , such that prepares a state having fidelity at least with . The algorithm makes poly queries to , where is an oracle for the entries of .
Setting implies can prepare to inverse-exponential error in poly time. Furthermore, a second result shows that if is allowed to be in rather than just , the algorithm requires at most queries. This is proved in Section 2. Now, what was previously known about the power of needed? The best known upper bound was that suffices, initially by an algorithm using queries [Aar16]. Prior work on state synthesis has mainly focused on reducing the number of queries needed for this task. In particular, [INN] showed that a PP oracle with 1 query suffices for state synthesis to obtain inverse-polynomial precision, which was improved by Rosenthal, showing 1 query suffices to obtain inverse-exponential precision [Ros24].
However, the construction in [Ros24] uses an even stronger PSPACE oracle. In this work, I will sacrifice the progress made towards reducing the number of queries and just focus on reducing the power of the oracle instead. The algorithm presented here builds on the original state synthesis algorithm by Aaronson [Aar16], from which one can notice it almost directly follows that suffices to get inverse-polynomial error, and which forms the starting point of the algorithm here. The surprising part is that we can get inverse-exponential error as well. The key ideas combine simple insights from complexity theory and quantum algorithms, in particular including approximate counting with an NP oracle [Sto85], quantum rejection sampling [ORR13], and exact amplitude amplification [BHMT00]. The algorithm is described in Section 2. I provide evidence that it is optimal in the sense of being the weakest oracle possible for efficient state synthesis, by showing in the Appendix that a oracle does not suffice, even when given polynomially bits of advice. The proof goes through a straightforward reduction from the lower bound for unordered search. To motivate this result further, let us consider the following direct consequence of Theorem 1.1.
Corollary 1.2. Consider a language such that . Then, any quantum state whose amplitudes can be computed in polynomial time with an oracle for can also be prepared to inverse-exponential error in quantum polynomial time with an oracle for .
This follows just by observing that for such a language, suffices to apply to prepare by applying Theorem 1.1. This shows that the search problem of preparing a state reduces to the problem of computing the amplitudes, given an oracle can be implemented efficiently. Notice that inverse-exponential error is in some sense the closest we can get to exact preparation, since beyond this we run into issues that involve specifying a gate set. Most interesting applications require this error guarantee in state preparation; it has been important in the context of state synthesis [INN+21, Ros24], as well as in defining unitary complexity classes [KT26]. Now, it is well known that state synthesis is the quantum version of classically sampling from a probability distribution. Consequently, Theorem 1.1 can also be viewed as a quantum state witness analogue of classical results by Bellare, Goldreich, Petrank [BGP00] and Jerrum, Valiant, Vazirani [JVV86], who show how to exactly sample NP-witnesses given access to an NP oracle. Indeed, the techniques here bear similarities to the approach by [JVV86]. Further discussion and open problems are deferred to Section 3.
Theorem 2.1 (Restatement of Theorem 1.1). There exists a quantum algorithm running in poly time such that, for every -qubit state , there exists an oracle , such that prepares a state having fidelity at least with . The algorithm makes poly queries to , where is an oracle for the entries of .
Proof. Our starting point is an algorithm first proposed by Grover and Rudolph [GR02] for preparing quantum states and adapted in the context of state synthesis by Aaronson [Aar16]. We first briefly describe this algorithm for clarity, setting the desired error for ease of exposition. It involves preparing the target state by computing prefix-sums. Consider the probability distribution over -length bitstrings corresponding to the amplitudes of up to polynomial (or polylog) bits of precision. Let us define the prefix sum , where consists of all length bitstrings. In other words, is the marginal probability when fixing the prefix to be . We start by preparing the 1-prefix state , followed by applying a rotation on the second qubit conditioned on the value of the first qubit such that it prepares the 2-prefix state as follows.
(1)
(2)
This involves querying the oracle in order to compute the value of each conditional rotation depending on , followed by a unitary that implements it, and then uncomputing the rotation value at the end with another query. We iteratively apply this process of conditional rotations, preparing each -prefix state, which is defined as follows.
After repeating this process times, we obtain the so-called state . To reduce the number of queries for this, we can instead also batch the iteration into groups of qubits. Each controlled rotation just gets replaced by some unitary on qubits, which remains efficient to implement. But the number of queries reduces to . Now, in order to prepare , we only need to add the phases , which we can do with just 2 extra queries to : query the phase on an ancilla register, apply a conditional phase oracle, and finally uncompute the phase. Since each prefix sum requires adding an exponential list of non-negative real numbers, this algorithm requires to be a PP oracle.
Our goal will now be to relax the requirement for the PP oracle to an NP oracle. The first key observation we need to make for our algorithm is that approximate counting [Sto85] allows us to estimate counting problems in #P to inverse polynomial precision in poly(n) time with a BPP oracle. Since our quantum algorithm can simulate the randomness required by any BPP algorithm, this shows that we can calculate any prefix sum to inverse polynomial precision. A simple calculation shows that this allows us to prepare to inverse polynomial precision. However, our goal is to prepare to inverse-exponential precision, as discussed in the introduction. Then, it seems like we made almost no progress, since an NP oracle does not let us calculate prefix sums to inverse-exponential precision, unless .
This brings us to our second key idea. We will use the state prepared by approximate counting as a warm start for the rest of our algorithm. We will invoke our NP oracle again, importantly making use of the fact that an NP oracle can trivially access each probability amplitude of in superposition. This suggests we could try to check how close each approximation was and try to factor out the error, classically known as rejection sampling. This leads us to utilizing a slightly modified version of quantum rejection sampling—first proposed by Ozols, Roetteler, and Roland [ORR13]—as follows.
We start with the state as prepared through approximate counting of prefix-sums followed by the appropriate phase queries. Then, we again use our NP oracle to query the true probability amplitude of each basis state onto an additional ancilla register in superposition. We also query the value of onto yet another register, which just requires us to repeat our initial NP queries over the same choice of randomness. So, we obtain the state
up to only polylog(1/ ) = poly(n) bits of precision, so note that may not equal 1, as is not normalized. In fact, calculating this normalization itself is in #P. However, we assume it is normalized for now, and account for it only in the error analysis. This will just incur an additional inverse-exponential error.
where each is obtained through a product of sufficiently good approximate prefix-sums such that it satisfies the guarantee that . Next, we apply a rotation gate on one more ancilla register, controlled on the value of on the second and third register, such that (after uncomputing and discarding the two intermediate registers) it prepares the following state . The guarantee on the ratio between and is crucial in order for this rotation to be both approximately balanced and well-defined, which shows why our warm start state through approximate counting is needed for our algorithm.
Note that post-selected on measuring on the second register collapses to the state . So it only remains to boost the probability of measuring , which we will call the good branch of our superposition. Thus, the final subroutine we need is amplitude amplification. Notice that the probability on the good branch is , since up to an inverse-exponential error (see footnote 1). So, we just run an exact amplitude amplification algorithm [BHMT00] to boost the probability of the branch from to . Then, we simply measure and discard the second register. Thus, as desired, we have prepared the state
such that , given some . The error guarantee and runtime of this algorithm are proved in Lemma 2.2 as follows.
Lemma 2.2. The algorithm in Theorem 1.1 makes at most poly(n) queries to an NP oracle—alternately queries to a oracle—runs in at most poly time, and outputs a state such that .
Proof. Preparing the approximate counting state and querying the values of approximate counts dominates the number of queries required. In particular, we need queries to an approximate counting subroutine. In addition, we just require a constant number of additional NP queries to get the phases and the values of (to polylog) bits) onto an ancilla register, via the Bernstein–Vazirani trick [INN+21]. Exact amplitude amplification requires us to repeat this process a constant number of times. Thus, given a oracle, our algorithm would need just queries, as it could give us the approximate counting values directly [Sto85] given access to random bits. To verify we get the desired error guarantee, recall that we require each probability amplitude to be within a factor of 2 of . Each is a product of ratios of approximate prefix sums, so estimating every prefix sum to within a factor with guarantees this; a algorithm just requires poly time for this, with failure probability after a union bound and boosting through repetition [Sto85].
We can simulate each such query to a computation with queries of length to an NP oracle, over a fixed choice of random bits throughout. Thus, the algorithm requires polynomial queries; and since each unitary we implement takes at most time (to implement any controlled rotation for instance), the algorithm also runs in time.
Now, let us bound the error in preparing the state given the above error guarantee on each prefix sum. With this guarantee, we know that the rotation gate to prepare the state is well-defined. Now, we just bound the error between and the ideal such state that has the exact encoded in its amplitudes. Each entry of their state vectors agrees up to relative error, so the two states are within in norm. After constant rounds of amplitude amplification, note that becomes exactly and for , amplitude amplification uses unitaries that are at most within operator norm of the ideal ones, so we end up getting a state within of . Thus, except with probability over the random bits, . So, by a standard argument, we can prepare (with the same global phase) in superposition over all choices of poly size random bits, and then cleanly uncompute them at the end, along with rescaling , to deterministically obtain such that .
3 Discussion
This algorithm highlights the power of BQP with an NP oracle, addressing a question raised explicitly in [GK24]. This result also extends a result by Grover and Rudolph [GR02], who showed how to prepare quantum states corresponding to efficiently integrable distributions; here we just require the distribution to be approximately integrable—to error instead of —as long as it is also pointwise efficiently computable. Further, slightly modifying the algorithm also approximately prepares, without the oracle , any state with amplitudes computable in .
Let us now consider the longstanding question of whether QMA-complete problems admit search-to-decision reductions. Theorem 1.1 implies that QMA-search, which is the problem of preparing QMA witness states, essentially reduces to the complexity of computing the amplitudes of the state, since NP QMA. However, it seems unlikely the amplitudes themselves could also be computed in QMA, since the amplitudes could encode a GapP-complete problem. Considering the contrapositive direction might be more useful. If we want to prove that there exists a classical oracle relative to which search-to-decision does not exist for QMA, the oracle needs to satisfy the property that amplitudes of QMA witness states cannot be computed in any class such that NP.
Open Problems. There are a few concrete future directions that appear interesting. The first is motivated by the original question posed by [Aar16] on reducing the number of queries for state synthesis.
Question 1. Can the number of queries for efficient state synthesis with an NP oracle be made sublinear or even constant?
I conjecture that the answer to this question is yes, perhaps requiring only one query, and that it would need to go through a technique that does not involve computing prefix-sums, since this seems inherently limited at queries, even with a oracle. I believe the approach given by the algorithm here could extend to such an upper bound with just an NP oracle, via a more fine-grained analysis of the approximate counting step in particular, but no further. Weakening the oracle required by constant query state synthesis algorithms [INN+21, Ros24] appears to be the obvious initial route towards this goal.
There is also a broader question we could consider. The Unitary Synthesis Problem asks if any unitary can be approximately implemented by a quantum algorithm making a polynomial number of queries to a classical boolean function [Aar16, LMW24]. It is clear that state synthesis is a special case of unitary synthesis. Thus, Theorem 1.1 directly prompts the following question.
Question 2. For every -qubit unitary , does there exist a function , such that can be approximately implemented by a quantum algorithm making a polynomial number of queries to an oracle?
Here, the meta-oracle would have query access to the entries of the classical description of in the computational basis. I conjecture that the answer to this question is also yes, largely due to a recent claimed solution by OpenAI for the Unitary Synthesis Problem [OAI26], and related progress by Nehoran, Slote, and Yuen [NSY26]. A clear route to proving this would be to reduce an algorithm for unitary synthesis to just using state synthesis as a black box, with some slack of additional queries that require nothing more powerful than an oracle. Conversely, it is possible that may be the weakest non-trivial class (i.e., larger than ) with respect to which an exponential query lower bound exists. Proving this would likely require new techniques, since the lower bound would need to be with respect to a specific complexity of the oracle, rather than an arbitrary boolean function.
Acknowledgments
I thank Scott Aaronson, William Kretschmer, and Ronak Ramachandran for helpful discussions and comments. Generative AI was used for literature search, assisting with the error analysis, and proofreading the final draft.
References
[Aar16] Scott Aaronson. The complexity of quantum states and transformations: from quantum money to black holes. arXiv preprint arXiv:1607.05256, 2016.
[BBBV97] Charles H Bennett, Ethan Bernstein, Gilles Brassard, and Umesh Vazirani. Strengths and weaknesses of quantum computing. SIAM journal on Computing, 26(5):1510–1523, 1997.
[BGP00] Mihir Bellare, Oded Goldreich, and Erez Petrank. Uniform generation of np-witnesses using an np-oracle. Information and Computation, 163(2):510–526, 2000.
[BHMT00] Gilles Brassard, Peter Hoyer, Michele Mosca, and Alain Tapp. Quantum amplitude amplification and estimation. arXiv preprint quant-ph/0005055, 2000.
[GK24] Sevag Gharibian and Jonas Kamminga. Bqp, meet np: Search-to-decision reductions and approximate counting. arXiv preprint arXiv:2401.03943, 2024.
[GR02] L Grover and T Rudolph. Creating superpositions that correspond to efficiently integrable probability distributions. arXiv preprint quant-ph/0208112, 2002.
[INN+21] Sandy Irani, Anand Natarajan, Chinmay Nirkhe, Sujit Rao, and Henry Yuen. Quantum search-to-decision reductions and the state synthesis problem. arXiv preprint arXiv:2111.02999, 2021.
[JVV86] Mark R Jerrum, Leslie G Valiant, and Vijay V Vazirani. Random generation of combinatorial structures from a uniform distribution. Theoretical computer science, 43:169–188, 1986.
[KT26] William Kretschmer and Ewin Tang. Unitary complexity in polynomial space. arXiv preprint arXiv:2610.03705, 2026.
[LMW24] Alex Lombardi, Fermi Ma, and John Wright. A one-query lower bound for unitary synthesis and breaking quantum cryptography. In Proceedings of the 56th Annual ACM Symposium on Theory of Computing, pages 979–990, 2024.
[NABT14] Aran Nayebi, Scott Aaronson, Aleksandrs Belovs, and Luca Trevisan. Quantum lower bound for inverting a permutation with advice. arXiv preprint arXiv:1408.3193, 2014.
[NSY26] Barak Nehoran, Joseph Slote, and Henry Yuen. All unitaries have constant depth quantum circuits. arXiv preprint arXiv:2609.40351, 2026.
[OAI26] OpenAI. Polynomial-Time Unitary Synthesis from a Boolean Oracle. OpenAI Math Release preprint github.com/openai/math/blob/main/preprints/Polynomial-Time-Unitary-Synthesis-from-a-Boolean-Oracle-October-5-2026/paper.pdf, 2026.
[ORR13] Maris Ozols, Martin Roetteler, and Jérémie Roland. Quantum rejection sampling. ACM Transactions on Computation Theory (TOCT), 5(3):1–33, 2013.
[Ros24] Gregory Rosenthal. Efficient quantum state synthesis with one query. In Proceedings of the 2024 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2508–2534. SIAM, 2024.
[Sto85] Larry Stockmeyer. On approximation algorithms for# p. SIAM Journal on Computing, 14(4):849–861, 1985.
A Lower bound with a P/poly oracle
Lemma A.1. Consider a quantum algorithm such that, for every -qubit state , there exists an oracle , such that prepares a state having at least fidelity with . Then, needs to make queries to , where is an oracle for the entries of .
Proof. We give a simple reduction from the lower bound for unordered search. Consider the set of basis states , , and consider the simpler problem where the algorithm just needs to prepare some basis state and is allowed to make queries to , but only has query access to the entries of . Since , BQP can simulate any queries makes to directly with polynomial bits of advice. Now, notice that any algorithm that could prepare would solve the search problem for finding a marked element with query access via to the size state vector of . By the lower bound for unordered search [BBBV97], even with polynomial bits of advice [NABT14] (note that the advice can only depend on ), needs to make at least queries to . This concludes the proof.