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.2.1.tar.gz (32.0 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.2.1-cp313-cp313-win_amd64.whl (240.2 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (406.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (397.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (343.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.2.1-cp312-cp312-win_amd64.whl (240.3 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (406.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (397.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (343.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.2.1-cp311-cp311-win_amd64.whl (240.1 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (406.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (398.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (346.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.2.1-cp310-cp310-win_amd64.whl (240.2 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (406.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (398.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.2.1-cp310-cp310-macosx_11_0_arm64.whl (346.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.2.1-cp39-cp39-win_amd64.whl (240.5 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (407.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (397.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.2.1-cp39-cp39-macosx_11_0_arm64.whl (347.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.2.1.tar.gz
Algorithm Hash digest
SHA256 093f59e568033caba62b810cf0e10b10675d09d1c3f5e9a87630573016bd674d
MD5 2a17f2f7628dfd41b28525648a0614bd
BLAKE2b-256 59d4e835cb9f9c536f3bee6265f121873d2e9cb55e67f95e8fd234770ca36437

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e1572544e4a2097644a7a64e3859451921ca9fbb37f85b7c74ce4f0d3d851269
MD5 cd884d34b959f51028afe8bea6d4d0ea
BLAKE2b-256 8838bc2bfcf4f7e17785659928f3f57dc6ab53512461b12d52b2d1188f8e6158

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c9f8724c82570f1a5eff3517ec26ff4c574fb7fa734f5931fa6c612ce0def675
MD5 8d0ffbead4b66bf4320297b9e2afb7f0
BLAKE2b-256 bb4ff02f38e6bf843ee92a39431059a70c6af15961a79a6d32ce4fe660cfe4b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5b0806db7988e85d3926a0decd43ac4dc60acb8262c836ae0ff2c94a63e4b0e7
MD5 5ccb839237894f604a521067e2c25fd4
BLAKE2b-256 70113c0e174c18c43e886b48482d68f47b166448cd913ab075c0d84eb75aa060

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd98e69e95bd4d28754d9cbabfeb7667c953cd0fcbba3eb70676af3e13c6e671
MD5 f98c8ba7b2af7eb97d10a0bed818ac8a
BLAKE2b-256 cdcc1e8c8c4ee87bf337e7e33cb58e11dd8687b7e73c74d2acbb31ea247f2c18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 29cc5af0f8a41c352b5c7c5a4c4f3bca1e5d20994a5acc33e154b2da7ca19f7d
MD5 bdcdb4bd31f4305d8f01dbbd42031754
BLAKE2b-256 8acc1edfe0fe8aa8dff5e93ebae0ba1addbb13c1d0ed98bdf62f0d9bcc5964d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f1286fd018371460991a17931311a76a719e5f3f52028475de25fe655f61431
MD5 eb43ca952860ab600690aa54f7231ecf
BLAKE2b-256 16bda25a98992fa880c834cb24c8453ad502b1bd63d1bbdd4b63e6a180f93a57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e3bff90f2a06d0059f59022f7b2dc42323201cb9ad8652f8a8f1467d8d1d2879
MD5 1499770e31c687a22c659571e563fc3c
BLAKE2b-256 0cf102b8d0e9a482274ba8fa4f96d8dea3f114af3f9e9da22dab6476f39e8f87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 60c69e712b820da3c321448992c1237335b7aaf8faec05e75541f4f01f687cf3
MD5 0fdcb83c55678466411a4b51ab77babc
BLAKE2b-256 b80e9a3a96ece3a39bef9f27ef1449517f65477994389c8dac5bc067ed2ce46f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6b1a659b766b2c703d047124e4ee581f131468408e4f5d334b8694c8008e1077
MD5 49f5b2f8dd87804f7f332a6da357f7aa
BLAKE2b-256 e664b05892f937661b11ce2fe73c2a7495b11cd304b416c9385b80ffbb57c9e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b03f482d684812c359ddd1f36e074a8dfd8ae2379f45c5e08e66375051004ffd
MD5 db4c08e2dee932b83c4d7bc9afd6fc23
BLAKE2b-256 5b0db109756e4cd958666b048d5983c6055c9823ed150d450647cb172857bfa9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c1fef6f3c653dc54bb53afc4a43c7e11bceb70a27838d1f58e21e23a8d22db26
MD5 b2de9197bccf8bc29898858207397313
BLAKE2b-256 a28e5e929b1f5ab8bdfa4fcace39fd59d9f7209a371ddb75765ebee905bcc5a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c389ba29bcdc63a976f75fd6899bda21d079b80f9f4ff3c67827a702d56f7cee
MD5 9097921b3a56303f60cd0cf71c915c2c
BLAKE2b-256 a8066e33910f041244f165bce6da1844b0fe4b138a02d6e90e270dd5ba69ba93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d255f8a215bee52ac74e4abccacf087dcfac59c8ff2c32047a48918cde44e15c
MD5 27cbd59c03ae3a7d2f1d302710c3ed8b
BLAKE2b-256 b0cd638a7163343b9be4b0f520a0c4345b3715459a5714902ca00dadb71b0958

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c10964df7c6bf84b59a4aa94d4e752d5911fd3d337daa1622f948fce09c216a0
MD5 14952d29969ecb0e0870edcf9221d0e1
BLAKE2b-256 0b4ef558291d8410b3bc87ae1cfedcc6db62c3d54adf1f5dda2aab423ddca0e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9da3b1da9a8607b298655de8faa96b2f1e8ee95def2508a942269868faae2b16
MD5 8551f9418e096ca1cbc30aa01dd25ac9
BLAKE2b-256 f86cf66d80e033693037600b8b6ddc336889a18b5351899a4cf43079f0a39984

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31ecc653ceb698f1e335dfd26797e03fe40563ed20946d5a308994637b521f2d
MD5 48896da42cf20ab7b075067ff7389328
BLAKE2b-256 dd0943596ae547c471b8aa4d1a4f9762dcad4a3bcd8d079f6749dddd97b81e0c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.2.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 240.5 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.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 936ed1192aa1360ef7d6290ea5867f451ebc6da6874e0dd3ba92bd80b7fb7dce
MD5 84c647764e996d337faed4c863b51c52
BLAKE2b-256 a23332843b836f888ed89e3a7722973343031343e9813950bfe75fcda890c564

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c89f11c283bb7203ec607f02048d5c4ed95f42b1811b7ec3d5e2eb4c3e299494
MD5 b8c135674a8991e12452c9ac350e4d48
BLAKE2b-256 9081266056857bc6915a7e84cc1e706fef96208de9004d1e8a7152f454fd1907

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fd299f663294b6dfb73325b85fc2326f0a2b786d4bf05c5a9f57c40e6464c5d9
MD5 1680d483cfd3bc4d5deb74c4d2fbd07f
BLAKE2b-256 04a2a7b74f8f78c1bb5bd87475672abd8702f4514c34cec5ae9cdbb73b6f0bc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 073fdd5fe4a6759e6ce396f86254b6a827f9c464956c279a0cd13b51d93b06cc
MD5 648b15e8f16d97f974e74d7e80480625
BLAKE2b-256 32adc3c8dbc77682eda861600c69145d023a546281c98b08da3a351a3875b0f8

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