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.0.tar.gz (97.5 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.0-cp313-cp313-win_amd64.whl (384.0 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (558.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (548.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.4.0-cp313-cp313-macosx_11_0_arm64.whl (489.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.4.0-cp312-cp312-win_amd64.whl (384.6 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (559.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (548.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.4.0-cp312-cp312-macosx_11_0_arm64.whl (489.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.4.0-cp311-cp311-win_amd64.whl (384.2 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (559.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (549.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.4.0-cp311-cp311-macosx_11_0_arm64.whl (492.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.4.0-cp310-cp310-win_amd64.whl (384.1 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (560.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (549.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.4.0-cp310-cp310-macosx_11_0_arm64.whl (492.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.4.0-cp39-cp39-win_amd64.whl (384.4 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (560.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (548.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.4.0-cp39-cp39-macosx_11_0_arm64.whl (492.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b287cfb6996d022a562a49742d53143d9868fa7cea23672cdc67c8f0b698b587
MD5 234e6d2593e460ba6302c7636e551d84
BLAKE2b-256 441da1182ed526bf7039a8ab4835b8fd678bf823fa2ce9db88dc825c5887e320

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 61fae62424db200e185a0fc356900385a03540bf22efea081af2597d2d61c0e3
MD5 8454998fe846ca04ac72e78eef656a7f
BLAKE2b-256 bf076ce4c16e2aa589502784f7a6a8433d78b1284c57a01dcde19ce3f0789c94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3350ac06f729d0c9b3ff6a6f3c14f0051aac5701528a1aaf4080b8997d888c2
MD5 a48a559174ab8a106ece4e8c1cc85d53
BLAKE2b-256 57907974831af0631fa277255287b6cf4178a377d7022d5580aa391b3795201f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 639666828d58db2b65cd6d6c77a6d6790039c5afe280df552df95695ad767f4f
MD5 85ef26b519c41049527039359ea32f83
BLAKE2b-256 56c6207056520c96be9009b4aa019f86e4bbb29c813c531a0bfdf58b50dd9f88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0d14ad11c8cfc139d6c5b6af5412bf4a6ecaeaea5a12480b54c4295ff9dd990
MD5 ff42eac5020285e4eb2d928a7834677d
BLAKE2b-256 2ade194b9e9094f6c401fa94578405aad25b65cd427963c8de296dc63f94d0cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 78c09894a0b517b4e92d7e8ade6ff4774a03af8950c884f65bed412bf619dedb
MD5 630e3918a1d05caf4b700d8e831cd791
BLAKE2b-256 50e04cd6f28c3bf730d90f0a3e5016f8b9fff1971bc07df56350e47b9343f2d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d16c2bb10fdc21f474d60c0fc5373e16b63ecf6d5e6d9c85ba01f6bb6e8ec04c
MD5 0484f48763b6e14f6005d401481440d8
BLAKE2b-256 fda995b2fd2fe30f868b4ab16bd3a5139b071e0c4c09c0841bdc9d71d7a7274a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d8d7553ecbb239411058a6489f18aefd963a9827e6cb640c1cb31fbf844e9f19
MD5 83191181ebca799bf9b1588862841575
BLAKE2b-256 91a22a63855e63ee55eb96a793931b76566ab4f57fe71bce3d84d5ccd44ffe48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb6af6b558b4b8bba2679c897a6b2d6a5b3c44d9ab78e944686c0dc06ef79299
MD5 3bd482f1da55b52b1bc20defcf5f77f5
BLAKE2b-256 a9147bceeb7f5e62f61f076a76c57e5f287b531a5ed2d1f59d9b6006d773b1e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8fb47c9fc3ed1eff1d57989b5a60b8e3bee8fabb61baee088921108352de85a1
MD5 a3f974bcd238cda8cc51a90322769681
BLAKE2b-256 ef23c10a55473024321899605e74bc3d415b53eb67938b565caceecc92297ada

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 866cb6710f1b3d63bc7cdedd9e174188b86bfc055fbf370e194c5a995329757f
MD5 53ad377899752fa0663425d53df504ec
BLAKE2b-256 944237a1b1913e4287aa82d7faed67065864cdef7dee476dd2b994c427ede884

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 835ddf16ff69f67b1001af94aa2f598438b21d98bfacdb6b7b95864ea3e08bfc
MD5 c0f789435209655988ad5b9d2382cd91
BLAKE2b-256 726b9529d2fc534eb715c84bea81f3f98d55a24520e843d719dcebbb9afa7dfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46ea4af1f014ac22cded199127c2ee56ab2ae0953dc72230cb46a853c20eb8ce
MD5 662b46198e3d51f46ac099944109f947
BLAKE2b-256 9a19ec6887566e4ae3ccfa798dd0c5efcda89fc4c16777dd3d23f50c4dc1acbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 04e1d8fe3d1e2c7bfa00ac5ce68bb44e73f6c30f629b2063c2ef30da6dd197ce
MD5 d98b05d5d8717b29fb2cd7cabdc99998
BLAKE2b-256 5ffa253ff5e4ed167665bf82dc46ff9044236c41e9d2cae5a16e3ad3ac11553d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9bbdd4b78f4852b8c4709af1cb2a30c7c1d03e79cb54bd1d015228b96188e98
MD5 8c7b6a68cf8735c35b7041b0c101ec80
BLAKE2b-256 322de984f12820e7e73216504ef924015442a2ab2de13fd6f49b4cf88fa45904

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4a415074cc5ee8e80e0b7b3b066289739de1b254a0e7ca33477dbe7468803c0f
MD5 f4b8ce8d0497e633837fb1c3e76cf225
BLAKE2b-256 6d12ce1423002e356a901d542e58d5d9559220313f9a7e64aa986e7f76bf2700

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a634117dcb1b760664f55ab204f1b017deeec79f33efbf73a497cb1a503fe4f0
MD5 d0c65c806ff5d4c4986f1e1305aebdb0
BLAKE2b-256 59e046a78dbad43e6b09da8436cc0ea529a2bd8ff7539158d4890eda805ac357

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.4.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 384.4 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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 128e7f0102750064ba2739414d7ef4b7234def7ede8d5d7ce3531a34ab898dc4
MD5 8673652027d34d7077f24acd27a7aa1c
BLAKE2b-256 d8f2ecebb233f6b5d091d9cad38de47b979934f34feb64d71704841ef6adc829

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc06cdb8680bb59176348b5bb0c3849927eeefda024c5b5af1bb5039efe8b073
MD5 0e3b29ddf191351ca38d70ed8070abaf
BLAKE2b-256 711da95494c3d45fe7e21fc5654986a7743cae4739f4e10ffc4d0dd635a3d8ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 be2bd26aae02ce2c0eaaf3ebf82e9d50324e055b4666874a269b856321a34676
MD5 6c0c17ce0a0e8abf4f0317517ab02cbd
BLAKE2b-256 a5751eb5bce04ab22f9529b60b5164ac955d4850ab72232d1e743ede19c6261d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8de5266744b671c11459efabfa5c5b6b113fccc9fbf49ce9a171458a02750914
MD5 4b53c913dc2c83ad3ace60984815412e
BLAKE2b-256 30ab4fffc865988d7138e292f55572e1907b60e1acf2f57e88d8063f7b05b6c0

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