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.4.1.tar.gz (102.8 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.4.1-cp313-cp313-win_amd64.whl (389.1 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (562.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.4.1-cp313-cp313-macosx_11_0_arm64.whl (494.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.4.1-cp312-cp312-win_amd64.whl (389.8 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (563.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.4.1-cp312-cp312-macosx_11_0_arm64.whl (494.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.4.1-cp311-cp311-win_amd64.whl (389.3 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.4.1-cp311-cp311-macosx_11_0_arm64.whl (496.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.4.1-cp310-cp310-win_amd64.whl (389.2 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.4.1-cp310-cp310-macosx_11_0_arm64.whl (496.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.4.1-cp39-cp39-win_amd64.whl (389.5 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.4.1-cp39-cp39-macosx_11_0_arm64.whl (497.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.4.1.tar.gz
Algorithm Hash digest
SHA256 f4a2a163c4cb9fb2d17ae2eb9514831d131de66041f6c2f6a22b42ac710faabf
MD5 146f86b96d9760c5c37e1f8512b3b6b6
BLAKE2b-256 75b89f4361341c574da4458b047f44589f959f7c72acc1a63354c3ab5919e7cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5ae9532ebd97c164f3580c570e375ae571a6baa1e7c999c0f802611da7fd2330
MD5 789a83de0067be2890683121bd16b745
BLAKE2b-256 29a058cd84815d269ff218dba033a564bc900de381c3ec210eb6505ce7d98140

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6db33a44041d9b5b3f2f0a5688a736550f261bf44e92c4abbc179806b85f035
MD5 8292f14a049105e77f180cf9e3df29f7
BLAKE2b-256 2039ac57a7f6506926f23471e4c3e0086c841e7aebb06bae913270c1f3f1a28e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 468e868b09fa199812660ac3e3098692158548579cc5ad3e3e8349c3e950b567
MD5 462624dd2036cf70a31a22d489e86767
BLAKE2b-256 2952131d006b2e74b53ed4fc08bee9e8f48d4cf9a5705ee22e8dc6e718b13503

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1b015a9641c4a37b2dccaf854208e7222b1a878b60da35ffab74d3cf8c311d9
MD5 636a67ed6820ae017e08571a3dfc5295
BLAKE2b-256 e91060a8b373b8e536849a8d4892e28b00231d2cce7f61d35fb4098b328dab93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 92baeb589c8fda9fd8c081d97fc38dd017907cf4cf437129187b8594c08167b8
MD5 4af72ff3f14c03e491509c1da391ddc9
BLAKE2b-256 d60d98f001bb78d57e300fea1d3b0ac11a399b57da72fc65370d8092bf8d2e43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3e5b84b4dcb8aeda38cb6d836552d1ce912f6920e6c36d0ef3e3c3b7d41ded3
MD5 ac6cba4495eaeae8dc25e2b84d95fc18
BLAKE2b-256 3b98a7e1cacef6a8453d14b37922f562bad74dc67325ca94578347cd46f1cc8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 435ba17711d4394094f30f946ac7363e5af140a4be6c99f97e6b4bd1d874aae8
MD5 d1d593e201c8cd074477e972d1909526
BLAKE2b-256 686751f2a739dfcfdaf18a2b40df9b64d403543021ed9ff701800ff3df45e8f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f1d57907e713270ad1cc1c1c87eaf6668d5a207bd0cf343fb2f52e2ef2faba7
MD5 f20e674f3f0742cc43a6e3e49cca4b81
BLAKE2b-256 c9644fa0cfb3ecbee46366bcacee8e1d65afbc5a74643981d2876d079fa6c70d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b6580ca6b6fbc614999e453898bbcd0d19ca1ad92150f33e315f17b2a6963800
MD5 e1d63dad948b78e5265abb1f13dd6c52
BLAKE2b-256 37a4e33c0a37b733d72af9de55c62ae221c4feb7a11a8fb2ec7061cb2216d9a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e60edca20cfd57e0ed0b3e2959673f05adb4c7471ca8ca7065ad37431d402ec
MD5 16b4dc0f35104eb8656f5af33a181fe6
BLAKE2b-256 5416fb4cb5571388c69fed3bc0479bc69d56cb4b6be27a18d22b6707986509a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2d43d8c21c74e63a1283b22c65a2db55f2ed0035979d651e583d0d4733d44fe8
MD5 cff83dc42492590d488465c2edfa1b9c
BLAKE2b-256 7b799b2f9bceeee36ce9e2d0a9f06b41b17a60cd9c4fc2af469ae9ccb0c378bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31b9cdbbb1d31b604a6c737d6dc029f8d85ef462436689b33c947cb63b170686
MD5 9dc50f2252978d623d139426f763ba6e
BLAKE2b-256 584f5c3b6800aa9d8af163047010b42eb13e4e1d45324d0d83ef73c24079daa0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2cd68d2b1c3adbf2269f5201f2c1e6aa96aa88892e0dde6c2202414d9fb1f6af
MD5 58afe007f4f772a4c476ef2039464286
BLAKE2b-256 c471849aeae03b0ddeff7525616f13af8cde4cf0f5ed5e91caf5146bbf04284c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 834bef6e2fc2033338f88c11b356ba1cb4c554bf058acf2743e680bf5e9de016
MD5 2f7ae931a0b718ed45974f14057cf469
BLAKE2b-256 4ca2d0c18a7fada625a33ac14407aea7e2991b0835e08aa8a074b44287175e16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e366ad05f6f18d238c48daa2a01a94a45752a9c8f87516f2d061270b552a24d3
MD5 12fd7d22c99347f2c9b411f54736ab82
BLAKE2b-256 a7fb51b81bb79c30a73560b7cd3d924c39d409ed0f2187e7be1cfe807c5d7ad4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27abbbde7dd45652d5e5cee3170b1c66acac4ebb48adb0253d2f53ba00c2bab1
MD5 a63e922eec278d107a3423c0faeb3c75
BLAKE2b-256 a92eb12cd6e833cf551a47610b0d3528a6f5a7e0f12230a249ae300e58dc67c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.4.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 389.5 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.4.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 59264a9c0296bd06f25aa5c33fd20b2bd7d51c7bc4b85dfcceba83361efadf04
MD5 8330b84dd5b56323562030a42208e076
BLAKE2b-256 4e726fe60595fe6196709a925f910c884c25c44c72a620e81082cc012441ddb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 100cf603016dd6ac2216b4abccc1ce239a660e3c66a23611f5de43133e3c9014
MD5 752681d664490e8c335e15c977e95e34
BLAKE2b-256 1eeb05682cd37fed3eebe40d51907b05222a203f060e2e36c191f8c79719dc05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8776e52d34d8cfc3d7b1102d8b161dc054c12255adfc60793d3f86815685dc4f
MD5 6f391d5060ff66edcfe833f4ec554801
BLAKE2b-256 76716e2dd6b6346aff600e50edb040c88fbd63d8d41b64d85d8cd0478d2f3cda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 82f0ad9e5b306e22dbc9397166b438a5eb1f46afa6719f89906d4ea0df18bd97
MD5 31f170589bf346a8640833effda27aa1
BLAKE2b-256 53609ba14c74ee3efdb9cede1e888511c075c8cbb2dae03d2f209d1fdd3b845d

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