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.5.1.tar.gz (117.7 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.5.1-cp313-cp313-win_amd64.whl (413.2 kB view details)

Uploaded CPython 3.13Windows x86-64

panta_sim-0.4.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (588.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (580.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5.1-cp313-cp313-macosx_11_0_arm64.whl (518.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

panta_sim-0.4.5.1-cp312-cp312-win_amd64.whl (413.9 kB view details)

Uploaded CPython 3.12Windows x86-64

panta_sim-0.4.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (589.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (580.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5.1-cp312-cp312-macosx_11_0_arm64.whl (519.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

panta_sim-0.4.5.1-cp311-cp311-win_amd64.whl (413.3 kB view details)

Uploaded CPython 3.11Windows x86-64

panta_sim-0.4.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (590.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (581.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5.1-cp311-cp311-macosx_11_0_arm64.whl (522.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

panta_sim-0.4.5.1-cp310-cp310-win_amd64.whl (413.4 kB view details)

Uploaded CPython 3.10Windows x86-64

panta_sim-0.4.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (590.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (581.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5.1-cp310-cp310-macosx_11_0_arm64.whl (522.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

panta_sim-0.4.5.1-cp39-cp39-win_amd64.whl (413.9 kB view details)

Uploaded CPython 3.9Windows x86-64

panta_sim-0.4.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (591.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

panta_sim-0.4.5.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (581.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

panta_sim-0.4.5.1-cp39-cp39-macosx_11_0_arm64.whl (522.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for panta_sim-0.4.5.1.tar.gz
Algorithm Hash digest
SHA256 e3a8e236873b18c0e0a034fae1a48301513a74c5e81d5f0acbd5db4a08d9ca86
MD5 add9ca80137d2a0ec096e874ddc1f2c3
BLAKE2b-256 0cd25376e729178ead3441e80f0196199f562ad3d859619c831989ea912e4523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e120e4433a077ccb3e222b257bdca4272d429578fa2136cc2db01e4d70f9844e
MD5 c375ed45767c82cf94d1e2b5446a69e0
BLAKE2b-256 848300607274e04d3e24f79577928e4df8d7ea02bc2945f318db9a97f8b5d170

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe1f959c194cf4b3aa175ac78b0ed802a150e2e2a7415582ef9c5c5096c1f8f3
MD5 de47b41ea69d5e333016d46b5b2bb12a
BLAKE2b-256 95625ee5228eccffb979381979558602d4ae1afbc36c1edeb37d1683643b7f1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a7799abcc41cc146a982e13c3673612d43842560e16dfd0888da1aa9c362199a
MD5 7688919c8c9fb4583f2e04273b7a119b
BLAKE2b-256 f6932ff937067aa5c6331f39b70940b39b8ba0556a8ef30d5b36a921fc502fc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1d9c3ed5e8ff353e9ec854098b1eb3a8b6adf1af7254b42577775b80366cc29
MD5 054345d3cbe23f373b0bf7a50919b282
BLAKE2b-256 e213e5e986be3393de136111ddc1c9552ac2b28657016cf320bb7eff8f39723f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d458a18a25f80dd341ff22d9ef9ca8042a9eb7651e9cde2976f02a91dec91fa6
MD5 02ad95b623cce6dd8b8fe66a54d52f7d
BLAKE2b-256 4795d2e582d5de4bd388fe81ab9e922493227db5cd3df683f8b776ddf35c6539

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24efbf5634a6dc6ea9a4f84d5ee1c601a2a453e8f35df0323b89d1ecf609147b
MD5 d43c917f6a36d7e01e857fc7376181aa
BLAKE2b-256 dcc45485101b0f21e5ae8ffdeb2d4bf0bbfda774ba05535f7182622cb92de596

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3c807c6430a813a5900dbf0e3c2f13a407f7f8afa0e2d752b3ac771019a8fc43
MD5 e89f8813da9b7ddd0d9f9e7f7cbee5b4
BLAKE2b-256 4fdccbf635f1234106a36b55622a64e828fb85c466b13785edd0947b95982805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 47d70c7417e9b67158e247aa39691b9a3f8be7d8b8b5f9f08bfc8f780e82aabc
MD5 e72e01d4e4772cda36bba3fbfa6dcda4
BLAKE2b-256 8b43c12bf5cc6be010425d68a19b1fbdc13d1a88bec1875e4283d58903983921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7f27f9af620609fbc2ca39ccd4955cac8d291e04c6ec5185e70676ca828f19b3
MD5 4f1ecf6ba1a4a0c3f7f31c21080da11f
BLAKE2b-256 ad72e0407b03b8564167c4986a871d318f57c88140c4acda7b63925568ce24a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 320ec19a4c60168890cc1d4d21d27dee9498f8a48e901c52b950df128597a3c4
MD5 9c64974137db588571be0213da6f91b5
BLAKE2b-256 b80629b702ad927a40067286f4fbc74a1b4de2b021d1be3f4ff57bf8b8f965f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9297b755f0ddf450e1005615403bc587bc35ccc2ac803c3ecd4fc82263d5fdf4
MD5 cc5e0e5508f3f90fb572b824998ccb57
BLAKE2b-256 65aab1a50ad906c0a8bd3b9d8897e731f5209dd04ee14ee059cb9d31f193bc40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5834f11e98d378cf4dc8d4a9157242207fb706760dd11acd7fe6d1f271b62420
MD5 d7e35f4eddb9e9099a60855894037aff
BLAKE2b-256 93e1acbd0df709b4d12899feac422de85afe328550e9dfbbcad8decbad68717e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2add99d27c0f1efed9e1272aa1a7c8ce3ad272110c1933e7263f3a240ce7bf4b
MD5 31f88f794586ea13877ac3d5f8a33d65
BLAKE2b-256 077e7daf4b7b5901d2ef844dd08f423ba1e9ceb87b9d3651795d6af832341f19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1edee3aab196169d7a043d0aed2595808fcbe67445aa5f2363d6cbd1902b5e4f
MD5 3299af24941ef7be11c3a254b9624842
BLAKE2b-256 f2e9c91f7d1fb4ea0e5f32294e00bcf362867949f6d132dd266f4da939b578ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 78e16ea1911356120d8fcfb0e622f4a8b05071282fa73db46aaf781c272542a9
MD5 4944df060d2b76119b263da2167bc1a8
BLAKE2b-256 92c02eaa17accc3cb5c4f5edfeb97fdf0d13c5b4e9628f2e0ebfeacb3c7a7b93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c7d37337e3262ef229fb3bdcec640c2626f88a02535687f8b256271d847c468
MD5 6144f265be52366b9b0283d99c7245a1
BLAKE2b-256 a06d8c6ac20a12a8e9b02868126f50ed95fef65c63e2336b56160ed70ab795b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b80a6511f568bccde2342fe7b3d6daf0e9610149125a3bb39fb2b62cc86a75a9
MD5 a5168a599d740eea98cb2250e59c8d27
BLAKE2b-256 69549778850c78c4e1f7f28e3da07a8de86451cd7104b2d444fd2eec1fe6be6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb61be150915c17d2c44a35c22f1882f786c1778868f2eea44abdc39679f4545
MD5 45c4a0dae1914b37a292295b0c69ffe1
BLAKE2b-256 7f7f40ad97bd7a11de14faa645489cff5e18a6aeb5fa05ee92818964a3ad7a41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3037fdb0925fb82a0caa9bddb2a8c2144fc94d1aebd2e4b292b5f6ed239736c2
MD5 755fa65ed01b2bf2057d1884068c52c9
BLAKE2b-256 8d5b8ef8b1013b0080699e636c886057382d3cdf2220118b8ef74e345dc17251

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panta_sim-0.4.5.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 daba514ec2a63b74650302916d8420580b622912a0851e407686b7f894eaadf4
MD5 be7716600eb7e3d73ce37788a156dea7
BLAKE2b-256 7ca99273cf432d9cd127b371fdc6cd279806c2b451ccf98ed8b5ad6418d78b77

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