Refactor: decouple Run/Protocol from Client, add RandomTraps sampling, detection_rate, and round-count optimisation#22
Draft
jemappellesami wants to merge 41 commits into
Draft
Conversation
…r RandomTraps suitability
…s, noise comment, benchmark dedup, disconnected-graph rank assertion
…r RandomTraps suitability
…r RandomTraps suitability
…s, noise comment, benchmark dedup, disconnected-graph rank assertion
…an code, also cleaner dummyless test
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.
Summary
Builds on
dummyless3.Refactors the canvas-sampling procedure to support the
RandomTrapsverification protocol, in which the client samples a fresh random multi-qubit trap at each test round rather than drawing from a pre-computed set. DecouplesRunandVerificationProtocolfromClient. Addsdetection_rateto the protocol interface and a newutil_roundsmodule for computing optimal round counts from security parameters.What changed
RandomTrapsand thesample_test_runinterfaceIn the
RandomTrapsprotocol ([KKLM+22, §6.3.1](https://arxiv.org/pdf/2206.00631)), the client samples a uniformly random non-empty subset of nodes at each test round and uses it as a single multi-qubit trap. The set of possible test runs is the powerset ofV— it cannot be stored or pre-computed, so the prior approach of indexing a fixed list at round time does not work.VerificationProtocolgains a new abstract method:FK12DummylessRandomTrapssample_canvasnow routes throughself.protocol.sample_test_run(...)instead of directly indexingtest_runs. ForRandomTraps,create_test_runsreturns[].This also fixes a prior bug where trap size was sampled from
[0, n), allowing empty traps.detection_rateproperty onVerificationProtocolAll protocols now expose a
detection_rateproperty:FK121 / n_colorscreate_test_runsDummyless1/14RandomTraps1/2Decoupling
RunandVerificationProtocolfromClientRunno longer holds aClientreference. The execution method is renamed fromdelegatetoaccept, following the visitor pattern:ComputationRunandTestRunforward to two new methods onClient:Client.execute_computation_run(backend, noise_model, rng)Client.execute_test_run(test_run, backend, noise_model, rng)The
clifford_structuretableau is no longer stored onClient. Instead,get_graph_clifford_structure(graph)(moved fromclient.pytoverifying.py) is called on-demand insidebuild_stabilizer. This is valid because MBQC verification protocols depend only on the graph entanglement structure, not on client-specific state.Signatures that changed:
New module:
veriphix/util_rounds.pyImplements analytic bounds and optimizers for round-count design, built on Hoeffding-based security bounds from [SO26](https://arxiv.org/abs/2601.07111) (Appendix B, itself building on [LMKO21](https://arxiv.org/abs/2109.04042)). Those references bound the security error given fixed round counts
(d, s, w)and a noise level;util_rounds.pyinverts this direction — given a security targetεand protocol parameters, find the round counts that achieve it. This is the practically meaningful direction: in deployment, one fixes the desired security level and asks for the minimum experimental overhead.The core bound (
bounds_corrected_delta) is split between a test side and a computation side, withdelta_tildeandlambda_phias free parameters that trade off between the two.optimize_with_robustness_constraintGiven security target
εand minimum robustnessρ_min(the noise level the protocol must tolerate), finds the minimum total roundsd + ssatisfying both.maximize_robustness_under_budgetThe dual problem: given a fixed round budget
d + sand security targetε, finds the maximum tolerated noise levelw/s.Both have
_over_lambdavariants that jointly optimize overlambda_phiin addition todelta_tilde.Minor changes
FK12— proper-colouring validation ofmanual_colouringmoved fromcreate_test_runsinto__init__, so invalid colourings fail at construction time.MaliciousNoiseModel— removed a duplicateself.nodesassignment and stale commented-out code..github/workflows/ruff.yml— ruff pinned to0.15.12in both lint and format steps.Why
RandomTrapsrequires the client to independently re-sample a trap for every test round. The old interface forced pre-computation of a fixed list, which is both semantically incorrect (samples are not independent) and infeasible (the powerset ofVcannot be stored). Thesample_test_runabstraction resolves this without special-casingRandomTrapsanywhere in the canvas loop.Removing the
Clientdependency fromRunandVerificationProtocolis the structural prerequisite: aTestRunbuilt only from the graph can be constructed on-the-fly by any protocol, without a boundClientat setup time.Testing
test_random_general_traps_average_detection_ratetest_random_traps_performancetest_designed_rounds_noiselessoptimize_with_robustness_constraintfeed correctly intoTrappifiedSchemeParameters; all traps pass with an honest servertest_designed_rounds_bqp_circuitprob = ρ_min / 2still pass traps and return the correct majority-vote answerAll existing tests updated to the new
acceptandTestRun(graph=..., nqubits=..., traps=...)APIs.Risks / Notes
RandomTraps.create_test_runsreturns[]— this is intentional.Clientcallscreate_test_runsat initialization, soclient.test_runsis always correctly populated: a non-empty list forFK12andDummyless, and an empty list forRandomTraps(where sampling happens on-the-fly throughsample_test_runat canvas time). The only risk is code that callsprotocol.create_test_runsdirectly and expects a non-empty result forRandomTraps.detection_rate— forFK12andDummyless, the rate is set insidecreate_test_runs. SinceClientcalls this at initialization,detection_rateis valid by the time it is accessible through aClientinstance. Reading it directly on a bare protocol object beforecreate_test_runshas been called returns a stale default, not the graph-specific value.PR description drafted with [Claude Code](https://claude.ai/code) from the git diff and manual author annotations.