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

Uploaded CPython 3.13Windows x86-64

panta_sim-0.5.2-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.2-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.2-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

panta_sim-0.5.2-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.2-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.2-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

panta_sim-0.5.2-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.2-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.2-cp311-cp311-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

panta_sim-0.5.2-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.2-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.2-cp310-cp310-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

panta_sim-0.5.2-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.2-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.2-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.2.tar.gz.

File metadata

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

File hashes

Hashes for panta_sim-0.5.2.tar.gz
Algorithm Hash digest
SHA256 e52d6372a322542c5206f7f5cf93de3d0155ec4f514c50ae956535857cc24674
MD5 20fad1c204a7f06f8a179f14546ce2a1
BLAKE2b-256 1faac0827eabc3d8f156bb4a8b93b030e53f3bdd8da0b236037e3bb42071e1e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 18e0ef4f97a192e5882df068cd826c8f3782f3bfc1b71cff7996ffdfc1f5c5a2
MD5 33f9a34899df7644ec40c60f42fc1220
BLAKE2b-256 daf6640f5fea4da55bd711f41640259861973f3699cebf05cb7f249014e673a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d724c4321c69c99f7605d02ee45dddf51b99615aac138c80f6aa7c9db5e7b5e
MD5 d3ffb6eab44edec503b2f460a1c84198
BLAKE2b-256 9482e7c8a9d1406a14ba7c491462c31dc41c486a6bfff6da0b1c6c2043861cb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6e18fd7cd68395b55abb46c0f0d5c8996891ec38f368a280345047e0b38c3047
MD5 80713fb781f19ac0a0599b9963b51fae
BLAKE2b-256 f2d5a8ab55e68d96107c42a3ce2afb183d6461056598e1acd105dd9015f8c038

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20112e4c18ddd862cfc2e0c1241ab162b48400091cde63fc3a65800e1dfb7b82
MD5 2330c2e952da30065f97a5b43894b8a2
BLAKE2b-256 dac88f3b3cd5b169123dad90f730928ec66acf4040d9cbcf5f6a0a43d00dd073

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 209caa272adcab6f94fb9a4d63bb80a74c04ce874f67b7fbe55c33b4f2d6524a
MD5 136de4827332c2cb9b632d912e2e8bc7
BLAKE2b-256 4718a99ff27b92c260c2bfc7446db037c59d16820df0f6a3ab1e9123f069a104

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f52cd9c0a87b7dd197c29009ca1ce3797e3ec5016263f52c8c3463bb0c18d1d3
MD5 a5b4b52da1184284c8bfc2328b148cf4
BLAKE2b-256 be35050539427f81f9adec0a61c668395f578866e5d5f3343b88d30094e59491

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3743582371029642f45dbe6d600a3d797f42f24877e440906deef14f9bc920ff
MD5 0507eb649a188dcca346213944bd810b
BLAKE2b-256 27d88ea5519491badb4bc47044aab94eb79933ece732c9e47277efdb6bd95d3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28afe140a0ff243ec0fc27b9c4c3bae414631b477add99f5f9342eee34c60dce
MD5 96b37b8b9ab2385402d11d94ba8b3bf9
BLAKE2b-256 0cb777f84fa10889a471415e43622f767cc5e4d4afaf18bf334f7725b36b4335

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f0eade2ef6d0949e288e4a6e7ec4e90b29d8983a22c5937f1a3173f271e721f9
MD5 d9b262ad709a66dd510ecafe21c154a2
BLAKE2b-256 9eecf49d5ce4e161110114159926ea98c1a14f26479259286e9d2400ac80d099

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 facfc9f2a1ff28d1f5e425809acab546dbaf35f068d4a95e00e53768b36ee229
MD5 a35fde2dbc7e8ee6be517337d9842a59
BLAKE2b-256 b25e2bfe1720b6baaeb0cba1b0ab83f399c7d733d8253a5f35b699702eda2ede

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 96363cbfd861c2a69592b7576211d85f4b9f9babb802052c56b0364cea65dd0a
MD5 f74ad05e4612338bf0c49670b182ed89
BLAKE2b-256 b2a91d1b9e9e961ca1a24b4de71b62dc449ae9f5ea46b0b13b3c139144b64413

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7980d1510c5d7488ce773a924811a3a8fcbf512ce3b9782fd1351c26186a649f
MD5 938ccdaae863a52610d0dae5eb9814ba
BLAKE2b-256 d3d2ef346522efbc4585b5aee30c3c07348b803c14020cddb3b6eb7aca6cd46f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9fa70bb2082f420814071fa6354382cb1879a6d4ea2419d5ab5c3e1fb6c62aac
MD5 b8681dc1a610a08dc8c5f4d2decde2e5
BLAKE2b-256 65a0d8349b56e9e23094c9c526ca2642498a3fe29fe31d75ce9ac5d2370a1133

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2dd5902f54ed2deb00100a84ef7ff5149c408eacd5b812ad2ceaec62f3cc8fff
MD5 add15611bd6d5dac1400e9f2f8b9d7e2
BLAKE2b-256 a5f6cf750a4954cb10593c11c80c7d63d27ab6424854d37fad54e2a9a7e904ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a3e620b945a1815981a340eaf278c09cd5433daabfc5bd4e2aee01c98cc522ae
MD5 c51b4cb4af2b86bba0e06b4dc3a1f101
BLAKE2b-256 a0e2fe702a63946759a38acf8f7bc323474b00fd77c5f2f62effdab856b02fea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d8db859eb25431e12b0e0a515554a9f5c5a4f1ab87b8580f1385ad2606e00a8
MD5 11f2f88255860d43b1bd85cd055ecf2e
BLAKE2b-256 1b5d38c2df3a5701a22789bcea5bbd1fe90a3a1889d591512b411f6f026f8e0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.5.2-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.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bfd29768b814b2bf971e02f5b13a8ca038b1a89cb3861627706b2e9ed1eca60b
MD5 dbde99737d67b52aebee1d7ab3ef2a6c
BLAKE2b-256 a72069f53030828d9cf4132569cfcbabeb0f9a33ac0256ec6e729265a9022828

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb56584b97d71eea0cfac8c67aab0ce2e51f0d9f7502b1f6739bdb76cc55e992
MD5 ee1333926b7342c58b1fb963d7623d99
BLAKE2b-256 b73be075e688ff4aacd123b3042f503f10b08bb6aeae12d9c0b544c6725a9970

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2059e7bd18d5b8727ad5f8686cb8cc8ab0160ca936f4ad13ead3dc6cd17c95e8
MD5 8d64b82870ccfa7262743dcbf7c58ffc
BLAKE2b-256 24763634e1a89a1f0c273dd01893652908528d0a2e56f7d483e927b9ec01aa5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7fda6203178de3f9ce91a6701069fc2859cebe7f73dd31f8415da41bbd6bb42
MD5 bbe8767a41caa282d4a1d2fd63d0f39c
BLAKE2b-256 4afbd1104ca3bbed5fe982ce4d13d2750bc4c7832cdc55cc1c579e6ec0f28261

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