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.7.tar.gz (141.1 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.7-cp313-cp313-win_amd64.whl (464.7 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.4.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (644.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.4.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (630.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.4.7-cp313-cp313-macosx_11_0_arm64.whl (565.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.4.7-cp312-cp312-win_amd64.whl (464.9 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.4.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (645.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.4.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (630.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.4.7-cp312-cp312-macosx_11_0_arm64.whl (566.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.4.7-cp311-cp311-win_amd64.whl (466.0 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.4.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (645.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.4.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (631.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.4.7-cp311-cp311-macosx_11_0_arm64.whl (570.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.4.7-cp310-cp310-win_amd64.whl (465.3 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.4.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (645.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.4.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (631.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.4.7-cp310-cp310-macosx_11_0_arm64.whl (570.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.4.7-cp39-cp39-win_amd64.whl (465.6 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.4.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (645.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.4.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (631.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.4.7-cp39-cp39-macosx_11_0_arm64.whl (571.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.4.7.tar.gz
Algorithm Hash digest
SHA256 434e0490dc9ece9f1cf0d094aef752e9183457b605b5215e10f624c0212f35d4
MD5 cc4362db4ecb18b95c84ea59f2c10655
BLAKE2b-256 3b930bb5ff1057620befece751c03ca0c6f1ed82874ea91067faec326c5d588e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b9281d6a2dbc9bf15cb6f3c6543377bbd9c9628da103d16d5ffe9e2a67cccc18
MD5 08f0bca33e8e301e3ce9fb171ab26613
BLAKE2b-256 d684ab7b7a1fe9229478e80043dc5134a8ea94329925ea84a329f0246d81d777

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 efbd112e2d80a08bac86a9585fdf16fe193ae23fc267a0e214213e524f4fca42
MD5 404a0c136ba77ba7c365a984b98129b7
BLAKE2b-256 b5c1edb67e6dcb9b9c72929d856548f9ba1289e3966fb7ddc7260fbe46d96ba9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2a34c8e1b3e247f7ba5c0e17b134e0baf8ecaf0b613afba49aa523a432a0fcf3
MD5 9e706938fccc385d3cbd4241e32d8aea
BLAKE2b-256 41a0d2b4b0cda5e4497615b967ccd23f67f6b48b7d0088b0d9f46dd8349b1b31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18b531abc3dbb7a4053da48f3b4db24273c93fcacaf685468359e8e2d2412df6
MD5 692c3ec31591fb151f0d1da0590ad554
BLAKE2b-256 3fe4be4abb8d63d09a7cab96797b19e40e95592133a4772ff728e720cdb07092

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0c7210d1c6bd90e4e7ba36a6e735012b7e03eeddef8b323ec6d04bd0a30070e7
MD5 b91bcb8a3e53b3303580fdcf4b18675a
BLAKE2b-256 996afca6c6759d5880441e3cb8760113bf8267556ca11a40b69ebff915093b39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8207e5682956af38ab7fa219bb81d75a009c38e7259624bbfed125490702cbbc
MD5 edd643b8f53418773566b44922822463
BLAKE2b-256 63e02cc041bc2c7b0073629b791890d66e744acf1ce6cf88b68f2f42d95e426f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9bd90618416608e55590bb4f216a350e689811f6f3a53a94be5cc2b18b943b09
MD5 95fc7d867af3da42f790a6753d9a569b
BLAKE2b-256 e4b43b95326fca7659cbb4b090e7e090d96737be0bf2d80cbb1af54b1a4e32da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a49f5898e65277be28e1822f9c302b89ba864121b6a50f2954e81f8fcc73d313
MD5 74898eebfc66356a7d13bbc3bdeec174
BLAKE2b-256 24c290cbb8de3d92bd5e365bd37aaedd5e48883743b0cd542135aadff24179a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0c793cfddf050282b15ca5ba672b094b78e8dd22cca58ddc4fcc44c82fae4013
MD5 e93b356a7b5117dbd35700fd90df46cf
BLAKE2b-256 16f58c84ef97f84a4997c340475c505b161f7d2b77fde3f2f3ba106755f9aa94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 abcf5c733928f0798e32c3e0cb41325147d3aac4a008d8f6230df8599b53ef90
MD5 9bec16cfa3dd2dbeea0b55f9a9909b08
BLAKE2b-256 3ba3233c8b114ee1e1857456f534b5009c3636300c48e2a95fb773922dae173e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3aedafa9a4e9febd4fe1a6d7a5dbf7de02dfbc66ad71ab5f96ffe00b3cb433d2
MD5 9c3c337c22a91d9deb31f9a7fe2534cf
BLAKE2b-256 93708623ef247e5e1caf10bc092e02d4024d7b23a6a7306aebf9b4567e536019

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d95f9c6e2ced82974a805f4276e6dc5a04c957a48ad6b633b4293239d1edac22
MD5 be464d4ca581d0c1d81726d1e2c7c411
BLAKE2b-256 411c0e74e6ff19dc7ba208d7fd99364526e2e987d128e2c59144927b58d1ac95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ddd46e5c548f13a4ac47f4bc4e35ab3f7a68ead80e34c23b12dc68547363e64f
MD5 966e19c0d62c6c041f1793634ec3dcf9
BLAKE2b-256 e257371d6e25c4e1c70d8d0da7237d4869480f0969bc054416cd09c010e99ada

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86f6d48720be95a28d5c890d4fbb9a6a276a5aadbd66f45a725ba790737a7f22
MD5 e5378861dd1a733eb9ce19cbb81cc0ac
BLAKE2b-256 2828489da38cb4f52e02aeb4f17d36f71b4ee3015e5c280656bfaf3def82aaee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0c9850f302ee43e52f0b3ec78fad691d4d2ef7c7f0c257fde824ae692b36b6e9
MD5 97b2c4db0ffb0b6fa6772529846046ea
BLAKE2b-256 d92a11a22919504ea3d18d1258849ea3944fd1cdf6935db4fb6ebf0a2a50484c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 263d2e07825b26b37d205993fa4d5c6723900b55703d19cce9e26d2ba4dda83e
MD5 f2c3800c22b62994ce5e7fcec9604a0b
BLAKE2b-256 46c5832e2cd5ae80fdd5a0116bccb9c8dd19a61d8d9963ebfda5506cf595e5d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.4.7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 465.6 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.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fffd3a12c542a61770ff0532578849b895b51b5ae1ebb1899142aa8cc58a8a78
MD5 839636d846f6844fb8b339c286761cf7
BLAKE2b-256 748fc0ef92ad3b611986fda7c7586ba90d6840c5eb8cc5c91e675569f0c604c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 760dd5a75b2d5aa6251385654fe92fb965071cc455b9a0ac855f00c6ea2fa849
MD5 fc097c54f0fd0fd34a56a5130a3b61b6
BLAKE2b-256 4e41ec913ec917d1c4d3087c2cbbce6dc18bdc558954531b88e1ef7bb58db7ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 97deb2cd0a710597518619133b2eb109483e02e51632b72b88417d2db3c6870f
MD5 fcf5237a16d2c3074a6240996816826c
BLAKE2b-256 8d417a7642f86e0767ed6766526f08d24f457cf80f7cf85f2e1de77a59c4cb0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 067025c02c6c9c14ce809e20ab93d175579e6dc3c19e9c02729f6b54deada3eb
MD5 e9eb73c1a084161b60375e965fbf621c
BLAKE2b-256 55991a69e62d69b029945602a7122c01b974d6812692c74113064a4d69a2d562

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