Repository navigation
Conversation
Add tsim.experimental.count_determined_measurements and missing_detectors, the non-Clifford counterparts of Stim's methods, and nondeterministic_detectors, which lists the declared detectors and observables that are random without noise. A parity is determined when every noiseless record gives it the same value, so the determined parities annihilate the directions of the records' affine span. The exact path compiles the noiseless circuit and walks each tape's branches (Branches.support), adding unread fair coins as directions; unknown inputs enumerate their independent rotation signs, one walk per distinct signs of each tape. The sampled path spans the shots' differences. missing_detectors puts determined parities of random detectors first, which heals circuits whose S gates became T gates. Branches now drops an outcome by its probability given the lane, not by the lane's absolute weight, and gains support() and coin_rows. Integration tests reproduce published cultivation circuits: Chan et al.'s uncorrected and corrected d=5 circuits, each rule of Clifft's S-to-T converter, and Wan & Zapirain's d=3 and d=5 inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The repository ignores *.stim; the test data are an exception. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
☂️ Code Coverage
Overall Coverage
New Files
Modified Files
|
The other nine circuits checked claims of their papers; the unit tests cover correctness. Keep Chan et al.'s uncorrected d=5 circuit, a cultivation-sized T circuit with random detectors to heal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tors with a reference sample Each public function compiles the circuit; cache the span by the noiseless circuit text (not for shots without a seed) so calling all three compiles once. The missing-detector docstring and test sample with use_detector_reference_sample=True, since a Tsim detector is its raw parity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Warn about too few shots after the cache lookup, so a cache hit warns too. - Ignore the seed in the exact path's cache key. - Drop the exact path's single-pass batch loop and Span.contains. - Build declarations from record sets; share the random-declaration helper. - Suggest sampling when the exact walk exceeds its branch limit. - Compute each lane's weight once in Branches; test properties, not pivots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage cannot trace numba kernels, so the GF(2) span tests and one determined-measurement test also run them through py_func. Also test refused Pauli declarations and the support walk with split lanes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Stacked on #305 (
feat/shortest-errors), whoseBranchestape walk this reuses.What
This adds non-Clifford versions of Stim's
count_determined_measurementsandmissing_detectorstotsim.experimental, plus one function Stim has no counterpart for:shots=None):Branches.support.unknown_input=True, it starts withX_ERROR(0.5)on every qubit, enumerates the input bits that set independent rotation signs, and walks each tape once per distinct sign pattern.shots=n): spans the differences ofnnoiseless shots. It warns if a new direction still appeared in the second half of the shots.missing_detectorslists determined parities of random detectors first. For example, ifD1andD2became random butD1 ⊕ D2did not, that parity is returned. This repairs circuits whose S gates became T gates.Changes to
BranchesIMPOSSIBLE. Previously the lane's absolute weight was compared. Example:R_Xwith probability 1e-7 on two qubits, then CCX: the joint outcome has probability 1e-14 but is possible. This affectsshortest_errorsas well.support(f)andcoin_rows.Literature checks
One-off runs on published circuits; the exact and sampled (1000 shots) methods agree on all of them. Only Chan et al.'s uncorrected d=5 circuit is kept as an integration test (
test/data/determined, whose README gives its source and license).convert_s_to_t.pyPerformance
The GF(2) span, its annihilator, and the overlaps of declarations with directions run in numba on packed 64-bit words. Healing works only on the random declarations.
Tests
unknown_input, both exact and sampled.Notes
count_determined_measurementsrejectsMPAD, and its type stub saysmissing_detectorsreturns anint..gitignoregains!test/data/**/*.stimso the test circuits are tracked.🤖 Generated with Claude Code