arXiv:2611.06819quant-phNov 2026

Manuscript Offprint

arXiv:2611.06819

GFlowQEC: Generative Flow Networks that Learn to Sample Quantum LDPC Codes

Nuno Batista, Gabriel Falcao, Penousal Machado

Nuno Batista¹, Gabriel Falcão²,³, and Penousal Machado⁴

¹ Department of Informatics Engineering, University of Coimbra, Coimbra, Portugal ² Instituto de Telecomunicações, Department of Electrical and Computer Engineering, University of Coimbra, Coimbra, Portugal ³ New York University Abu Dhabi, Abu Dhabi, United Arab Emirates ⁴ University of Coimbra, CISUC/LASI – Centre for Informatics and Systems of the University of Coimbra, Department of Informatics Engineering nuno.batista@uc.pt, gff9537@nyu.edu, machado@dei.uc.pt

Abstract. Choosing a quantum error-correcting code for a real device means scoring candidates with circuit-level simulations so slow that only a few hundred can be run. So every evaluation counts, and a search is judged by how many good codes it finds per paid evaluation. Quantum LDPC codes built from a few group elements protect many logical qubits, but good ones are rare in a huge space. We introduce GFlowQEC, to our knowledge the first generative flow network (GFlowNet) for quantum code design. It builds a code one group element at a time and learns to propose codes in proportion to a power of their score. We train it once on scores from earlier searches, freeze it, and let it propose lifted-product codes with 180 physical qubits, scored by their distances. Ranking ten of its draws per paid call, it finds more than twice as many new top-scoring codes (inequivalent to any it was trained on) as tuned parallel tempering, even when tempering starts from GFlowQEC's training codes. It finds more than three and a half times as many as a supervised screen ranking ten random candidates per call. When both rank a hundred, the screen beats GFlowQEC, and does best ranking GFlowQEC's draws. Soft Q-learning, which shares the GFlowNet's optimal policy, does as well at one noise bias and better at the other, so the gain does not depend on the GFlowNet's training loss. Trained proposers can make a budget of expensive evaluations go further when good codes are rare.

Keywords: Quantum error correction · Quantum LDPC codes · Generative flow networks · Code search

  • This work is funded by national funds through FCT – Foundation for Science and Technology, I.P., within the scope of the research unit UID/00326 – Centre for Informatics and Systems of the University of Coimbra, https://doi.org/10.54499/UID/00326/2025. This work is funded by national funds through FCT – Fundação para a Ciência e a Tecnologia, I.P., and, when eligible, co-funded by EU funds under project/support UID/50008/2025 – Instituto de Telecomunicações, with DOI identifier https://doi.org/10.54499/UID/50008/2025.

2 N. Batista et al.

1 Introduction

Quantum low-density parity-check (LDPC) codes can protect many logical qubits in a single block of physical qubits [25,6]. Many of them are specified by a short list of elements of a finite group, and since every list gives a valid code [23,31], designing one amounts to a search over lists. That search is hard for two reasons. The space is enormous: the [[300, 60, 14]] mitten code of Bhardwaj et al. [4] is a list of ten elements of a group with sixty elements, and lists of that length give up to about 3×1083 \times 10^8 inequivalent codes. And every candidate has to be scored, either by computing its distance or by simulating how often it fails, which takes from about a second to a few minutes per code. A search therefore only ever sees a sliver of the space.

Our motivating setting is choosing a code for a particular device. There, each candidate is scored by a circuit-level simulation, with faulty measurements and a real decoder, which takes minutes to hours per code, so a search scores only hundreds [42,5,4]. Since the best code can also change with the device's noise and connectivity [5,3], a cheaper score can only shortlist candidates for the expensive simulation, so a search should deliver many good candidates for its budget rather than a single best one [1]. Because methods cannot yet be compared fairly at that price, we compare them where scoring is cheap enough to run each method many times, but we keep the unit of cost that matters on a device: the paid call, that is, one call to the scoring routine (the oracle) for a code the run has not scored before.

Bayesian optimisation, reinforcement learning, filtered uniform sampling and large language models (LLMs) have already been used to search code families of this kind, and Table 1 compares these searches with ours. None of them, however, trains a model to sample codes in proportion to their quality.

Learning can turn a fixed budget into more good codes in two ways. A screen draws random candidates and pays only for the ones a learned model ranks highest, whereas a proposer learns to draw good candidates directly. When good codes are rare, the difference matters: a screen has to look at many random candidates for every one it keeps, while a proposer builds that rejection into its own draws. Generative flow networks (GFlowNets) [1,2] are proposers of this kind. A GFlowNet builds an object step by step and is trained so that, at its optimum, it produces each object with probability proportional to a reward, which means one model yields many distinct good objects where reward maximisation would converge on one [1]. To our knowledge, no GFlowNet has yet been used to design quantum error-correcting codes.

This paper makes two contributions.

  • We introduce GFlowQEC, a GFlowNet whose policy fills in the list one group element per step and is trained with trajectory balance [41] to produce each list with probability proportional to a power of its score.

  • We test this policy, as a proof of concept, on lifted-product codes with 180 physical qubits, where it is trained once on scores stored from earlier searches, frozen, and compared with tuned parallel tempering, a supervised screen and soft Q-learning at matched budgets of paid calls.

Table 1. Prior code searches compared with this paper. LP stands for lifted product and BB for bivariate bicycle codes, two-block codes built from two sums of elements of Zl×ZmZ_l \times Z_m, the pairs of integers mod ll and mod mm (Bravyi et al. [5] allow only pairs with one entry zero).

WorkFamilyScoreReturnsMatched budgetExact distances
Chengyu et al. [10], Bayesian optimisationBB, any weightRate k/nk/n and error rateone code per weightingyesno
Cruz-Benito et al. [11], LLMBBkd2/nkd^2/na cataloguepartlysome
Liu and Marquardt [24], LLMLPRate k/nk/n and error ratean archivenono
Bhardwaj et al. [4], filtered samplingLP, non-abelianDistance upper boundsone code per groupnosome
Sella et al. [34], reinforcement learningBB as defined by Bravyi et al. [5]Decoder success ratebest code so farnono
Freire et al. [13], three searchesHypergraph productErasure failure rateone best codeyesnot stated
This paper, GFlowNet policyLP, non-abelianFailure exponent, Eq. (7)codes proposed and ranked by one frozen policyyessome

At 180 physical qubits the frozen policy draws ten candidates for each paid call and pays for the ones it ranks most probable. Counting only codes inequivalent to those it was trained on, it found more than twice as many top-scoring codes per paid call as tuned parallel tempering (tuned PT), 2.4 and 2.8 times as many at the two noise biases we test, where bit flips are ten times likelier than phase flips or the reverse. Started from the same stored codes, tuned PT did not close the gap, so the lead is not just access to the stored data. It also found more than three and a half times as many as a supervised screen built on the same network and trained on the same scores. Because only about one random code in a hundred is top-scoring here, a screen shown ten random codes per paid call rarely sees one. Shown a hundred random codes per paid call, the screen found more than the policy, and the largest count of all came from a screen that ranked the policy's own draws. Soft Q-learning trained in the same way, which shares the GFlowNet's optimal policy on our construction [38], did as well at one bias and better at the other, so the gain does not depend on the GFlowNet's training loss.

N. Batista et al.

A longer version with all settings and further results is available with the code and data at https://doi.org/10.5281/zenodo.23922222.

References (42)