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.5.tar.gz (114.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.4.5-cp313-cp313-win_amd64.whl (410.5 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.4.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (586.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (578.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5-cp313-cp313-macosx_11_0_arm64.whl (515.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.4.5-cp312-cp312-win_amd64.whl (411.3 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.4.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (587.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (579.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5-cp312-cp312-macosx_11_0_arm64.whl (516.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.4.5-cp311-cp311-win_amd64.whl (410.5 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (588.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (579.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5-cp311-cp311-macosx_11_0_arm64.whl (520.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.4.5-cp310-cp310-win_amd64.whl (410.5 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.4.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (589.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (579.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5-cp310-cp310-macosx_11_0_arm64.whl (520.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.4.5-cp39-cp39-win_amd64.whl (411.1 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.4.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (589.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (579.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5-cp39-cp39-macosx_11_0_arm64.whl (521.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.4.5.tar.gz
Algorithm Hash digest
SHA256 828cd7180658a7bf345e567319fd99cd21971c6cfe5904f03808f3e8379cebdc
MD5 427231d594be7277b2bec981170ff56b
BLAKE2b-256 a2baff5e19d818882d9774c40bf3d6e4e150182a2181155cab3468bf7e4a1e38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b9759c257b02fca7294932e043051cffd8a53e95c415b0daaca2da4986f38484
MD5 319a4d91ea206f1eade396f2dd74ac7e
BLAKE2b-256 defcf2a767682515cc9914b2c2829d40acfd9ac1798c5d93edf5886e0357abc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d56d2297c07b996634857f5291106da0c2005c1275d29c88392bfe2a80f67f76
MD5 8df92e3cd5e67e63fcdd68b6f3a17e61
BLAKE2b-256 a4217b1b7a26941423bf61a2cdd9e64e462b19576a2fc92eb00e3253e31335eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 22c99cb7fcdada738aa914210709959d04288ca77ba03ad9cc7275bbbf57a934
MD5 8f06532479b570983a47e0ad336b9a71
BLAKE2b-256 62cecfbef097dc039e2740f2ef08254d744ec6ab8a0352550f60412bb874000b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bce5897a81beb4d88566677933642c1925df1fcc98240f325bc1074cc8144f96
MD5 401f2999eb3881b86836b128ef44fe93
BLAKE2b-256 587f38103916b6e021257cc2121b4d7ac4f1281afa479b67b7542ab9d79fba06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7937b23005b9caae116f9fa6ad08e90790ff020c06a74b31e5d9b08f3c5731cd
MD5 fce89e30b0bc351524463e4ce0062c58
BLAKE2b-256 ecbbb3cfbcdb7480d96571fca4198e9cb930b913891db7e2bf893ddab94f1c4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec6497f2efd03a9fac1bf6405ecd1fcbbe4026116c1fdc10ee3a24f1880b757d
MD5 4062cded683c8b9ab59e00340bf7a52b
BLAKE2b-256 61139d52b641e2b2910eac44d72adda534fb1e6d4d2c4c8c0bbc4446f2a7446f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dad813e7128e3e9642a0ddc153311d562a01775ebadfda541f3c3d2fe310cb32
MD5 400dd48d17926859069f0cd55f914110
BLAKE2b-256 302e1c7e3eb94b5e93fbdd45811ae7684422d165b57fdb2b2ee93612943e7551

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb00b5a128b9b90b815b429738af806fccfa7f2fa27cb4e6b0d6149be207b149
MD5 8fbdd282e52371b253ab7dbfb5790e3a
BLAKE2b-256 7e75af45c5bb940bbdabd192d144c3a7cd949eed17d92232235f9cbb5859b49c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d1f0893cfc60f77ef0e7cd541b84dbca53968aa49f747a6bc9b2f3d8177dfaa3
MD5 a5b52b292c14cf3914a12c6f2a146975
BLAKE2b-256 d33da190a6f8f469d55ea2fadb82834084e74b446b8ee32443f8edfd59fb89e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0dad1632f4af07c7d8c641b7fd2cf4f28694ca3c720a14998d5d121e8c05e58
MD5 4a10194d93d7beb1b5db8cc7a484c944
BLAKE2b-256 53e2abccb42107c7d0f7a265492df559b45d01602159521f2a8381173559c523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 10a0df4a70e293342875785ee80229df66a9c55a2f035ab8784d2478810f7b0e
MD5 5eb09ec5a88808391ba0f121f3a52a67
BLAKE2b-256 9d419ecd840bbdd5f431a44ee8281cd04c2c13237c32598e60b588c5cc9b4403

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25b1f4c99001d2a869dfed14a2999683f1b12abf09d71a8a4302f9c0e3b3fa29
MD5 9dbe229882afde20fcc3ea6187861fd3
BLAKE2b-256 2bec7e0df43f5c87822731574f75fc9c8327c558d6dc715140cfd72c93a07d81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 88799b3abd426ddb0a33359660220b8ecf38199dc93f475494838475a949943a
MD5 fa22ac57ac71fa7195e6637955b18d6b
BLAKE2b-256 7881a20cf67e8337e1cea28c2284504d8bf2d7fee1a4912cba160350eea93dca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 898312ce0ea31deca795f998b9499965f29bd6423b2b6dd46991c1ccfc39a704
MD5 7e6578e33f0abf0f6eb17f97900be9c8
BLAKE2b-256 c627a7a2f69caf36491efd64a1c548d90d1f281e07340eac7fb9a45e5c967d66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cf22117e6143d98067c00f084694e5e5a4efac76411f2a245546ace0cdf9b57f
MD5 fe7be6f1a62a7629b9cba35f50257c05
BLAKE2b-256 150698c0e6144dc25b38ebee15438af632965844f8528a9d782935c145bfe505

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f5ddd296f07b7093c3d70715582cca4df1cd9a228cae0487fc45faa391a8e71
MD5 a3b59390feeecf86fb6347060d5d20b2
BLAKE2b-256 9775863c07e88d0e6336379d8724c5d79675f26af88bd5bcbebad4b62cf1354c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.4.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 411.1 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.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 625284e25520e8c7b0761b43a9fb32ae1fe6ef33d772eb1139ccd9172702b5dc
MD5 1355c7b2a17135d51a2b42953d05c6ad
BLAKE2b-256 0e0d33ea12603bc8c0c1f24b23b1dbf83e0766aebc5df5869b89410fc39849a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 523c989965ebc82b7db699244db16112b104b471a29a0b080b093a675ea6cac2
MD5 8e7717d922e4c56bf086d5615dca80f8
BLAKE2b-256 76496b295fbe77f98847bd54124d8f1e3f97c771fac86e73d2e52058e8ee271e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2d0d173a26dff28234e3799486ba1344bd9b2f87d695130a2ac569a7acddc34a
MD5 25c9177f96f15878e79392554d19c471
BLAKE2b-256 f628e66fabcf3b1af5ce5c3c59db74cb28817862a2f30a74ff641149a2fa2f10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1688ce24eb8541aa32df832c24d939d9210c5bfaeaa6c9d0566b609242a9f325
MD5 d4d1fe584c42044ba560d285e11b6fac
BLAKE2b-256 120515b099c80a0be993f99d1773aa37bf1359ee2cb09dab79fc0d855a1ba3d0

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