Repository navigation
Update contextuality module to match published Science paper - #505
Conversation
- Remove withdrawn effective_layers metric from ShallowCircuitResults and replace with classical_bound (4 / classical_layers, matching Fig. 4B). - Update shallow_circuits_experiment_test.py to test classical_bound against valid-outcome probabilities. - Update module docstrings across recirq/contextuality to cite Science 394, 870-874 (2026) (DOI 10.1126/science.aec3042), and standardize Bell-Kochen-Specker (BKS) and magic square naming.
|
@mhucka ready for review! |
mhucka
left a comment
There was a problem hiding this comment.
Thanks for doing the updates so quickly!
In addition to the specific comments below, can you also please do a sweep for non-inclusive terms? In particular,
- avoid "master" (e.g., in "master list")
- avoid "dummy" (e.g., in "dummy index")
Possible replacements include "main list" or "primary list", and "placeholder index" or just "index".
| for num_qubits in self.total_dof.keys(): | ||
| classical_layers[num_qubits] = math.ceil(np.log2(self.total_dof[num_qubits])) | ||
| classical_bound[num_qubits] = 4.0 / classical_layers[num_qubits] |
There was a problem hiding this comment.
I think this may have some problems:
-
When
n_qubits == 1(accepted by bothhlf_circuit_biased_dropoutandShallowCircuitExperiment),total_cz == 0sototal_dof == 1andclassical_layers[1] == 0. Previously_analyze()succeeded because it guardedif score > 0:before dividing; now4.0 / 0raisesZeroDivisionErrorinside_analyze(), breaking all three properties (probability_of_valid_outcomes,classical_layers, andclassical_bound) for any run containingn_qubits=1(ortotal_dof <= 1). -
For
n_qubitsin{2, 3, 4}on a 2D grid (total_dof <= 8),classical_layersis2or3, yieldingclassical_boundvalues of2.0or1.333...(> 1.0), which is invalid for a success-probability bound.
There was a problem hiding this comment.
Great point, the probability should not be grater than 1. Fixing it.
There was a problem hiding this comment.
Possibly missed:
| """Estimate chi_BKS (with uncertainty) from a context_to_parities mapping.""" |
| return self._classical_layers | ||
|
|
||
| @property | ||
| def classical_bound(self) -> dict[int, float] | None: |
There was a problem hiding this comment.
| def classical_bound(self) -> dict[int, float] | None: | |
| def classical_bound(self) -> dict[int, float]: |
| """Builds a Bell-Kochen-Specker (BKS) experiment, which measures state-independent contextuality. | ||
|
|
||
| See https://arxiv.org/pdf/2512.02284 for more details. | ||
| See Google Quantum AI and Collaborators, Science 394, 870-874 (2026) | ||
| (https://doi.org/10.1126/science.aec3042) for more details. |
There was a problem hiding this comment.
I'm not sure why the CI didn't pick this up, but the line length is > 100.
| """Builds a Bell-Kochen-Specker (BKS) experiment, which measures state-independent contextuality. | |
| See https://arxiv.org/pdf/2512.02284 for more details. | |
| See Google Quantum AI and Collaborators, Science 394, 870-874 (2026) | |
| (https://doi.org/10.1126/science.aec3042) for more details. | |
| """Builds a Bell-Kochen-Specker (BKS) experiment, which measures state-independent | |
| contextuality. See Google Quantum AI and Collaborators, Science 394, 870-874 (2026) | |
| (https://doi.org/10.1126/science.aec3042) for more details. |
| list of tuples containing whether each tuples of previous context, where each | ||
| tuple contains the axis context corresponds to a row or column context. For the |
There was a problem hiding this comment.
I can't figure out what this sentence means. Maybe something got garbled?
- Clamp classical_bound at 1.0 when classical_layers <= 4 (fixing ZeroDivisionError at total_dof=1 and bounds > 1.0) and tighten its return type to dict[int, float]. - Add key-set equality assertions in test_experiment() and a direct unit test covering small total_dof edge cases and lazy initialization of classical_bound. - Add module docstring to kochen_specker.py, apply exact docstring suggestions, and clarify estimate_coincidences docstring. - Replace non-inclusive terms (master -> primary, dummy -> placeholder).
|
Thanks for the thorough review, @mhucka! Addressed all comments in the latest commit. Ready for another look. |
Making changes to match the content in the published paper: Science 394, 870-874 (2026) (DOI 10.1126/science.aec3042)