Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
mathematics
information-theory
quantum-information
representation-theory
bosonic-memory
task-relative-compression
Download tests/test_physical_limits.py from PureOne/ORYNTHRA-H6: direct link, hf CLI and curl.
- Browser
- Download file 2.57 kB
-
https://huggingface.co/datasets/PureOne/ORYNTHRA-H6/resolve/main/tests/test_physical_limits.py
- Command line
-
hf download hf://datasets/PureOne/ORYNTHRA-H6/tests/test_physical_limits.py
-
curl -L -o test_physical_limits.py https://huggingface.co/datasets/PureOne/ORYNTHRA-H6/resolve/main/tests/test_physical_limits.py
2.57 kB
| """Regression checks for dephasing, photon loss, spectral gaps, and worked atlas.""" | |
| from pathlib import Path | |
| import sys | |
| import numpy as np | |
| from scipy.linalg import expm | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "code")) | |
| from orynthra import simplex_code, observable_closure, LinearEdge, permutation_matrix | |
| def test_dephasing_destroys_exact_distinguishability(): | |
| v, _, _ = simplex_code(6, 2) | |
| rho = [] | |
| for j in range(6): | |
| pure = np.outer(v[:, j], v[:, j]) | |
| pure[0, 1:] = 0 | |
| pure[1:, 0] = 0 | |
| rho.append(pure) | |
| assert np.isclose(np.trace(pure), 1) | |
| for i in range(6): | |
| for j in range(i): | |
| assert np.isclose(np.trace(rho[i] @ rho[j]), 1/18) | |
| def test_h6_fails_one_photon_loss_knill_laflamme_condition(): | |
| v, _, _ = simplex_code(6, 2) | |
| n1 = np.diag([0, 4, 3, 2, 1, 0]) | |
| logical_error_gram = v.T @ n1 @ v | |
| eigenvalues = np.linalg.eigvalsh(logical_error_gram) | |
| assert np.allclose(eigenvalues, [0, 0, 1, 2, 3, 4]) | |
| assert not np.allclose(logical_error_gram, | |
| np.eye(6) * np.trace(logical_error_gram)/6) | |
| def test_gap_sensitive_commutator_bound_on_seeded_unitaries(): | |
| rng = np.random.default_rng(20261009) | |
| n = 6 | |
| energies = np.cumsum(rng.uniform(0.5, 1.5, n)) | |
| gap = np.min(np.diff(energies)) | |
| h = np.diag(energies) | |
| a = permutation_matrix(list(range(1, n)) + [0]) | |
| b = permutation_matrix([1, 0] + list(range(2, n))) | |
| assert np.isclose(np.linalg.norm(a @ b - b @ a, 2), np.sqrt(3)) | |
| for t in [0, 0.001, 0.02, 0.1, 1]: | |
| us = [] | |
| for _ in range(2): | |
| x = rng.normal(size=(n, n)) + 1j*rng.normal(size=(n, n)) | |
| x = (x + x.conj().T)/2 | |
| u = np.diag(np.exp(1j*rng.uniform(-1, 1, n))) @ expm(1j*t*x) | |
| us.append(u) | |
| ua, ub = us | |
| eta = sum(np.linalg.norm(h @ u - u @ h, "fro") for u in us) | |
| physical_comm = np.linalg.norm(ua @ ub - ub @ ua, 2) | |
| assert physical_comm <= 2*eta/gap + 1e-12 | |
| eps = np.linalg.norm(ua-a, 2) + np.linalg.norm(ub-b, 2) | |
| assert np.sqrt(3) <= 2*eps + 2*eta/gap + 1e-12 | |
| def test_two_domain_worked_example(): | |
| j = np.array([[0,1,0],[1,0,0],[0,0,1]]) | |
| loop = np.array([[1,0,0],[0,0,1],[0,1,0]]) | |
| obs = [np.array([[1,0,0]]), np.array([[1,0,0]])] | |
| edges = [LinearEdge(0,1,j), LinearEdge(1,0,j)] | |
| bases, _ = observable_closure(obs, edges) | |
| assert [len(b) for b in bases] == [2,2] | |
| bases, _ = observable_closure(obs, edges+[LinearEdge(0,0,loop)]) | |
| assert [len(b) for b in bases] == [3,3] | |