Repository navigation
Answer connected-cluster coset batches in one compiled call per block - #1067
Merged
Merged
Conversation
ConnectedClusterCosetSearch gets the batch queries find_first_not_within_max_weight and get_min_weights of BrouwerZimmermannCosetSearch, with the same signatures, floors, and thread options. Each block of a batch runs in one nogil compiled call, _find_first_not_within_max_weight or _find_min_weights, which maps each syndrome to the sparser checks, finds its words of weight at most one by comparing it with the checks of the symbols of its first check, and tries increasing weight limits with _search_supports. CosetLeaderSearch drives these searches as it drives BZ searches, so the Python batch loops of _connected_cluster/coset.py are gone. Single queries keep their Python path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…cuts of single queries A test counts the states that a batch query visits, through the work that its compiled loop counts, and compares them with those of single queries at the same limits, on a case where restrict_viable_symbols and the overlap cuts each change that number. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… queries The test of the restriction and the overlap cuts of batch queries counts the states that _find_first_not_within_max_weight visits too, as it does for _find_min_weights. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…er a tuple of tables The batch queries find_first_not_within_max_weight and get_min_weights of ConnectedClusterCosetSearch now run one compiled loop, _find_min_weights, through one helper, _search_batch. The loop writes the weight of each syndrome, and stops at the first above max_weight only when find_first_not_within_max_weight asks it to, so both queries keep their results and their requirements on threads, and numba compiles one version for both. The loop and _get_min_weight take the tables of the search of the sparser checks as one plain tuple, _BatchTables, as the BZ coset searches take their tails, instead of fifteen separate arguments. _get_min_weight unpacks it once per query, and names each table in its call of _search_supports, since star-unpacking the tuples there made the queries a few percent slower. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ther case catches - The test of pair sums checks single queries only: the batch queries read the same check tables, and the tests that compare them with exhaustive minima and with the states of single queries catch batch tables with pair sums. - The test that batches search with the restriction and cuts of single queries counts the states of the one batch loop once, and leaves their answers to the test of exhaustive minima. - The test of exhaustive minima checks get_min_weights with random floors only, which are zero at max_weight zero; a separate run with floors of zero caught no further mutation of the loop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ount unsuccessful work - A batch of the checks I3, whose minimum weights are the bit counts of the syndromes, moves to two threads after its first query, so a block starts at its second row; that row must start its search from its own floor of zero, not from the floor 3 of the first row. - A batch of 32 copies of a syndrome of minimum weight 3 on a five-qubit graph state, whose searches at the limit 2 visit states without finding an error, must move to threads, so the work of unsuccessful searches counts toward split_work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ocks The test of floors in blocks now also runs a batch of 34 syndromes of the checks I3 on two threads, long enough for blocks of several rows with differing floors, whose syndromes of weight 2 each do work, and whose first syndrome of weight 3 follows such a syndrome in its block. The expected weights are the bit counts of the syndromes, and the first index without a word within max_weight is that of the syndrome of weight 3. The docstring says that the rest of a batch moves to blocks, which up to two threads run, rather than that the batch runs on two threads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… end of the batch The first batch of the test of floors in blocks now has a third syndrome with the floor 3, so that taking a block's floors from the end of the batch, like taking them from its start, gives the second syndrome a weight above its minimum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The long batch of the test of floors in blocks now has the floors 0 to 3 at max_weight 3, so that a block that read the floors of its rows in another order would answer some syndrome of weight 2 from a floor of 3. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pattern Fixed pseudorandom floors from 0 to 3 make a block that took the floors of other rows, in any order or offset, answer some row wrongly, which a regular pattern of floors could hide. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ck minima A new test runs the batch queries of a coset search on more than 64 checks, copies of a block, by Pauli and by binary checks, against the sums of the minima of the blocks and against single queries, on one to three threads with random split work and floors. Its syndromes of the last copy reach the second word alone, so that a search that misread the words of a mapped syndrome would misweigh a coset. The test of batch states now also checks a class of minimum weight three, whose batch query counts the states of both limits that it tries, and the test of floors in blocks checks that a batch whose first query ends it ends there, even with no split work. The cut switch of the test of batch states, the long batch of the test of floors in blocks, and the graph-state batch of the test of threads go, since the other cases catch every bug that they catch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… work A new test calls the batch loop of connected-cluster coset searches directly on the checks I64, whose syndromes fill exactly one word, with its tables and again with an empty fixed_words, which selects the version of the search for any number of words. Its batch repeats a syndrome of one bit and has syndromes of two bits, so the loop must size, clear and compare the mapped syndrome by the words of the map, not by fixed_words. Three queries whose states fill the work budget after two must stop there and leave the third weight unwritten, so the loop must add up the work of its queries. The test of batches of syndromes of two words keeps only its Pauli checks, since its binary checks caught no bug that another case misses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ectangular checks The test of the compiled batch loop now checks its budget from the floors 0, 2, and 2, where every query searches from limit two and must count its states, and with no work allowed after a first query that looks up its word and visits no states. It weighs its batch at max_weight 2 only, since max_weight 1 caught no bug that another case misses. A new test runs batch queries on the checks [I2 | 0], whose syndromes fill one 64-bit word while their 65 variables fill two, so that batches must size the syndromes of their searches by the checks. The test of batches of syndromes of two words compares the bound of its first rejected syndrome in one assertion, which every seed reaches, now that its Pauli checks alone can leave classes above the largest max_weight that it tries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…hecks A seeded test runs the batch loop of connected-cluster coset searches on identity checks of 3, 4, 63, 64, 65, and 129 rows, whose syndromes have their bit counts as minimum weights. Its batches have syndromes of random bits in each word alone, across the first and last words, and anywhere, and start with one that the loop looks up. At each max_weight up to five, with random floors, the loop must give the weights that _get_min_weight states, with the tables of the search and with an empty fixed_words; the first syndrome without a word within max_weight must get the bound of a single query; and a budget of the states that the single searches of any number of leading rows visit must stop the loop at the row that reaches it and leave the later weights unwritten. The fixed test of the batch loop on I64 and the test of batches of syndromes of two words on graph states go, since the new test and the others catch every bug that they catch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ed rows The randomized test of the compiled batch loop now also runs on three checks of six variables with exhaustive minima, where floors above the number of checks must search up to the number of variables, and checks its budgets with floors at max_weight too. A loop that stops at the first syndrome without a word within max_weight must write that syndrome's weight and no later one. A new test answers a batch with tables of identity checks of eight and nine 64-bit words, the largest that the fixed versions of the search take and the smallest that they do not. Its searches are assembled directly, since building them takes seconds as plain Python. Two older gaps close too. A single query on checks [I2 | 0] must size its syndrome by the checks, not by the 65 variables. Batches of minimum weights by CSS weight on |0>^65 and |+>^65 must read both words of the syndromes of their X and Z parts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Drop the test of nine-word batch tables, the budget sweep with its rectangular checks, the identity checks other than I64 and I65, and the checks that repeat other cases, and count the states of a batch query with two calls of the loop. Drop the tests of single-query sizing and of CSS-weight batches over several words, whose behavior this change leaves as it was. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
CosetLeaderSearchwithmethod="connected_cluster"answered the batch queriesfind_first_not_within_max_weightandget_min_weightsone syndrome at a time in Python. For each syndrome it mapped the syndrome to the sparser checks, built aMinWeightBound, and called the compiled_search_supportsonce per weight limit. On the batches thatcertify_bounded_fault_propagationmakes, most queries visit one to six states. So the Python work around each compiled call, 14-17 µs per query, was 60-70% of the batch time. At fault weight 6, on flagged preparations of the [[82,2,13]] and [[144,12,12]] codes, these batches made up 85-87% of a certification call.Changes
ConnectedClusterCosetSearchgets the batch queries ofBrouwerZimmermannCosetSearch, with the same signatures, floors and thread options. Each block of a batch runs in one compiled call,_find_min_weights, without the global interpreter lock. For each syndrome, that call maps it to the sparser checks, finds its words of weight at most one by comparing it with the checks of the symbols of its first check, and tries increasing weight limits with_search_supports. Both queries share this loop:find_first_not_within_max_weightasks it to stop at the first syndrome abovemax_weight. The compiled code takes the search's tables as one plain tuple,_BatchTables, as the Brouwer-Zimmermann coset search takes its record of tails.CosetLeaderSearchnow drives both methods' searches through one code path, so the Python batch loops of_connected_cluster/coset.pyare gone. Single queries keep their Python path.connected_cluster.mdandproblems.mddescribe the batch path.Validation
On a sample of 52 state-preparation circuits, every certificate, threshold answer and minimum weight equals the previous code's. The counterexamples replay as violations with Stim. The same holds for two [[79,1,15]] preparations at orders 5 and 7. The tests compare batch queries with single queries and with exhaustive minima. They count the states that the compiled loop visits, on a case where restricting to viable symbols and the overlap cuts each change that count, so the batch path is checked to use the pruning of single queries. They also run batches on threads, checking that each block takes the floors of its own rows.
Times are single-threaded and warm, medians of 3 to 5:
max_weightOver the 52 circuits, certification with this method drops from 87.2 to 45.6 CPU-s. Threads give no further gain on these batches, which stay below the size at which a batch is split across threads. The first search on a new syndrome width compiles once per installed version of the source. That compilation takes about 6.1 s instead of 4.6 s, because the batch loop is compiled too.