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.3.5.tar.gz (86.6 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.3.5-cp313-cp313-win_amd64.whl (363.0 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.3.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.3.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (525.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.3.5-cp313-cp313-macosx_11_0_arm64.whl (466.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.3.5-cp312-cp312-win_amd64.whl (363.2 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.3.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (540.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.3.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (526.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.3.5-cp312-cp312-macosx_11_0_arm64.whl (466.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.3.5-cp311-cp311-win_amd64.whl (363.4 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (540.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.3.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (526.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.3.5-cp311-cp311-macosx_11_0_arm64.whl (469.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.3.5-cp310-cp310-win_amd64.whl (363.3 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (540.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.3.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (526.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.3.5-cp310-cp310-macosx_11_0_arm64.whl (468.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.3.5-cp39-cp39-win_amd64.whl (363.6 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (540.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.3.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (526.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.3.5-cp39-cp39-macosx_11_0_arm64.whl (470.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.3.5.tar.gz
Algorithm Hash digest
SHA256 2a95d994c36b310e23f1f0bc6957e7c2bc9d8e64312648ea60c460261740b4a1
MD5 70b86f2dfba5056e3f7907dd84395459
BLAKE2b-256 ae0edaab6af346ebdb08943397407cd54852e864f40ffe0a769a86bcbb032ae1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3daebd09854514395f0715bcfec0414701c71680829c5805aa1a6f7781201145
MD5 44709044fd52475a80e0435b418f7b56
BLAKE2b-256 b4cc05a9ae27f2c3fdfcbd31286b4749d3a6e46ef6e5604198eeb59dd2262cf6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9dac390c467f23d2e7552ee40403ca5319b4779f3edd308f777ec305b44792a2
MD5 fdd1947d5abfeb44790c8ebd0c722a3d
BLAKE2b-256 94c611d6fef7bd87897ea85dbe9b56c3a79e1c83a0fe25d4a250c2db3940bda2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 12808e295b4d497580152075d6fd2e3c6295dbba67e7b51f999f577da099ba27
MD5 60f931aa88a77a1b384775f3d16ed9fc
BLAKE2b-256 fc1f476ffa60337fa817ab7f617870d61e0525e7a7ddf9c3e74d7f74788c499a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b377eb7b74978d0b862ca9ac2f8389ecf4e3e53f9e5ed233068e5a1bb737e7ae
MD5 ac2d55c3d895ef52d50cad5210b1ee8e
BLAKE2b-256 15107ec2871c27345e9c4f6f95645114654bfbd449a3deda9879dbb8a070374d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 57a714d27ac8a3612cc0a3d236eb0fea004980db22d2bebc0aaadc43bc3bd1cd
MD5 b96f7615bf41483818c6dc9b5f22d991
BLAKE2b-256 6628261ffe31555075809fb0ead94793e6206763094e98efa5f89b1d04b620b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 376e61d27148793d5ace32bd391bb9abd7d1bc1fefc8daa8fd4ff4c9f30c08e8
MD5 32a031ddcc6ffe4e2668108383b55b19
BLAKE2b-256 0986fea415ed876fda3b84602237999ce7e0831541d289583f4a68bb92d1d1e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d1fb833f0b5edc8b78e49e27cd3a5b34ac2fb0ce96773a63aeced645d96b6aa3
MD5 4a6310f9ea54c7f392272dd69f0c0385
BLAKE2b-256 82f0e5470125a45aa5eae0fefcfbc1f08c859e1da4bfc162bafc09ef9c7b9047

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e6c29f9babb9215b311e5dd80ba0678823aab36a2cf1568c5061e41c2b49b70
MD5 494838fe2eb2b2cc0afc4295dcfcdd6a
BLAKE2b-256 f1e132b6b12778e14f7582956ef1ce799134eb05abbcb617a2406b60f5dd9443

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 08760600abcb1b6c9e9b10fce5be8017362aa6a64e664d3551c0e02bff3b21bf
MD5 76e0c4e3b979283ea34894cbdd128bcd
BLAKE2b-256 eb61b742c08105a44206e0f3fe793a848b948147f43f74ff2bb7c8c61a3573fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e8ece75918d15a8a19fd00b79b0045c403db9b58f079ecd73778e21bdf38e110
MD5 a1a5c70c7bb1f47b4fdeb1af4f2e4ad7
BLAKE2b-256 859b3d5041ad36ddceb7600ef7d6be04d3b09acba193da7a1bd8cd8f99fb341a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 61e0370ed91c67860f371b89fb1071cb921dc8244fde2f3c8dbee58aad0e4a85
MD5 57c38857e9ae119b4ddad966f4d293ab
BLAKE2b-256 505d0317da6095b3e93ca6741036ba9eb9841123895e0f543d0b77cc48692d8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fab7b58de3300594949494f04633d059d542a6f0d6ef9aadb30d5f5f17bb81ab
MD5 26cc70ac895ff028738f1392960a0207
BLAKE2b-256 50903df6907401bd942678f84120d8df0356728cb19232c6301299eb6e3f921d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6296322ada17632a7f480fc0bd1846ed8ca83ce1dc44bd6fb0d3728046ffb59e
MD5 978dd30d53e551f115b9bc2e75354a8d
BLAKE2b-256 962cc2cd89bdcfb3b5e4fafc7b39a99d27626bfd33ec22aba992776136aa9500

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc51191a50012f646f6b67e1d4e60b530df7dec72ebc182447c78715a39a50b6
MD5 f702c85eb0295927e29c1b55729f5097
BLAKE2b-256 dae3a756decd8a70cabdd3562b3352d614069af67eb7131d7d7a5ccafa99ee21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e525a78e270432839721fab3316fcb59870a7d9efcafdca2d817356acb263619
MD5 910e79fdd58f5a2ebb985bbafbcbc4df
BLAKE2b-256 82bed62878574727b669bb04f697ca7fd5b6d045edbd4a6417a678ad487c519d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac060136d410569350734ed82c5574540b2eb04e826a20bb3ba8fc46d3869212
MD5 53a4e79ecd69a2b7441d1d7bc56436b8
BLAKE2b-256 bb0f56594bf9648db0203e04a6fc03fa2b1f10859773514a3ce9818aa3d42024

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.3.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 363.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.3.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8a541ec591c4b501813ad0c5252ec20e37f19b08bb11071913f67590f98a14f4
MD5 83f3070dac1cdfe532141afd124587b7
BLAKE2b-256 a630d6c9a5dc0195da48bb98407b2f0890387ff20207d142422b5a8433dc812a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 23e7442dd9e3c98021598d0f9764b444a6f5a8095172baf186d1df16536a1623
MD5 1873b3c7a0c569a5fd73fa376ec4c994
BLAKE2b-256 0bb7b7f6da0cbc0e3239566071680c752fe189dae22bbd6cd8e388bb47c62a03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2867b4eec0f0a87306001ed3aabba22497e0e2f9a3013d07364c5eb11d69a5a0
MD5 7dcae5bbbfc05e693ab56cc6056179a6
BLAKE2b-256 e2448039e9411f196d9a55b34686598fc8ddd44823cf8badd5b8f1261bf04620

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 faa02b46a61a6d9a976eafdeaf7caa2f9fa20ae3b3bb899e41120fd68c3ea6d8
MD5 99d4b9b7618eaf1d2a64023398886216
BLAKE2b-256 27e7a12193921778475586357d35daf0c871549d76fb3c8aea22383e1520b645

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