Skip to main content

Full Rust core quantum circuit simulator with Python bindings

Project description

panta-sim

PyPI Python CI License: MIT

풀 Rust 코어 + Python 바인딩으로 작성한 양자 회로 시뮬레이터. Full state vector 방식으로 단일 머신에서 30큐비트 회로까지 시뮬레이션 한다 (충분한 RAM 기준).

  • Rust 코어: num-complex 기반 상태 벡터, qubit-wise multiplication
  • 멀티스레드: rayon 으로 게이트 적용 병렬화 (v0.2.0~), Python GIL 해제
  • f32/f64 정밀도 선택 (v0.2.1~): qc.run(precision="f32") 로 메모리 ~50% 절감 → 같은 RAM 에서 큐비트 1개 더
  • Python API: PyO3 + maturin, NumPy 연동
  • 검증: 145 pytest (f32/f64 양쪽) + 93 케이스 광범위 Qiskit 교차검증 (f64 < 1e-10, f32 < 1e-5)

설치

pip install panta-sim

Linux (x86_64, aarch64) / macOS (Apple Silicon) / Windows (x64) 에서 Python 3.9~3.13 미리 빌드된 wheel 을 제공한다. Rust toolchain 은 필요 없다.

소스에서 직접 빌드하려면:

# 사전 요구 사항: Rust toolchain (rustup), Python >= 3.9, maturin
pip install maturin
git clone https://github.com/quantumfia/quantum-sim
cd quantum-sim
maturin develop --release   # 또는 pip install .

빠른 시작

from panta_sim import QuantumCircuit

# Bell state |Φ+⟩ = (|00⟩ + |11⟩)/√2
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

result = qc.run(shots=1024, seed=42)
print(result.counts())          # {'00': ~512, '11': ~512}
print(result.statevector())     # [0.707+0j, 0+0j, 0+0j, 0.707+0j]
print(result.probabilities())   # [0.5, 0, 0, 0.5]

QuantumCircuit 의 게이트 메서드는 모두 self 를 반환하므로 메서드 체이닝도 가능하다:

counts = (
    QuantumCircuit(3)
    .h(0)
    .cx(0, 1)
    .cx(0, 2)
    .measure_all()
    .run(shots=1024, seed=0)
    .counts()
)

pip install panta-sim (배포 이름) → import panta_sim (Python 모듈 이름).

지원 게이트

분류 게이트 메서드
단일 큐비트 Hadamard h(q)
단일 큐비트 Pauli-X / Y / Z x(q), y(q), z(q)
단일 큐비트 Phase / T s(q), t(q)
단일 큐비트 Identity id(q)
회전 Rx / Ry / Rz rx(theta, q), ry(theta, q), rz(theta, q)
2큐비트 CNOT / CZ / SWAP cx(c, t), cz(a, b), swap(a, b)
3큐비트 Toffoli (CCX) ccx(c1, c2, t)
3큐비트 Fredkin (CSWAP) cswap(c, t1, t2)
측정 부분 / 전체 측정 measure(q, c), measure_all()

비트 순서 규약은 Qiskit 과 동일한 little-endian 이다 (q_{n-1} … q_1 q_0). counts() 의 키는 MSB-first 비트 문자열, statevector 의 인덱스는 동일한 비트열을 정수로 해석한 값이다.

빌드 / 테스트

cargo build --release          # Rust 전체 빌드
cargo test                     # Rust 유닛 테스트 (core + simulator)
maturin develop --release      # Python 바인딩 빌드 (개발 모드)
pytest tests/                  # Python 통합 테스트 + Qiskit 교차검증
pytest tests/ -v               # 상세 출력

Qiskit 교차검증 테스트는 qiskit 패키지가 설치되어 있을 때만 실행되며, 설치되어 있지 않으면 자동으로 skip 된다.

예제

examples/ 디렉터리 참고:

  • bell_state.py — Bell 상태 생성 및 측정
  • grover.py — 2큐비트 Grover 탐색
  • qft.py — Quantum Fourier Transform
python examples/bell_state.py
python examples/grover.py
python examples/qft.py

프로젝트 구조

quantum-sim/
├── crates/
│   ├── core/              상태 벡터, 게이트 행렬, 복소수 연산
│   ├── simulator/         시뮬레이션 엔진, 측정, 회로 실행기
│   └── python-binding/    PyO3 바인딩
├── python/panta_sim/      사용자용 Python 라이브러리
├── tests/                 pytest 통합 테스트
├── examples/              사용 예제
└── docs/                  설계 문서 (plan.md, architecture.md, references.md)

성능 (v0.2.1)

rayon 으로 게이트 적용을 멀티스레드 병렬화. amplitude < 8192 (≈ 13 큐비트) 인 작은 회로는 직렬 폴백으로 회귀 0건 유지.

f32 / f64 정밀도 선택 (v0.2.1+):

from panta_sim import QuantumCircuit
qc = QuantumCircuit(30)
qc.h(0)
for i in range(1, 30):
    qc.cx(0, i)

# f64 (default) — 16 bytes/amp, 정확도 < 1e-15
result = qc.run(shots=0)                   # ≈ 16 GB state @ 30 qubits
print(result.statevector().dtype)          # complex128

# f32 — 8 bytes/amp, 정확도 < 1e-5, 같은 RAM 으로 큐비트 1개 더
result = qc.run(shots=0, precision="f32")  # ≈ 8 GB state @ 30 qubits
print(result.statevector().dtype)          # complex64
머신 30 큐비트 GHZ statevector 31 큐비트 (f32, v0.2.1)
16 GB / 32GB+ RAM, 다코어 약 1분 (16 GB state, f32 로 가능)

자세한 벤치는 benches/results/examples/validation/RESULTS.md 참고.

로드맵 / 미구현

  • v0.2 — CPU 성능 (rayon ✅ / f32 ✅ / SIMD)
  • v0.3 — OpenQASM 2.0/3.0, 트랜스파일러, 시각화
  • v0.4 — 노이즈 모델
  • v0.5 — GPU (wgpu / cudarc) → 30+ 큐비트
  • v0.6 — Tensor Network / MPS

상세 로드맵은 docs/plan.md 참고.

참고 자료

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panta_sim-0.3.2.tar.gz (73.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

panta_sim-0.3.2-cp313-cp313-win_amd64.whl (346.5 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (521.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.3.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (507.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.3.2-cp313-cp313-macosx_11_0_arm64.whl (447.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.3.2-cp312-cp312-win_amd64.whl (347.2 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (522.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (507.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.3.2-cp312-cp312-macosx_11_0_arm64.whl (448.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.3.2-cp311-cp311-win_amd64.whl (347.0 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (522.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (508.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.3.2-cp311-cp311-macosx_11_0_arm64.whl (451.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.3.2-cp310-cp310-win_amd64.whl (346.8 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (522.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (508.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.3.2-cp310-cp310-macosx_11_0_arm64.whl (450.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.3.2-cp39-cp39-win_amd64.whl (347.0 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (522.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (508.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.3.2-cp39-cp39-macosx_11_0_arm64.whl (451.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file panta_sim-0.3.2.tar.gz.

File metadata

  • Download URL: panta_sim-0.3.2.tar.gz
  • Upload date:
  • Size: 73.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for panta_sim-0.3.2.tar.gz
Algorithm Hash digest
SHA256 fb7782d76a3f1f9a5d31e2ecd009323ed2152b740478822ab2cc4c1653e4380b
MD5 b9ae1eb1921bee324624284fc730f7ff
BLAKE2b-256 7b68cdcc7e9c380ae07183c2d787d44ac63fe6d5b3bfb164b332dc9c464ec82e

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 735793516bb44a0fc6c509685c698be1a0af57c75b74ce3f20b34483c9c12fb8
MD5 8ef30d62493edfb1d5bab6fbafc840b8
BLAKE2b-256 df6b7b02c3a3843badb76110dc6b5b869956e0f304bd4e51a0e1d84fb7faa6d3

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f7bb83901c847a97ee8cfff9904561f10f4ef06ab5733938831aa53f9a1a1a1
MD5 dfc05f22e82d911352a94313458ceba0
BLAKE2b-256 8546e7e12c2ae094dd38345921e6a95bb847dd06eac9b01c5550b54b2ae93172

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 83c39a2857bbbf6a61042eafa0876cee4e30a239d475ba419d50f3e07eee32f7
MD5 e149edf88dba8fd81c32ecccf6ba3f94
BLAKE2b-256 c89caabeb74bf7b2afbd63185ea1701329901fda6f97ae8c066224f360dd125a

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1b5c5fb98bb4924bc28e7e92322a09fa78d6df7b6b35c47a4cf985ca59c62be
MD5 931a483217cc36c19f852e763b9f360b
BLAKE2b-256 3e0af369e569f54070d768aa7cec06fbe1451bfd16e23720e8dce21a471d11b4

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 28294229eeb0a44da4e560903e54089a6ba40f0e9bf9aff34d529999c796c673
MD5 c7c24c660f87e7703e3f5697f7290857
BLAKE2b-256 a9ad2706acae17053610d4bdced15b5a6437e6eba144852ed3cb12322ca90044

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e43fb154c3a6d9448d47fb94d09fe5fc74f10e200b560af43f89e3b220c044f4
MD5 20889de88bb7730a354fff90ed655aae
BLAKE2b-256 53a1093d8a4bb627202c0226982c4f118d3f37aea6f7a91a5b5e1127581cb3f8

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0f3f90793582c5740f0f9a1c977da7ae85e7e9f20bf41d54b45dcbeffba12dcd
MD5 21d52139211f2edb3637fdc981ee8e2e
BLAKE2b-256 19ce81cdaf454bf157af0e667090ba55e0addc19015862a8645c45f2d69563ea

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70d61a519ffe9bfbdf5b26fcca925cf92e140aeeb1725e7236a3fe08ec351a2c
MD5 074e322122479e734cd3b9d075b75242
BLAKE2b-256 dc6974cff0434f5274a99f21d0f454ad0a2a83eedb2dfb99359147814f7a4c34

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a9381cc52b37285e1854a246c024481199c832b0aefb155e7bce4cc349d55079
MD5 fe9b82f89d7344ae0d65fba1d7bc7c6f
BLAKE2b-256 28c32ea55ef15a59c142788d1879a7773c6e45874472c37b030984c52f10cc9e

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4233c5b5a66c2e0d67e02febc73a09834d5fb9506440dd48a0d8b0bf9ae2f96
MD5 a33ce09af2600178ef234dbd3502ee4b
BLAKE2b-256 7ef6e68f5123264627b9376f5a0a4e6212e2d51ac85022e0171b1661a977f245

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5970daf69c7779938c01e0ed3dcca525a9cca8e17fd5e757f3daef9ee50eab8e
MD5 089583c4a3afa6690867d310d99e91d1
BLAKE2b-256 51b1b5e9b5e48b64011433f1ff397f32aad9c11b9b516c96e30b5be75a3dceef

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc0824cf03384fe1d205797d52281d1d90bd92e84978381e326c7e6d58b4b534
MD5 632b30da1bce3debcc5d87dbf6da832b
BLAKE2b-256 298d0f36a246d5e0970d96ee77c05f574869031000615c11d1d7fbc7002914bc

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8f7b4b8c601c46d32e009daa962559ed979af33f2f5de620813ec3713d1274ef
MD5 c117f7d7818ab4453e77eaa03c188f19
BLAKE2b-256 6b991686c88ea82ea1c7c5b5507b00fe682e45909cc66957cff2824596330dc1

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 19e23847760c45269dbe94f0f4484f47ddb0a2d38f2989feed1e4a4ac8e0b84a
MD5 e39211c8ca19c0ca3510268a92dd98e0
BLAKE2b-256 cd524533bb756c143830da2059ff96309015ce1ddfc5730136981e759f0f914d

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d27738eead8fb5e393a03be623110653d7362159ec1bce2f37d2226540c63639
MD5 ec69644a1e20c0783940ed4bbb1fdb08
BLAKE2b-256 374dbae3013fb4755fd0760f4a3c6430ac8bb5afe1383693fe4f93d17e7f5c1b

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b34bc144dffe4dd9d508c038f252dbae325a394fcb791aa6e16fb26bfb831ddb
MD5 3313b96e4eade6d7952a8c251efbd8d9
BLAKE2b-256 7f7eafe986a00926197fcb2a6ca5a38ab62eaf6e856f9519235f59ad5ec7a6a0

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: panta_sim-0.3.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 347.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for panta_sim-0.3.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3d51fa78f2098c8ac3a8b1ca51ffa33f13609670cc5ef689f15f2fe0b8559e49
MD5 02322b560c5cdd484cb92f7163b260f9
BLAKE2b-256 7a464fa1db8477f8627ec7c06358efaf262c8a52d2fc9773883b2c4d596667ff

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 74169da30d05a34a949b3cad795b6fe337ba4a0acd5d062948fee285ae4fbfa0
MD5 381d62d36b8dba4a8b26a9007cccc536
BLAKE2b-256 66c069749200633e1784c15e4283d24c1f07bb62221f9b8c3f166f3660b6a7f5

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0ea19449f47be63e14da33f7dce5658273f34c550cfeb114ea538a560a4f0fa4
MD5 549b760b9078474e721a8e8d80d86cf0
BLAKE2b-256 673640d781b0cb4195901a3cfd1f64d8528ae07c7147a5bc16b139fdd8fd7b02

See more details on using hashes here.

File details

Details for the file panta_sim-0.3.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for panta_sim-0.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 629276e31d04cf45a4ca47d2a13d306c8d4b7759ab23911889a92f12eccfbf09
MD5 16fdda9bdd161e8f86ecc2b0f0b2823f
BLAKE2b-256 ab6baa931a7fefe3ce0b4077a8d21895b32c0dc8a8375a86940ea37827335560

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page