### Advanced Usage of Tesseract Decoder with Multiple Options Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Illustrates an advanced command-line invocation of the Tesseract decoder, showcasing various configuration options. This example includes setting priority queue limits, detector error constraints, sampling seeds, thread counts, beam search parameters, and shot range processing. ```bash ./tesseract \ --pqlimit 1000000 \ --at-most-two-errors-per-detector \ --det-order-seed 232852747 \ --circuit circuit_file.stim \ --sample-seed 232856747 \ --sample-num-shots 10000 \ --threads 32 \ --print-stats \ --beam 23 \ --num-det-orders 1 \ --shot-range-begin 582 \ --shot-range-end 583 ``` -------------------------------- ### Define iniconfig Python Dependency with Hashes Source: https://github.com/quantumlib/tesseract-decoder/blob/main/src/py/requirements_lock.txt Specifies the 'iniconfig' package version 2.1.0, including its SHA256 hashes for integrity verification. This dependency is noted as being required via 'pytest', ensuring that the correct version is installed for testing frameworks. ```Python Requirements iniconfig==2.1.0 \n --hash=sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7 \n --hash=sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760 # via pytest ``` -------------------------------- ### Surface Code .stim Filename Convention Source: https://github.com/quantumlib/tesseract-decoder/blob/main/testdata/README.md Example filename for rotated surface code `.stim` files, encoding parameters such as number of rounds (r), code distance (d), noise probability (p), noise model (noise), code type (c), number of qubits (q), and gates used (gates). These files are used for protocols introduced by Dennis et al. ```text r=11,d=11,p=0.0001,noise=si1000,c=surface_code_X,q=241,gates=cz.stim ``` -------------------------------- ### JavaScript Global Variables and Three.js Material Setup Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html Initializes global variables for scene management, animation state, user interface elements, and Three.js objects. This includes camera distance, scene objects, animation timers, rotation speeds, view toggles, and material definitions for rendering spheres with different visual properties (e.g., transparent gray, solid blue, solid red). ```JavaScript let zoomDistance = 30; let scene, camera, renderer; let activeEdges = []; let errorToDetectors = {}; let detectorMeshes = {}; let activeDetectors = []; let activeErrors = []; let frames = []; let errorCoords = {}; let frameIndex = 0; let playing = true; let frameInterval = 1000 / 3; let animationTimer = null; let rotationAngle = 0; let spinSpeed = 0.003; let topDownView = false; let loop = false; let sphereGeo = new THREE.SphereGeometry(0.2, 16, 16); let grayMat = new THREE.MeshPhysicalMaterial({ color: 0xffffff, metalness: 0.25, roughness: 0.1, transmission: 1.0, thickness: 0.5, transparent: true, opacity: 0.3, clearcoat: 1.0, clearcoatRoughness: 0.1 }); let blueMat = new THREE.MeshPhongMaterial({ color: 0x0077ff }); let redMat = new THREE.MeshPhongMaterial({ color: 0xff0000 }); const fileInput = document.getElementById('fileInput'); const speedSlider = document.getElementById('speedSlider'); const speedDisplay = document.getElementById('speedDisplay'); const frameSlider = document.getElementById('frameSlider'); const frameDisplay = document.getElementById('frameDisplay'); ``` -------------------------------- ### Color Code .stim Filename Convention Source: https://github.com/quantumlib/tesseract-decoder/blob/main/testdata/README.md Example filename for color code memory protocol `.stim` files, encoding parameters such as number of rounds (r), code distance (d), noise probability (p), noise model (noise), code type (c), number of qubits (q), and gates used (gates). These files implement the 'superdense' syndrome extraction cycle from Gidney and Jones. ```text r=1,d=11,p=0.01,noise=data_qubit_X,c=color_code_mpp,q=91,gates=mpp.stim ``` -------------------------------- ### Toggle Scene Animation Playback (JavaScript) Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html This function controls the playback state of the scene animation. It toggles a `playing` flag and either starts or stops the animation timer accordingly. It depends on global variables `playing`, `frames`, `animationTimer`, and the `restartAnimationTimer` function. ```javascript function toggleAnimation() { playing = !playing; if (playing && frames.length) restartAnimationTimer(); else clearInterval(animationTimer); } ``` -------------------------------- ### Bivariate Bicycle Code .stim Filename Convention Source: https://github.com/quantumlib/tesseract-decoder/blob/main/testdata/README.md Example filename for bivariate bicycle code `.stim` files, including parameters like number of rounds (r), code distance (d), noise probability (p), noise model (noise), code type (c), nested code parameters (nkd), number of qubits (q), a boolean flag for color structure (iscolored), and polynomial descriptors for matrices A and B (A_poly, B_poly). These codes were studied by Bravyi et al. ```text r=10,d=10,p=0.0001,noise=si1000,c=bivariate_bicycle_X,nkd=[[108,8,10]],q=216,iscolored=True,A_poly=x^3+y+y^2,B_poly=y^3+x+x^2.stim ``` -------------------------------- ### Transversal CX Surface Code .stim Filename Convention Source: https://github.com/quantumlib/tesseract-decoder/blob/main/testdata/README.md Example filename for surface code circuits implementing transversal CX (CNOT) gates, suitable for neutral atom architectures. The naming convention follows other directories, encoding parameters like rounds (r), distance (d), noise probability (p), noise model (noise), code type (c), number of qubits (q), and gates (gates). Correlated decoding of their error models was studied by Cain et al. ```text r=11,d=11,p=0.0001,noise=si1000,c=surface_code_trans_cx_X,q=482,gates=cz.stim ``` -------------------------------- ### Run Tesseract Quick Test Suite Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Executes the default, quick unit test suite for Tesseract using Bazel. These tests are designed to complete in under 30 seconds. ```bash bazel test //src:all ``` -------------------------------- ### Build Tesseract Decoder with Bazel Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Instructions to compile the Tesseract decoder using the Bazel build system. This command builds all targets within the `src` directory. ```bash bazel build src:all ``` -------------------------------- ### Initialize 3D Scene and Data (JavaScript) Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html This function sets up the initial 3D environment, including lighting and detector meshes. It also loads and initializes frame data, error coordinates, and detector mappings, preparing the scene for animation and interaction. It depends on Three.js and global variables like `scene`, `detectorCoords`, `frameSlider`, etc. ```javascript Light(0xffffff, 1); light.position.set(30, 30, 30); scene.add(light); detectorMeshes = {}; for (const [idStr, coord] of Object.entries(detectorCoords)) { const id = parseInt(idStr); const mesh = new THREE.Mesh(sphereGeo, grayMat); mesh.position.set(...coord); scene.add(mesh); detectorMeshes[id] = mesh; } errorCoords = errorCoordsIn; errorToDetectors = errorToDetectorsIn; frames = frameData; frameIndex = 0; frameSlider.max = frames.length - 1; frameSlider.value = 0; frameDisplay.innerText = 0; updateFrame(); restartAnimationTimer(); animate(); ``` -------------------------------- ### Basic Usage of Tesseract Decoder Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Demonstrates the fundamental command-line usage of the Tesseract decoder. This command decodes error events from a specified Stim circuit file, samples a given number of shots, and prints decoding statistics. ```bash ./tesseract --circuit CIRCUIT_FILE.stim --sample-num-shots N --print-stats ``` -------------------------------- ### Sample Shots from a Quantum Circuit using Tesseract Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Demonstrates how to use the Tesseract decoder to sample a specified number of shots from a quantum circuit defined in a Stim circuit file, outputting predictions in a 01 format. This is useful for simulating quantum error correction performance. ```bash ./tesseract --circuit surface_code.stim --sample-num-shots 1000 --out predictions.01 --out-format 01 ``` -------------------------------- ### Load Default Logfile on Page Load (JavaScript) Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html This event listener attempts to load a `logfile.json` when the page finishes loading. If successful, it parses the JSON data and uses it to initialize the 3D scene. It gracefully handles cases where the file is not found or cannot be parsed. It depends on the `fetch` API and the `initializeScene` function. ```javascript window.addEventListener('load', () => { fetch('logfile.json') .then(r => r.ok ? r.json() : Promise.reject()) .then(data => initializeScene( data.detectorCoords, data.errorCoords, data.frames, data.errorToDetectors)) .catch(() => {/* ignore if not present */}); }); ``` -------------------------------- ### Generate Tesseract Decoder Visualization JSON Log Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/README.md This snippet demonstrates how to run the Tesseract decoder to generate a verbose log file containing detector and error information. This log is then processed by a Python script (`to_json.py`) to produce a JSON file suitable for 3D visualization. The `--verbose` flag is crucial for printing detector coordinates, and `--det-order-bfs` is compatible with this logging process. ```bash bazel build src:all && \ ./bazel-bin/src/tesseract \ --sample-num-shots 1 --det-order-seed 13267562 --pqlimit 10000 --beam 1 --num-det-orders 20 --det-order-bfs \ --circuit testdata/colorcodes/r\=9\,d\=9\,p\=0.002\,noise\=si1000\,c\=superdense_color_code_X\,q\=121\,gates\=cz.stim \ --sample-seed 717347 --threads 1 --verbose | \ grep -E 'Error|Detector|activated_errors|activated_dets' > logfile.txt python viz/to_json.py logfile.txt -o logfile.json ``` -------------------------------- ### JavaScript Function to Handle File Input Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html Defines the `handleFile` function responsible for processing user-selected files. It uses `FileReader` to asynchronously read the file content as text, attempts to parse it as JSON, and then calls `initializeScene` with the parsed data, logging any parsing errors. ```JavaScript function handleFile(event) { const reader = new FileReader(); reader.onload = function(e) { try { const data = JSON.parse(e.target.result); console.log(data.errorToDetectors) initializeScene(data.detectorCoords, data.errorCoords, data.frames, data.errorToDetectors); } catch (err) { console.error("Failed to parse JSON:", err); } }; reader.readAsText(event.target.files[0]); } ``` -------------------------------- ### Run Tesseract Exhaustive Test Suite Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Executes a more comprehensive and exhaustive unit test suite for Tesseract. This suite includes additional shots and larger distances, requiring the `TESSERACT_LONG_TESTS` environment variable to be set. ```bash TESSERACT_LONG_TESTS=1 bazel test //src:all ``` -------------------------------- ### Decode Detection Events and Observable Flips with Tesseract Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Illustrates decoding detection events while incorporating observable flip information from a separate input file. This command uses a detector error model to process both event and observable data, providing a more complete decoding result. ```bash ./tesseract --in events.01 --in-format 01 --obs_in obs.01 --obs-in-format 01 --dem surface_code.dem --out decoded.txt ``` -------------------------------- ### Quantum Error Correction Test Data Folder Structure Source: https://github.com/quantumlib/tesseract-decoder/blob/main/testdata/README.md The `testdata/` directory organizes `.stim` files into subfolders based on the quantum error correction code type, facilitating testing and benchmarking of different protocols. ```filepath testdata/ ├── surfacecodes/ ├── colorcodes/ ├── bivariatebicyclecodes/ ├── surface_code_trans_cx_circuits/ ``` -------------------------------- ### Cite Tesseract Decoder in LaTeX Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Provides the BibTeX entry for citing the Tesseract Decoder project in academic publications. This citation includes details such as the title, authors, year, and arXiv identifier, ensuring proper attribution. ```latex @misc{beni2025tesseractdecoder, title={Tesseract: A Search-Based Decoder for Quantum Error Correction}, author = {Aghababaie Beni, Laleh and Higgott, Oscar and Shutty, Noah}, year={2025}, eprint={2503.10988}, archivePrefix={arXiv}, primaryClass={quant-ph}, doi = {10.48550/arXiv.2503.10988}, url={https://arxiv.org/abs/2503.10988}, } ``` -------------------------------- ### Decode Detection Events from a File with Tesseract Source: https://github.com/quantumlib/tesseract-decoder/blob/main/README.md Shows how to decode detection events from an input file (e.g., events.01) using a specified detector error model (DEM) file. The decoded output is written to a text file, facilitating analysis of error correction results. ```bash ./tesseract --in events.01 --in-format 01 --dem surface_code.dem --out decoded.txt ``` -------------------------------- ### Animate 3D Scene and Camera (JavaScript) Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html This function drives the animation loop for the 3D scene. It uses `requestAnimationFrame` to continuously update the camera's position for rotation and zoom, and then renders the scene. It relies on Three.js for rendering and global variables like `camera`, `renderer`, `scene`, `rotationAngle`, and `spinSpeed`. ```javascript function animate() { requestAnimationFrame(animate); rotationAngle += spinSpeed; if (!topDownView) { const zoomInput = document.getElementById("zoomSlider"); zoomDistance = parseFloat(zoomInput.value); camera.position.x = zoomDistance * Math.cos(rotationAngle); camera.position.y = zoomDistance * Math.sin(rotationAngle); camera.position.z = zoomDistance / 2; camera.lookAt(0, 0, 0); } if (renderer && scene && camera) { renderer.render(scene, camera); } } ``` -------------------------------- ### Define numpy Python Dependency with Hashes Source: https://github.com/quantumlib/tesseract-decoder/blob/main/src/py/requirements_lock.txt Specifies the 'numpy' package version 2.2.6, accompanied by a comprehensive list of SHA256 hashes for robust integrity verification. This dependency is indicated as being required via 'stim', highlighting its role in numerical operations within the project. ```Python Requirements numpy==2.2.6 \n --hash=sha256:038613e9fb8c72b0a41f025a7e4c3f0b7a1b5d768ece4796b674c8f3fe13efff \n --hash=sha256:0678000bb9ac1475cd454c6b8c799206af8107e310843532b04d49649c717a47 \n --hash=sha256:0811bb762109d9708cca4d0b13c4f67146e3c3b7cf8d34018c722adb2d957c84 \n --hash=sha256:0b605b275d7bd0c640cad4e5d30fa701a8d59302e127e5f79138ad6262c3e3d \n --hash=sha256:0bca768cd85ae743b2affdc762d617eddf3bcf8724435498a1e80132d04879e6 \n --hash=sha256:1bc23a79bfabc5d056d106f9befb8d50c31ced2fbc70eedb8155aec74a45798f \n --hash=sha256:287cc3162b6f01463ccd86be154f284d0893d2b3ed7292439ea97eafa8170e0b \n --hash=sha256:37c0ca431f82cd5fa716eca9506aefcabc247fb27ba69c5062a6d3ade8cf8f49 \n --hash=sha256:37e990a01ae6ec7fe7fa1c26c55ecb672dd98b19c3d0e1d1f326fa13cb38d163 \n --hash=sha256:389d771b1623ec92636b0786bc4ae56abafad4a4c513d36a55dce14bd9ce8571 \n --hash=sha256:3d70692235e759f260c3d837193090014aebdf026dfd167834bcba43e30c2a42 \n --hash=sha256:41c5a21f4a04fa86436124d388f6ed60a9343a6f767fced1a8a71c3fbca038ff \n --hash=sha256:481b49095335f8eed42e39e8041327c05b0f6f4780488f61286ed3c01368d491 \n --hash=sha256:4eeaae00d789f66c7a25ac5f34b71a7035bb474e679f410e5e1a94deb24cf2d4 \n --hash=sha256:55a4d33fa519660d69614a9fad433be87e5252f4b03850642f88993f7b2ca566 \n --hash=sha256:5a6429d4be8ca66d889b7cf70f536a397dc45ba6faeb5f8c5427935d9592e9cf \n --hash=sha256:5bd4fc3ac8926b3819797a7c0e2631eb889b4118a9898c84f585a4d475b7e40 \n --hash=sha256:5beb72339d9d4fa36522fc63802f469b13cdbe4fdab4a288f0c441b74272ebfd \n --hash=sha256:6031dd6dfecc0cf9f668681a37648373bddd6421fff6c66ec1624eed0180ee06 \n --hash=sha256:71594f7c51a18e728 ``` -------------------------------- ### CSS Styling for Tesseract Decoder Viewer Layout Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html Defines the basic layout and styling for the Tesseract Decoder Viewer, including body margins, overlay positioning, legend styles, and color definitions for visual elements like dots representing different states (gray, blue, red). ```CSS body { margin: 0; overflow: hidden; font-family: sans-serif; background: white; } #overlay { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,0.95); padding: 12px; border-radius: 6px; z-index: 1; } #legend { font-size: 14px; margin-top: 10px; } .legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; } .gray { background: #aaa; } .blue { background: #07f; } .red { background: #f00; } canvas { display: block; background: white; } ``` -------------------------------- ### Handle Window Resize for 3D Camera (JavaScript) Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html This function adjusts the 3D camera's aspect ratio and the renderer's size when the browser window is resized. This ensures the scene remains properly scaled and displayed. It depends on global `camera` and `renderer` objects from Three.js. ```javascript function onWindowResize() { if (camera && renderer) { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); } } ``` -------------------------------- ### JavaScript Event Listeners for Viewer Controls Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html Attaches event listeners to various UI elements to enable interactive control of the viewer. This includes handling changes for animation looping, spin speed, zoom level, view angle toggling, file input, animation speed adjustment, and frame seeking, updating the scene and animation state accordingly. ```JavaScript document.getElementById('loopCheckbox').addEventListener('change', (e) => { loop = e.target.checked; }); document.getElementById('spinSlider').addEventListener('input', (e) => { spinSpeed = parseFloat(e.target.value); }); document.getElementById('zoomSlider').addEventListener('input', (e) => { const distance = parseFloat(e.target.value); if (topDownView) { camera.position.set(0, 0, distance); } else { camera.position.x = distance * Math.cos(rotationAngle); camera.position.y = distance * Math.sin(rotationAngle); camera.position.z = distance / 2; } camera.lookAt(0, 0, 0); }); document.getElementById('toggleViewBtn').addEventListener('click', () => { topDownView = !topDownView; if (topDownView) { camera.position.set(0, 0, 50); camera.up.set(0, 1, 0); camera.lookAt(0, 0, 0); } else { camera.position.set(20, 0, 10); camera.up.set(0, 0, 1); camera.lookAt(0, 0, 0); } }); fileInput.addEventListener('change', handleFile); speedSlider.addEventListener('input', function () { const logScale = parseInt(this.value); let fps = Math.round(10 ** (logScale / 25)); fps = Math.min(fps, 1000); frameInterval = 1000 / fps; speedDisplay.innerText = fps; if (playing && frames.length) restartAnimationTimer(); }); frameSlider.addEventListener("input", () => { playing = false; clearInterval(animationTimer); frameIndex = parseInt(frameSlider.value); updateFrame(); frameDisplay.innerText = frameIndex; }); ``` -------------------------------- ### JavaScript Function to Manage Animation Timer Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html Implements the `restartAnimationTimer` function, which controls the animation playback. It clears any existing timer, resets the frame index to zero if at the end of a non-looping animation, and sets up a new `setInterval` to advance frames, handle looping, and stop playback when the animation concludes. ```JavaScript function restartAnimationTimer() { clearInterval(animationTimer); // If trying to play from the very end of a non-looping animation ``` -------------------------------- ### Update 3D Scene for Current Frame (JavaScript) Source: https://github.com/quantumlib/tesseract-decoder/blob/main/viz/index.html This function updates the 3D visualization to reflect the current animation frame. It clears previously drawn elements and then renders activated detectors, errors, and connecting edges based on the `frames` data. It relies on Three.js for rendering and global variables like `scene`, `detectorMeshes`, `errorCoords`, and `frameIndex`. ```javascript function updateFrame() { // Clear previous markers activeDetectors.forEach(s => scene.remove(s)); activeDetectors = []; activeErrors.forEach(s => scene.remove(s)); activeErrors = []; activeEdges.forEach(e => scene.remove(e)); activeEdges = []; if (!frames || frames.length === 0) return; const frame = frames[frameIndex]; // Draw activated detectors for (const id of frame.activated) { if (!(id in detectorMeshes)) continue; const blue = new THREE.Mesh(sphereGeo, blueMat); blue.position.copy(detectorMeshes[id].position); scene.add(blue); activeDetectors.push(blue); } // Draw activated errors and red edges to detectors for (const eid of frame.activated_errors) { if (!(eid in errorCoords)) continue; const errPos = new THREE.Vector3(...errorCoords[eid]); const red = new THREE.Mesh(sphereGeo, redMat); red.position.copy(errPos); scene.add(red); activeErrors.push(red); if (errorToDetectors) { for (const did of errorToDetectors[String(eid)]) { if (!(did in detectorMeshes)) continue; const detPos = detectorMeshes[did].position; const material = new THREE.LineBasicMaterial({ color: 0xff0000 }); const geometry = new THREE.BufferGeometry().setFromPoints([errPos, detPos]); const line = new THREE.Line(geometry, material); scene.add(line); activeEdges.push(line); } } } // Update frame label and slider frameSlider.value = frameIndex; frameDisplay.innerText = frameIndex; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.