轻量级量子电路构建、模拟和编译框架
Project description
Janus 量子电路框架
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file janus_quantum-1.0.1.tar.gz.
File metadata
- Download URL: janus_quantum-1.0.1.tar.gz
- Upload date:
- Size: 273.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
433ebfbd69320117f89b28aacaa20019a6737e369e4a01d4f787e078dcd46139
|
|
| MD5 |
b233f6b3f5840d4472961a6a8307702c
|
|
| BLAKE2b-256 |
d0109e3596473fdc53bc681e11a4df4520ae73735b999a89f1b416f3fb1110ae
|
File details
Details for the file janus_quantum-1.0.1-py3-none-any.whl.
File metadata
- Download URL: janus_quantum-1.0.1-py3-none-any.whl
- Upload date:
- Size: 321.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc020a56716b04c1c962de6c368dd6a8256f139d050d3e096e8d5eefd83e7e0c
|
|
| MD5 |
31d97b2d9817ef4c846294abd27618a1
|
|
| BLAKE2b-256 |
f856fa4cecfc2944cdc8958e1bfcdacb6947bbb4ba8a6a012d6dcfd60999bd68
|