Skip to main content

轻量级量子电路构建、模拟和编译框架

Project description

Janus 量子电路框架

PyPI version Documentation Status License: MIT Python 3.9+

Janus 是一个轻量级、高性能的量子电路构建、模拟和编译框架。

✨ 特性

  • 🚀 轻量高效 - 纯 Python 实现,依赖少,启动快
  • 🔧 60+ 量子门 - 完整的标准门库,支持参数化电路
  • 📊 多种模拟器 - 状态向量、密度矩阵、噪声模拟
  • 电路优化 - 多级优化 Pass,自动门合并与消除
  • 🎨 可视化 - 文本和图像电路绘制
  • 📁 JSON 格式 - 简洁的电路存储和交换格式

📦 安装

pip install janus-quantum

完整安装(包含可视化):

pip install janus-quantum[full]

🚀 快速开始

创建 Bell 态

from janus.circuit import Circuit
from janus.simulator import StatevectorSimulator

# 创建电路
qc = Circuit(2)
qc.h(0)
qc.cx(0, 1)

# 模拟运行
sim = StatevectorSimulator()
result = sim.run(qc, shots=1000)
print(result.counts)  # {'00': ~500, '11': ~500}

# 查看电路
print(qc.draw())

输出:

q0: ─H─●─
       │
q1: ───X─

参数化电路

from janus.circuit import Circuit, Parameter
import numpy as np

theta = Parameter('theta')

qc = Circuit(1)
qc.ry(theta, 0)

# 绑定参数
bound_qc = qc.bind_parameters({theta: np.pi/2})

噪声模拟

from janus.simulator import NoisySimulator, NoiseModel, depolarizing_channel

noise_model = NoiseModel()
noise_model.add_all_qubit_quantum_error(
    depolarizing_channel(0.01),
    ['h', 'x', 'cx']
)

noisy_sim = NoisySimulator(noise_model)
result = noisy_sim.run(qc, shots=1000)

电路优化

from janus.compiler import compile_circuit

optimized = compile_circuit(qc, optimization_level=2)

📚 文档

完整文档请访问:https://janus-quantum.readthedocs.io

🔧 支持的量子门

单比特门

H, X, Y, Z, S, T, RX, RY, RZ, U, P, ...

两比特门

CX, CY, CZ, CH, SWAP, iSWAP, CRX, CRY, CRZ, RXX, RYY, RZZ, ...

多比特门

CCX (Toffoli), CCZ, CSWAP (Fredkin), MCX, MCP, ...

📁 项目结构

janus/
├── circuit/      # 电路构建和表示
├── simulator/    # 量子模拟器
├── compiler/     # 电路编译器
├── decompose/    # 门分解
├── optimize/     # 高级优化
└── encode/       # 量子态编码

🤝 贡献

欢迎贡献代码!请查看 贡献指南

📄 许可证

MIT License - 详见 LICENSE 文件。

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

janus_quantum-1.0.2.tar.gz (274.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

janus_quantum-1.0.2-py3-none-any.whl (322.3 kB view details)

Uploaded Python 3

File details

Details for the file janus_quantum-1.0.2.tar.gz.

File metadata

  • Download URL: janus_quantum-1.0.2.tar.gz
  • Upload date:
  • Size: 274.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for janus_quantum-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4c1f813c29b3a396ba0366f0831cea71734ad91c4ffbbedd3a827c05b98548b4
MD5 b55eff08fe68a93052c69df7a79c57da
BLAKE2b-256 39ce2c64f15a5232fc131b27481db969137fe01187ca0fc7699ecafc82fda36c

See more details on using hashes here.

File details

Details for the file janus_quantum-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: janus_quantum-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 322.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for janus_quantum-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8865853791c80a9cd5529bb6873e8b36a5239f6ef3467911d9ed360b68d0ab97
MD5 12a13051782c4b90ac9345a4ec71b23a
BLAKE2b-256 9e97e18fe40ad397c5466452cf2d895a4c5eb2f00cb4bcfc7cfe541bf0a215e3

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