Cheaper Reed–Solomon error locators
Reduce the Toffoli cost of the error-locator step that coherent Reed–Solomon decoders run on syndromes in superposition.
Leaderboard: GF(32), two errors Hot
QArena's record 941 Toffoli gates by QArena's own run Ties it
| # | Participant | Score (Toffoli gates) | vs QArena baseline | Submission |
|---|---|---|---|---|
| 1 | qarena-baseline (QArena's run)(QArena) Baseline | 941 | #4 |
Baseline: QArena's own run: 941 Toffoli gates (nothing published fits this instance)
Instance: Field and gate set
Overview
Task
This is the error-locator kernel of a Reed–Solomon decoder that corrects up to t = 2 errors; the two GF(16) instances with t = 3
(see "The t = 3 instances" below) do the same for up to three errors. Large-t decoders, such as those in
Decoded Quantum Interferometry, run Berlekamp–Massey instead. Write a reversible circuit of X, CNOT and Toffoli gates that computes the
error-locator polynomial from the syndromes (four for t = 2, six for t = 3), coherently, using a limited number of workspace qubits that start and end in
|0〉, with as few Toffoli gates as possible. On the -mx instances, measurements and Z corrections are allowed as well (see below).
The field is GF(2m) in the polynomial basis. Bit j of an integer is the coefficient of zj, addition is XOR,
and multiplication is carry-less polynomial multiplication reduced modulo the instance's polynomial: z4 + z + 1
(modulus 19) for m = 4 and z5 + z2 + 1 (modulus 37) for m = 5. Write q = 2m.
The error locations are the q − 1 nonzero field elements. An error pattern is one of three things:
- empty;
- one location a with a nonzero magnitude e;
- two distinct locations a < b with nonzero magnitudes e and f.
Its four syndromes are Sj = ∑ eaaj for j = 1, 2, 3, 4. Its normalized locator is
Λ(Z) = ∏a in the support (1 + aZ) = 1 + λ1Z + λ2Z2,
so its roots are the inverse locations, and (λ1, λ2) is (0, 0), (a, 0) or (a + b, ab). The circuit must map
|S1, S2, S3, S4〉 |0m, 0m〉 |0A〉 → |S1, S2, S3, S4〉 |λ1, λ2〉 |0A〉
for every promised syndrome tuple, meaning the syndromes of some pattern above. There are 1 + (q−1)2 + C(q−1, 2)(q−1)2 patterns, and their syndrome tuples are all distinct: 23,851 for m = 4 (out of 65,536 tuples) and 447,827 for m = 5 (out of 1,048,576). Other syndrome tuples are outside the contract, and the circuit may do anything on them. Every promised tuple counts, including the empty pattern, the 1,575 and 14,415 two-error tuples with S1 = 0, and tuples where some other syndrome is 0.
| Instance | Field | Promised tuples | Workspace limit | Gate limit | Operations |
|---|---|---|---|---|---|
| rs-q16-t2-a64 | GF(16), z4 + z + 1 | 23,851 | 64 | 4,096 | X, CX, CCX |
| rs-q32-t2-a96 | GF(32), z5 + z2 + 1 | 447,827 | 96 | 4,096 | X, CX, CCX |
| rs-q16-t2-a64-mx | GF(16), z4 + z + 1 | 23,851 | 64 | 4,096 | also MX, RZ, PZ |
| rs-q32-t2-a96-mx | GF(32), z5 + z2 + 1 | 447,827 | 96 | 4,096 | also MX, RZ, PZ |
| rs-q16-t3-a160 | GF(16), z4 + z + 1, t = 3 | 1,559,476 | 160 | 8,192 | X, CX, CCX |
| rs-q16-t3-a160-mx | GF(16), z4 + z + 1, t = 3 | 1,559,476 | 160 | 8,192 | also MX, RZ, PZ |
The six instances are ranked separately. On the -mx twins the circuit may measure workspace qubits in the X basis, prepare
them again, and apply Z gates conditioned on the outcomes. These are the rules of the qrom measurement cells and the constant-add board, so a
temporary value can be removed by a measurement instead of being uncomputed, provided the sign the measurement leaves is corrected.
A reversible circuit is also valid on its twin, with the same score.
Known answers, which follow from the field arithmetic (the last four rows use locations 1 and 2, with magnitudes (1, 1) and (2, 1)):
| Field | [S1, S2, S3, S4] | [λ1, λ2] |
|---|---|---|
| either | [0, 0, 0, 0] | [0, 0] |
| either | [1, 1, 1, 1] | [1, 0] |
| GF(16) | [3, 5, 9, 2] | [3, 2] |
| GF(16) | [0, 6, 10, 1] | [3, 2] |
| GF(32) | [3, 5, 9, 17] | [3, 2] |
| GF(32) | [0, 6, 10, 18] | [3, 2] |
The t = 3 instances
rs-q16-t3-a160 and its twin rs-q16-t3-a160-mx use the same field, GF(16) with modulus 19, and the same rules
with t = 3, the case of the Reed–Solomon code RS(15, 9). An error pattern is empty, or has one, two or three distinct locations a < b < c
with nonzero magnitudes. The six syndromes are Sj = ∑ eaaj for j = 1, …, 6, the locator is
Λ(Z) = 1 + λ1Z + λ2Z2 + λ3Z3, and
(λ1, λ2, λ3) is (0, 0, 0), (a, 0, 0), (a + b, ab, 0) or (a + b + c, ab + ac + bc, abc).
The circuit must map |S1, …, S6〉 |012〉 |0A〉 to |S1, …, S6〉
|λ1, λ2, λ3〉 |0A〉 on every promised tuple. There are
1 + 225 + 23,625 + 1,535,625 = 1,559,476 of them out of 224 tuples. They are all distinct, because the code has minimum distance 7, and
every one of them is checked.
- Wires, every field register least significant bit first: bit i of Sj+1 is wire 4j + i (j = 0, …, 5, wires 0 to 23), bit i of λk is wire 24 + 4(k − 1) + i (wires 24 to 35), and workspace qubit k is wire 36 + k. Every operand must be one of the wires 0 to 35 + A.
- Limits: at most 160 workspace qubits and 8,192 operations. A file may be 524,288 bytes, with at most 8,194 arrays and objects, 16,388 quotation marks
and 32,768 commas. On the twin the limits are 16,386 arrays and objects and 36,864 commas, at most 1,024 measurements and at most 4,096 record
numbers in
bitslists. - Everything else is as for t = 2: the operations, the strict parsing, the measurement rules of the twin, the score and the tie-breaks.
| [S1, …, S6] | [λ1, λ2, λ3] | Pattern (location, magnitude) |
|---|---|---|
| [0, 0, 0, 0, 0, 0] | [0, 0, 0] | empty |
| [1, 1, 1, 1, 1, 1] | [1, 0, 0] | (1, 1) |
| [3, 5, 9, 2, 7, 13] | [3, 2, 0] | (1, 1), (2, 1) |
| [0, 0, 6, 0, 1, 7] | [0, 7, 6] | (1, 1), (2, 1), (3, 1) |
| [3, 5, 10, 2, 7, 8] | [3, 14, 4] | (4, 1), (8, 1), (15, 1) |
| [6, 5, 7, 0, 2, 3] | [7, 14, 8] | (1, 1), (2, 2), (4, 4) |
GF(32) with t = 3 is not an instance. It has 134,358,372 promised tuples out of 230. The verifier's method, one integer per wire with one bit for every address, would need 128 MiB per wire and about 300 wires, far more than the 16 GB of a verification runner.
Submission file
JSON structure:
{"ancillas": 1,
"ops": [["CX", 0, 16], ["CCX", 1, 5, 24], ["CX", 24, 20], ["CCX", 1, 5, 24]]}
This example only shows the format; it is not a valid locator circuit. The verifier bundle contains the accepted house circuit for rs-q32-t2-a96.
ancillas: the number A of workspace qubits, from 0 to the instance limit. It is the third ranking key, so declare only the ones you use.- Wires are numbered as follows, with every field register least significant bit first:
- bit i of Sj+1 is wire jm + i (j = 0, 1, 2, 3);
- bit i of λ1 is wire 4m + i;
- bit i of λ2 is wire 5m + i;
- workspace qubit k is wire 6m + k.
ops: at most 4,096 operations (8,192 on the t = 3 instances), applied in order, each in one of these exact forms:["X",t]flips wire t.["CX",c,t]flips t when c is 1.["CCX",c1,c2,t](Toffoli) flips t when c1 and c2 are both 1.
- On the
-mxinstances three more operations are allowed. Every wire that X, CX or CCX touches must be live (see MX).["MX",q]measures the live workspace qubit q in the X basis. Each measurement appends one record bit (0 for the outcome +1, 1 for −1), and records are numbered 0, 1, 2, … in order. The wire then becomes inactive. Syndrome and locator wires cannot be measured.["RZ",q]prepares the inactive workspace qubit q in |0〉 and makes it live again. A live wire cannot be reset.["PZ",q,bits,value]applies Z to the live wire q, which may be a syndrome, locator or workspace wire.valueis 0 or 1 andbitsis a strictly increasing list of records that already exist. As on every QArena board, the operation is applied exactly when the XOR of the listed record bits equalsvalue. An empty list has XOR 0, so["PZ",q,[],0]is an unconditional Z, and["PZ",q,[],1]does nothing but still counts. Over the whole file, at most 16,384 record numbers may appear inbitslists (4,096 on the t = 3 twin).
- Only the final state is checked. During the circuit any wire, including the syndrome and locator wires, may hold intermediate values.
- Files may be at most 262,144 bytes (524,288 on the t = 3 instances, which have their own counts above). Before decoding, the verifier also counts JSON arrays and objects (at most 4,098), quotation marks
(at most 8,196) and commas (at most 16,384). On the
-mxinstances the limits are 8,194 arrays and objects (a PZ holds a list) and 32,768 commas. Every valid file fits these limits. - Parsing is strict: exactly the two keys, no duplicate keys, and wire numbers, record numbers and values must be JSON integers (not
true,1.0or"1").
Validation
The verifier checks every promised syndrome at once by bit slicing:
- It checks the format, the limits and every wire number, and counts the operations in a structural pass.
- It builds the field's multiplication table, then enumerates every error pattern: the empty one, every location with every magnitude, and every pair of locations with every pair of magnitudes. For each pattern it sets one bit at the address u = S1 + 2mS2 + 22mS3 + 23mS4 in a promise column and writes (λ1, λ2) from the pattern's support into 2m reference columns. The reference never comes from a decoding formula. If two patterns ever gave the same address, the verifier would return an error instead of a verdict.
- Each wire holds one integer with 24m bits, where bit u is the wire's value on the syndrome tuple with address u. The syndrome wires start as the bit patterns of the addresses and all other wires start at 0. An X gate is an XOR with all ones, a CNOT is an XOR of two wires, and a Toffoli is an AND followed by an XOR.
- After the last operation, on every promised address, it checks that the syndrome wires still hold their starting values, that the locator wires hold the reference, and that every workspace wire is 0.
X, CNOT and Toffoli gates permute basis states without adding a phase, so a circuit that is right on every promised basis input is right on every superposition of them. A rejection reports how many promised tuples fail, and how many of those have a wrong locator, a changed syndrome or a dirty workspace qubit. It also gives the first failing tuple, with the expected and the computed locator.
On the -mx instances the verifier also tracks every sign exactly, as for the qrom measurement cells. Measuring a wire that holds
f(u), with outcome r, multiplies the branch by (−1)r·f(u), up to a factor of 1/√2. A PZ adds the current value of its
wire to the exponent of every record it lists, and also to the constant term p0 when value is 0. The sign of a branch
is therefore (−1) to the power p0(u) + ∑ rjpj+1(u). The file is accepted only if, in addition to the
checks above, every p is constant on the promised tuples (all 0 or all 1 there). Then every outcome leaves the right locator, up to a
global sign. The condition is also necessary: if pj+1 varies over the promised tuples, the outcome with only rj = 1 gives a wrong
state. Values on unpromised tuples do not matter here either.
The verifier reports format and life-cycle errors first, then wrong wire values, then the first sign that varies (p0, then the lowest record). It drops each record's column after its last use. Records are followed in batches of 256 (at m = 5), and each later batch replays the circuit, so memory stays bounded.
On one core of a shared desktop machine (Ryzen 9 9950X) the GF(32) house circuit verifies in under 0.5 s of CPU time and 30 MB. The heaviest files the limits allow verify in at most 2.5 s and about 70 MB (81 MB of address space): 4,096 dense Toffoli gates, or 1,440 measurement records all held to the end and checked in six batches, with 15,840 record references. Memory peaks with 997 dense records opened in the middle of the circuit, while its registers still hold values. The limits of the t = 2 instances are 60 s and 128 MB. If the CPU limit ran out, the result would be an error with no score, never a partial check.
The t = 3 instances work the same way on 224-bit integers (2 MiB per wire, about 200 wires) and enumerate 1,559,476 patterns. The house circuit verifies in 2.7 s of CPU time and 430 MB on the same machine. The heaviest files found take at most 14 s and 1,071 MB (1,087 MB of address space). In both, every wire ends dense (zero on the promised syndromes, nonzero on most other addresses) and dense measurement records are held to the end: 1,024 of them for the most memory, or 769, which replays the circuit in four batches of 256, for the most CPU time. The board's limits are 60 s and 2,048 MB, and the t = 2 instances still need under 3 s and 81 MB.
Scoring
Each instance is ranked by the number of Toffoli (CCX) gates. Fewer Toffoli gates rank first. Equal counts are ranked by fewer operations
in total, where X, CX and CCX count 1 each, and on the -mx instances MX, RZ and PZ do too. Remaining ties are ranked by fewer
declared workspace qubits, then by submission number (lower first). Operations are counted as written. The verifier does not simplify the
circuit, so two cancelling gates both count, and so does a gate whose controls are never both 1 on a promised input.
Baseline and reference scores
The house baseline is the specification's reference construction. It is deliberately straightforward and makes every exceptional case explicit. Write J(0) = 0 and J(a) = aq−2 (the inverse of a nonzero a). It computes these values into fresh registers, in this order:
D = S1S3 + S22, N1 = S1S4 + S2S3, N2 = S2S4 + S32, ID = J(D), I1 = J(S1), Z = D·ID, B = S2I1.
It then sets λ1 = N1ID + (1 + Z)B and λ2 = N2ID, and finally runs every intermediate step again in reverse order. For two errors, D = ef·ab(a + b)2 ≠ 0 and Z = 1. For one error, D = 0, S1 ≠ 0 and S2/S1 = a. With no errors every term vanishes. The primitive expansion is fixed:
- A product c ^= ab is one CCX(ai, bj, ck) for every coefficient k of zi+j mod P that is 1 (22 Toffoli gates in GF(16), 36 in GF(32)).
- A square is one CNOT per 1 coefficient of z2i mod P.
- J uses m − 2 rounds of square-and-multiply into fresh registers, followed by one final square.
- (1 + Z)B is an X on the low bit of Z, one CCX per bit of B into λ1, and the X again.
- There is no gate cancellation.
The generator is tools/gen_rslocator.py. The baseline uses (4m − 1)m workspace qubits.
| Instance | Toffoli | Gates | Workspace |
|---|---|---|---|
| rs-q16-t2-a64 and rs-q16-t2-a64-mx | 488 | 586 | 60 |
| rs-q32-t2-a96 and rs-q32-t2-a96-mx | 941 | 1,103 | 95 |
| rs-q16-t3-a160 and rs-q16-t3-a160-mx | 1,622 | 1,840 | 144 |
The t = 3 baseline (reference_construction_t3 in the same generator) solves the Hankel system
[S1 S2 S3; S2 S3 S4; S3 S4 S5] (λ3, λ2, λ1)T
= (S4, S5, S6)T by Cramer's rule: the determinant D3 and the three numerators are expanded over GF(2) into products
of three syndromes, each product is built from shared squares and pair products in fresh registers, and the quotients use I3 = J(D3), so that
λk = NkI3. D3 is nonzero exactly for three errors. With Z3 = D3I3, the two-error and one-error
formulas above are added under the control 1 + Z3: λ1 += (1 + Z3)(N1'ID + (1 + Z)B) and
λ2 += (1 + Z3)N2'ID, where N1' and N2' are the t = 2 numerators and D, ID, Z and B are as for t = 2.
The intermediate steps are run again in reverse order. The same primitive expansion applies and there is no gate cancellation.
The -mx twins start from the same circuit. Measurement does not help this construction under Z corrections. A register that is
measured instead of uncomputed holds a product of syndrome-dependent values, and no later wire holds that value again. Its sign could only be
cancelled by PZ gates on wires whose values XOR to it, so every uncomputing step stays reversible. Measurement pays off in circuits that
recompute a value anyway, or in circuits that hold the same value on another wire (see the qrom measurement cells).
Much better circuits are possible, and none is known to be optimal. Some directions:
- Products with fewer Toffoli gates: the bilinear rank of multiplication is 9 in GF(16) and 13 in GF(32) (see the andcount board), against 22 and 36 here.
- Inversion by lookup or by shorter addition chains.
- Fewer field operations overall. For example, on every promised tuple N1 = Dλ1 and N2 = Dλ2.
- Computing only the bit of Z that matters: D·J(D) is 0 or 1.
Synthesis that proved a matching lower bound would close a cell, and that cell would then be retired.
Reference: a reversible Reed–Solomon decoder for DQI found with language models (arXiv:2610.22367) gives application context and stronger algorithms at larger parameters. Its full-decoder costs are not locator-only scores, and no conversion to this exact interface has been checked, so none is listed as a reference score.
Application
Decoded Quantum Interferometry (DQI) and other coherent decoding algorithms run a Reed–Solomon decoder inside a quantum circuit, on syndromes held in superposition, and the locator computation is its arithmetic core. This board isolates the t = 2 and t = 3 locator kernels with exact interfaces, so that circuit ideas such as cheaper field products, inversion and case handling can be compared on equal terms. A record lowers the Toffoli cost of this locator map under its workspace limit. It does not by itself establish an improvement in a full decoder, in its success probability, or in the complete DQI algorithm. The Kaggle DQI task (display only on QArena) covers a full decoder.
Where verification runs
Verifications of this board run on the first lane of this list that is up and has room: the Mac mini, then CU Boulder's Alpine, then NCAR Derecho, then RunPod. A lane that is down, full or slow passes the file to the next one automatically, with the same verifier version; the limits of one verification are 60 s of CPU, 210 s of wall time and 2,048 MB of memory on the Mac mini, and 120 s of CPU, 300 s of wall time and 2,048 MB of memory on CU Boulder's Alpine, NCAR Derecho and RunPod (2 times the board's own CPU and wall time on the other lanes, because their processors are slower); the result goes to QArena only.
Current records
| Instance | Baseline | Record (Toffoli gates) | Reference score | Record holder | Status |
|---|---|---|---|---|---|
| GF(32), two errors Hot
m = 5, z^5 + z^2 + 1; 447,827 promised syndromes; at most 96 workspace qubits |
941 QArena's run | 941 | – No published count for this interface |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
| GF(16), two errors
m = 4, z^4 + z + 1; 23,851 promised syndromes; at most 64 workspace qubits |
488 QArena's run | 488 | – No published count for this interface |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
| GF(16), two errors, with measurement
m = 4, z^4 + z + 1; 23,851 promised syndromes; at most 64 workspace qubits; X-basis measurements and conditioned Z gates allowed |
488 QArena's run | 488 | – No published count in this gate set |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
| GF(32), two errors, with measurement
m = 5, z^5 + z^2 + 1; 447,827 promised syndromes; at most 96 workspace qubits; X-basis measurements and conditioned Z gates allowed |
941 QArena's run | 941 | – No published count in this gate set |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
| GF(16), three errors
m = 4, z^4 + z + 1; six syndromes; 1,559,476 promised syndromes; at most 160 workspace qubits |
1,622 QArena's run | 1,622 | – No published count for this interface |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
| GF(16), three errors, with measurement
m = 4, z^4 + z + 1; six syndromes; 1,559,476 promised syndromes; at most 160 workspace qubits; X-basis measurements and conditioned Z gates allowed |
1,622 QArena's run | 1,622 | – No published count in this gate set |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
The baseline of an instance is its published result where there is one (the hot instance's famous result, a cited published reference, or a published result or method on its leaderboard), else QArena's own run. Reference scores come from cited papers or derived constructions.
Record changes
The first strict improvement on a ranked instance will appear here as a card, and a chart will follow the headline record over time.
Headline record now:
- RS error locator, GF(32), two errors: 941 Toffoli gates (exact) by QArena baseline