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.0.tar.gz (55.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.0-cp313-cp313-win_amd64.whl (317.9 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (490.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (476.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.3.0-cp313-cp313-macosx_11_0_arm64.whl (419.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.3.0-cp312-cp312-win_amd64.whl (318.2 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (491.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (476.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (419.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.3.0-cp311-cp311-win_amd64.whl (318.2 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (491.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (476.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (422.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.3.0-cp310-cp310-win_amd64.whl (318.2 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (491.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (476.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.3.0-cp310-cp310-macosx_11_0_arm64.whl (422.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.3.0-cp39-cp39-win_amd64.whl (318.4 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (491.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (476.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.3.0-cp39-cp39-macosx_11_0_arm64.whl (423.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.3.0.tar.gz
Algorithm Hash digest
SHA256 308d9fa75b93deecaeeca98dab69cbb6cc58b34a8421c91f61dd10dceae72ee4
MD5 598979ddc7c482efce865b3d4f4c1bab
BLAKE2b-256 d4ec4767e63dc369fc641872f0ef90a210a3a41df8df03f9ece42ae2ea766173

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6cd4dfa58a190ea2c08b200e1c6984c040ad0f29a26b330e95c1eee019e0d94a
MD5 be30083717f957d723ab0c26e4cf0689
BLAKE2b-256 11b31c04067559d801e6c20608f30c1a8dc0cc82339709bddf068d76d2459fbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bbb508295126d3e9ca2c0f3f0639ed62954fe796cfe9e23af1d254347817dcbf
MD5 14245734edf8599e7a6389f6f2439def
BLAKE2b-256 832589dfcfaca33cd4996e5f11de9231f789ffce198310ac90756d62cc049ce4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f73d840f8738d761f062c68e0ae9b54f3ceedb08d756fd69e5c3dcea9f018666
MD5 05a5f327024062a11f3f76602e550e0c
BLAKE2b-256 67edcc13470a01c626ab64c2de1d6476b0e5493a7068fb753eac9883cc66a10d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08fe1afa7981334953da8788a0b59033c92b2a531bbac990fb84873751e78208
MD5 47730ba9e588920703a969132c10a86d
BLAKE2b-256 3fe54f2132482609fd032022dc5b16ed8363a8af6e83aed40a8465ba25404204

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0ea68fd57b4d3b8eaa3aa75d4bb6615f5bad47b82d049caf7f6afe81b0a7f6cf
MD5 ac7dbb98f234db0ebf113e667e0f5085
BLAKE2b-256 d6455d070f22952a1806cb2cd618a6af3849228898873eb39852f7e8870922c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c63e204cb2abbe93f6e140b07a1854fb0b25c5a1467635e7099a5628e5e8f92e
MD5 529442bbf7de7ef65b525006ced85b04
BLAKE2b-256 1adfffa7e13da894d89dd18874f2b1e6cd0f9ae5eab93d5651b6b0cc65928488

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 53f9061f4bde212b692fe55f6dd46fe7b8efceef127ba4486a782f5d2a6ca2bc
MD5 3bcfe5842091c5cbe5e8d18714db82d9
BLAKE2b-256 d019c01afedfc4392af612bbfe8f6aade74da5717826bbd8823bd40d60e0fca7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 502ea169ebcdcda5f3455a7a8b3f0aed26ccbe713a6baf8388114691fbae546e
MD5 bfc4a7dec3027845d101d1ee54341358
BLAKE2b-256 5311e47f747c11568de9e9689b7031d65c98132859dd050a2cff810dcb2c9ea1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 64e69eb0fd859ef5d7a01bd4d9beed02504e3fed8bb1535bbe59f2b31b6f842a
MD5 629ba4d5f30db76b76c3842e83532314
BLAKE2b-256 254fd77c9e76dbdb9d0b9912f2a6796262a3442e0f53ee7b76f480d39e87bf32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2e0761bf69d0168baf693dbfb3b5ce04db439948d1819a235688da9281d81de
MD5 4d689e6339009071dacb44aab0744e10
BLAKE2b-256 4c69987cd1436de34552dc50f0a30ea84476a2470633d8d27a30523447e8d2a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7304177f4a7013dd184ad684cee029dfc1424097adba9e083435c23b543b1c5d
MD5 b828a9a1a427653775d4590a1aa246cf
BLAKE2b-256 92df71865049c9f4ea9ce832745ea8ccd70c1232c9909ac3cc1de593bfaece2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e49d3a7eeaaa6236d181d620a89a0d148005f06e38f52db76ea0a78e4d95c7c
MD5 c4c574bd1449e353384bb743200f2288
BLAKE2b-256 21f3bb7d6e9cc14cb4788da5e2b42bae8bf7f7735843c0cead87a1b325bb6bdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c83ee15a2079cdf9262beb3421ad641315c38b94629ed88b40cecdff1f536689
MD5 d186bca36f7500be61589c800d67a410
BLAKE2b-256 07c6cdcf72ba3205126826e1315609faef6146ef7f14a22bf25d5ea63f3698f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c0b498b55756dbe2a725f2a0199517623a2a0351b3b70d32446e135067e1820
MD5 5b174d85edf340c7fb1c4bbbe90e24e8
BLAKE2b-256 90b25a1164390bd0784cfe3847a9e4af3a9d2fdd0d2a84987a93a74045c91702

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fc5173638c2f150189b863243704873fee6bef441282ee3772c4762cc0e3c1da
MD5 e5cc91f29ce313bce2c564f5f7a9b9e1
BLAKE2b-256 f790ffa6c0da26af0dcb10740567499dd669206744d68a53b4ed572773817f8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b916dbb343651213d34eef990e8b8fbe5263987bb22e5e0c84ce7a17faf477cc
MD5 55f738a9d3db692df3bc26d8157d2c84
BLAKE2b-256 ca91b0469c2d624ed8aab4ca4ffbedacd17e8ae7c89ee96fafb066b1197dcc72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panta_sim-0.3.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 318.4 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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1047d835ecdfdbd075ebd800d55aba7fcecd5b6fe29d76f04f253ea3fd866f66
MD5 c75ec98628c4a32b3f74b7ee3cc8a46a
BLAKE2b-256 2d161ec4cf7d114bdc758d41c2f1f463407d536681367a8bff055e50ef6c9719

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58d7bb37038572599abab68b3cd8070fcd9accc90ea7eb9f2c95dd111ffad1d0
MD5 ee81bbcb5d57ac51e9117ebfbeee31a1
BLAKE2b-256 1157da661ff1f2ec2a1fab2a115e736b16578b2126bc5014cf324f35e2116cd5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a98a5533fa354a7d7c8820159960be9cd8e75ffbd389c5f58d799b45dc02b39d
MD5 5f3eeda774f44dfa74a5013d3b7227a9
BLAKE2b-256 141f558b869d66a0ebce18311ab59f82aad01218efa219f93da456c7bb94fb0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 081d94da38851a2e6e470e97ab858c0795cc55cb5d0297187d7f5641fd00163d
MD5 7bb2094107c03760e7d8080f98a6bd75
BLAKE2b-256 9bed458c6d31739accfc0c2e83b2973afba4b6cdae72bdd3e3abf118f01ff09e

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