-
Notifications
You must be signed in to change notification settings - Fork 12
Simulation distance 3 magic state cultivation #92
Copy link
Copy link
Open
Description
First off, thank you for building this tool and open sourcing it. I'm building a similar near-Clifford simulator using different techniques. I was interested in comparing performance on the magic state cultivation distance 3 circuit. Before running on a GPU, I was doing a trial on my CPU but the compilation stage seems to hang. I let it run for 5 minutes with no progress. Is there a different configuration I should be using? Sidenote that the version number inside the package differs from the PyPI package version.
Reproducer
#!/usr/bin/env python3
"""Minimal reproducer: tsim hangs compiling d=3 cultivation circuit.
Requirements:
pip install bloqade-tsim==0.1.1
Usage:
python tsim_hang_repro_fetch.py
On first run, downloads the circuit locally from CIRCUIT_URL.
The script appears to hang at compile_detector_sampler().
"""
from __future__ import annotations
import time
import urllib.request
from pathlib import Path
CIRCUIT_URL = (
"https://raw.githubusercontent.com/haoliri0/SOFT/refs/heads/main/"
"magic_state_cultivation/circuits/circuit_d3_p0.001.stim"
)
LOCAL_CIRCUIT = Path(__file__).with_name("circuit_d3_p0.001.stim")
def load_circuit_text() -> str:
if not LOCAL_CIRCUIT.exists():
print(f"Downloading circuit to {LOCAL_CIRCUIT} ...", flush=True)
with urllib.request.urlopen(CIRCUIT_URL) as response:
LOCAL_CIRCUIT.write_text(response.read().decode("utf-8"))
print(" done.")
return LOCAL_CIRCUIT.read_text()
def main() -> None:
import tsim
print(f"tsim version: {getattr(tsim, '__version__', 'unknown')}")
print("Circuit: d=3 magic state cultivation (15 qubits)")
print(f"Source: {CIRCUIT_URL}")
print()
circuit_stim = load_circuit_text()
print("Creating tsim.Circuit ...", flush=True)
tc = tsim.Circuit(circuit_stim)
print(" done.")
print("Calling compile_detector_sampler() ...", flush=True)
t0 = time.time()
sampler = tc.compile_detector_sampler()
elapsed = time.time() - t0
print(f" done in {elapsed:.1f}s.")
print("Sampling 1000 shots ...", flush=True)
t0 = time.time()
result = sampler.sample(1000, separate_observables=True)
elapsed = time.time() - t0
print(f" done in {elapsed:.1f}s.")
print(f" detector samples shape: {result[0].shape}")
print(f" observable samples shape: {result[1].shape}")
if __name__ == "__main__":
main()Expected
compile_detector_sampler() finishes or raises an explicit error.
Actual
The script prints:
tsim version: 0.1.0
Circuit: d=3 magic state cultivation (15 qubits)
Source: https://raw.githubusercontent.com/haoliri0/SOFT/refs/heads/main/magic_state_cultivation/circuits/circuit_d3_p0.001.stim
Creating tsim.Circuit ...
done.
Calling compile_detector_sampler() ...
Then it produces no further output for at least 180 seconds.
Environment
- macOS 15.7.4 (24G517)
arm64Apple Silicon- Python 3.13.10
bloqade-tsim==0.1.1- runtime
tsim.__version__ == 0.1.0 jax==0.9.2jaxlib==0.9.2numpy==2.4.4stim==1.15.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels