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.5.0.tar.gz (189.2 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.5.0-cp313-cp313-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.5.0-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.5.0-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.5.0-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.5.0-cp311-cp311-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.5.0-cp310-cp310-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.5.0-cp310-cp310-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.5.0-cp39-cp39-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.5.0-cp39-cp39-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7ab0ec4e0b737eb9a41db79a076943ab9393b68b51a9e437427f6abdc6333820
MD5 d0c1201cf9f8962862105205395e3918
BLAKE2b-256 5c1aaf91419fdc70530ed0a1f80db7848c4cc48e3dd6afb3953cf801d453a884

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 256b835ebf08cc98b320acb1435a388b94974eddcc7c9ba6188f11f86916c011
MD5 3d0954ce1bd5dd3686ce5df4ff504284
BLAKE2b-256 dc4ab75408e0dc66b36d6a67be72b8bf4b5cd95c6918b420bd2688739d5388ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d227d6e59835e3b2b8dbf6f3b88af140ec9d398404cf5ac4fa960e5b2ef8d73
MD5 96595bcca9f819487b4e0b5c22979871
BLAKE2b-256 553f2c1cec320a4550271067d928476a83ccc1f1b300570e126fe2e8ed29e887

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2a1a04af467594f8f4349fd56d726900ca8bde86b8201348e9a66745f4ea493a
MD5 c1cee92fd1775676c59bd270641303ce
BLAKE2b-256 89eebaf274cd349a4cb58e258d3093b103cc20f894b1d7aff025b42c931ebd2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e08283731cb752ba26bbacc3eb2331b0826b56b7e46bce488db85e30bf8ffae
MD5 d22e5fae04906cea8954064a0e2e9f81
BLAKE2b-256 6d4ec45ae75c1fa500544d38229c8e6c03da7dc1b3cafbbc1bf1a8be72166df3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b74e2eda589c44e32cb887b20e736e771d6ef4ef5fce25ac1552b1696b5bafa7
MD5 623f80d67ccd4c58dee7e0314da9b0e5
BLAKE2b-256 4377972f9d076c76d28690c29e192108d87854aca58cf107287ccbbfb4899c0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a527ca211c69a7b706bdb7cac9325120d79cb803a9b2af9afbe986f3f402d59f
MD5 be6edbbc2551f677097e10d2145e971b
BLAKE2b-256 bf850182ff2bca0a21b465d8a66490eb4e2e127cf921d767ec65d12d39db5c79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5c4c2ad8bda1f5507ef9c550dd494958bc122b8cb392b3e052140c3315cf2fb4
MD5 2b0c758a731946e33f5fab06d305d44f
BLAKE2b-256 dab880ea59ce18f6a79950a17ff56781107efe2eb113f6917db5d7eff09a6da5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6c5a42a7c6f84f5039729fc70a2470000b46ed003232c596454191ed3c53858
MD5 a5846be4f5940fe70d6ab4846b0a9978
BLAKE2b-256 df7d026ba96ec47aea8c34d9338b50b0ecbd365713d5ecd0e2235d852b6e06f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4df2a22b165481867790287386d14ad1686b3b1cbca70c5212cd5bbbcb43d658
MD5 8ca685f25943b285585634554672ecfc
BLAKE2b-256 01c8642b6d9b19dffd1034e81f8127340d819b76bdd020f0ec9124205f832296

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57f9e45238a4fbc0925ce8cc85dc4c4e4c6dc20afe02f2e6c2703abd650b57fa
MD5 73168db917181014eb9b714f64a8163b
BLAKE2b-256 96ad8a2fccb9c4463c0565180013acd8903b07ce12c099fea8066e4bd1256e99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7777019c03ee1143af1a4c7527a920ce118aa934b9c58c89e9f36bc164fc7a50
MD5 bc1699abd1eedad055333b96daba7739
BLAKE2b-256 9e9129cef08ae9dd7ab69334bc184016a8a91cd321c0de7ba2bf6936f1919001

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0f12bfb97cec52e5bb219bc9050257cc61ffdff091e933d682924a4a49d4105
MD5 ab9d2d60e204de948b2e4bcbeb91cf39
BLAKE2b-256 852cd8f015f626657f153f2d6063a829e248b0065a448ea579a5611ca0267dc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 95bcf4f1ab48871842aff1671874d495f04a9a617d09d4003af855df77275685
MD5 2d2e7edc801ee05d4a5532cb902de048
BLAKE2b-256 587422f6f1a7f31951e91db61554722e96948ee8784ac7f9f9b7a5ebb2032bef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 97a2b65282b6b563e9fc13a16eeee7b07f8b1156c34039b05f22ab55eda6a411
MD5 31036dafa7a8f7d92ac783fcf0c88149
BLAKE2b-256 ce9b9bb223ad05d4456a06d53a70c897afe0e350ef6f5666820365c2dc4e58cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6f80582907499561272133fecd8b15c0d2215748f964d8765882b1606eaee866
MD5 4c67d9924f06932bdfc3e648acf913b9
BLAKE2b-256 5a9a11b84795e302b727e59f82ef9d6f489e20eaae3bc214b2f1d7b885939501

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6618f65215723bbfc894f1eb8e18579cc2aa18c1bf396593f563e9fba0feb7a
MD5 4c358c47994d2355ffc571f26d29b11b
BLAKE2b-256 087e3abb5fed383decd794edc6ce034d10f3aaaa1d2353dc3d7a127fa50f5303

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.5.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.9 MB
  • 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.5.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bc9664f6ed553fb2fb928c25acab253412447ec25d1c50b17b4ba76642014ea5
MD5 d02b107455879b0997905905b8d8318d
BLAKE2b-256 9c6c03dc389ec57d781f9700f7102017f99434ad7f21248b1e4225944bede277

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b897d13da24a49f1d03c7ed39baf83bf7ccade55dceea079cdaa65b7bfe6c3a7
MD5 4246e1d1f4115e29b91c895ec6cbd73c
BLAKE2b-256 2e97ec9b4f2fa2ec132b181073f522046e5d1afb2e81bb5e92190130c406197d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 348f47818ec9e78eb179e2323764593cd1d6a37a9ad27b5f4cbfeff33c9a92c3
MD5 bc01935d4d5b62514d14a620ffb976c1
BLAKE2b-256 ac01ce91ecf6a23c4df61184e17fb8570a01854670d2e386a15fc860577a1052

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 310df183de99db0c102a00d8e3d18dd934c40b6c0aa5bf30b139f8aed35b6729
MD5 d7f7f6284d8676d99583aa1c656e7f1c
BLAKE2b-256 23bc95186985d0d5bd961dbfc43e423b3425dc0611607260d6d489e0ff435d2d

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