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.5.1.tar.gz (191.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.5.1-cp313-cp313-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.5.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.5.1-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.5.1-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.5.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.5.1-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.5.1-cp311-cp311-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.5.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.5.1-cp311-cp311-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.5.1-cp310-cp310-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.5.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.5.1-cp310-cp310-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.5.1-cp39-cp39-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.5.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.5.1-cp39-cp39-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.5.1.tar.gz
Algorithm Hash digest
SHA256 7c3685b57a8f08a3a5749ace400936ce80c33883a97304a8d28a7d234b1dadd0
MD5 18058eae1e53ecfbec3229d2cb46dd13
BLAKE2b-256 2277dafd5e52604828df69476c29f0ce9874a82f171a93517bcc6cb20d9c7709

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 599ab3dd3e6a896d259637f6b1bc5d575ec05d9dfd98d5cc47a3fd9912e5db4f
MD5 c1a0d8bbdcdecdf4265b3823f66f1199
BLAKE2b-256 c06e4d3ca810fcb2353b5f341600c1b66e9f8678bd358bc33fec3738b5811e74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a19e835a9de47af05f88c3c5ec771b4dc1acfa21748d67a0fa7d45e0ad9869e
MD5 0131ecdea88ee6e41f778fe7f8247465
BLAKE2b-256 5e6ef6dae5e5e17099a35525c9eeeb048239cc158f094310c35979d51386dd4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bc67239a4580f498f3d05352f15f534ecdacd3b5d0a900fef37f837d7ff68161
MD5 02f286404c2be83a50e0f4448d75fa32
BLAKE2b-256 f2c136f43b6b0a8f24f0472b05d9fab5fac1ed9df214dc9e99cf0315e21e6d4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 454b748c80ed35250ccc5f99451ae71aca74e027a5b128abd0e59b9aadf91a05
MD5 2a368c0a916b03b0c8c40b28b7772685
BLAKE2b-256 ebf61c69a44ea093372defce08ada9048502797990c0c7fb8c84b5140cd0fe5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ddb659ab1c3a634a5825bfb52e87c16e03193d38294f0e2cbd034e49ebd1b797
MD5 7ec5168dc5d3ed3f3b3e7b9e413f8fba
BLAKE2b-256 20c7f7e6613cfaf55ee239b5e3018fe267b66213a5ab9ecd597672a3039df84c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c7b6346cf05e54f256b696c63d5a6c566627da2ebd54a3e4c28abf24063b2aa
MD5 7120acf7eda5bee65c017f68cdbe3c83
BLAKE2b-256 2398f52d26890dc3e00cd0a2ebdb2c54fd35d6dce19f828f756e469c9488c4a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9efb7010b11dac591b6b81f851a00f1b666199f5fdfd9692ebcc9cc1fea328bf
MD5 e169d52a1dea4da170b2f0a72e04c5df
BLAKE2b-256 66b8957ddbadd3b420f38197c2b5d53f03c6ffdd604c256db2bcf4bcec7e6b87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a984b62f0eb6b411eabcbd033495b95d79d3c387c80ac637b43fa8350bc9004c
MD5 38e29dc779a4e05ed80d503acc3d34c1
BLAKE2b-256 a2eb133178d6d57a5212ab17a21ee0e2a543b17cdd52a10b5e24c37c0eb86f13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f4ddafa831897e9cb95073f05ca522bccd3382b4f542ee8551034622b40e508a
MD5 34f5e61d25f19b97d2d7d9d5a8f9ca85
BLAKE2b-256 7bfd32bcb97c70342ce2c91fc14b7ac9920b5c8ae66243ed3175caad7ede3245

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dfdb85aa8fbd9f01399b9f4dcfe8a103d4fa3be68304bbf8915ac9dca0e8afa4
MD5 cb83b866e77f26e37de9881833287e1f
BLAKE2b-256 cd611676e43d68ecc8f6020dcc6ad8608545033ee2dd0dae9597b2ac0b5f2546

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8f92d8a4dd0f752e2cad04f4d0b57259f6140708d91f78f753bc531b428947eb
MD5 cf87b1f641b1ba668996b750630f42d4
BLAKE2b-256 4597745ee672ff08441ab254d5927a0e96cd934855c7867a9edd9e09acb306dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86406b5cb10ea8f19264f65beaab6ab0ed68f5e89560555fd1a50123987bb599
MD5 3f5b2dcdeae2b7eb897d750487339e1d
BLAKE2b-256 f84bf0c18aa84312a7e49be87a15df1fb3e02cb82b956828e2d8e8491124564e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 994b15bfd6af0db4368ed633e15f233f2afdae6f4ce9be2da8bf47bc74dd242d
MD5 3b003509e370efde50596406beb5a5be
BLAKE2b-256 2e642ccf3f645d174391b3211c14773bdc50e53fb2bb8afaf81c58af8afff67f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a7b7ea649fa28979006c5fbe9871fa10b5ec935891ef69bd1de26f93317eb8a
MD5 06a87472376bb9c0b85f6ee1f189ea2e
BLAKE2b-256 8140dad1abbb1ce8fd0f2807e2dab85f1de0507f8928ae5f3ff37bc38eb0ca07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3a8f2c6b85642bcb17f50b4d89f4fcf87fd26bc993f461682bb009b55efdbfe3
MD5 63818809236976266658a4083fa60e4d
BLAKE2b-256 f55266ac1d1540a9f97057bb34c781d6509d02ed83b60b351dbdb706b4447675

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7695af26ecc9656d14271a9e8ed1006eb1b65c5f1eea5dc111050582522484ac
MD5 9138ea079416d8dc4cb4ab60ce20d7f6
BLAKE2b-256 189fc8a5fe51ead7c0f753f4cf25245fe942843c4015b658144e7b2fe867d5ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.5.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.9 MB
  • 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.5.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6cb5b8bb3718196de25947294366df379e472fba46b5f6cfca818d33c6b68889
MD5 7bb492d155d0c670e15d3bea887dcd23
BLAKE2b-256 d6af7542764f065f5ba294a6ba36edd24e3f07f86357015c9e9408f7128c7981

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed664790ebac1ad014642f6947e4d0873a8efdb12757868e40753afab58367d8
MD5 d86094cf8edeaebea6c43a352116b927
BLAKE2b-256 1b2a0d4aa1cc915efda0fddd647d63fa7878f21b16709d3679073b1f8c2e74d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0d58b7c4920e79501f1eb1b0d43097aea739361b94da83439f644111b06adaa4
MD5 9ce14cc467408714da76f12bdd3c06f0
BLAKE2b-256 e5167ef26fe8670d7090329ec5e3c3ac99916a61124e4f97f0ffb190dd897c70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.5.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 caa4bcca143896f3d87ee742e411fac8c8317559832e5c5b0f0b15ac75b1b885
MD5 9c4381bf5ca632d659770986b85e61b1
BLAKE2b-256 8d00aef5f3e8bd7188601a183fbe4c593ceb63b1a99d922ba0cca948029c1429

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