computingvista-qservice
Python SDK chính thức của Computing Vista — submit OpenQASM từ Jupyter/VS Code local, chạy trên Computing Vista Cloud.
Cài đặt
pip install computingvista-qservice
Hoặc từ local clone (dev):
pip install -e .
Sử dụng
Lấy API key tại computingvista.com/dashboard/developer.
from computingvista_qservice import QuantumClient
qc = QuantumClient(token="qkey_live_...") # hoặc set env QUANTUM_SERVICE_TOKEN
print(qc.get_usage())
# {'used_shots': 2000, 'max_shots': 100000, 'remaining_shots': 98000}
result = qc.run_qasm("""
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0],q[1];
measure q -> c;
""", shots=1000)
print(result["counts"])
run_qasm raise QuotaExceededError khi vượt hạn mức trial, QuantumServiceError cho lỗi khác.
Tham số QAOA pretrained
get_qaoa_params là hàm duy nhất bạn cần biết. Đưa vào một đồ thị, nhận lại góc (γ, β) đã pretrain cho MaxCut — không phải chạy optimizer:
import networkx as nx
from computingvista_qservice import get_qaoa_params
G = nx.random_regular_graph(3, 12)
gamma, beta, confidence = get_qaoa_params(G, p=3)
G là networkx.Graph (đọc attribute weight nếu có), hoặc list cạnh [(i, j), ...] / [(i, j, weight), ...] — networkx không phải dependency của SDK.
Dựng mạch bằng framework nào bạn đang dùng cũng được. Convention:
U_C(γ_k) = exp(-i·γ_k·Σ_cạnh w_ij·Z_iZ_j) → cx i,j; rz(2·γ_k·w_ij) j; cx i,j
U_B(β_k) = exp(-i·β_k·Σ_i X_i) → rx(2·β_k) trên mọi qubit
Áp lần lượt từng lớp lên |+⟩^n; qubit thứ k ứng với đỉnh thứ k theo thứ tự sorted. Dấu và các hệ số 2 là một phần của convention — các bảng góc đã công bố không thống nhất về cả hai, nên hãy kiểm tra một ca đã biết trước khi tin bản port sang convention khác: đồ thị 3-regular không trọng số ở p=1 phải đạt approximation ratio ≈ 0.69.
confidence cho biết có nên tốn shots tinh chỉnh không:
| Ý nghĩa | |
|---|---|
"high" |
Chạy thẳng. Gap đo được so với góc tối ưu ~0.1–2 điểm % |
"medium" |
Điểm khởi đầu tốt. Đồ thị có hub hoặc trọng số đuôi nặng mất ~2–18 điểm %, phần lớn lấy lại được bằng một lần quét 1 chiều |
"low" |
Chỉ là khởi tạo, cần optimizer đầy đủ 2p chiều |
Nguồn: bảng fixed-angle cho đồ thị d-regular (Wurtz-Lykov, arXiv:2107.00677), median 261k đồ thị 9 đỉnh (QAOAKit) + rescale theo bậc/trọng số (arXiv:2201.11785), nội suy schedule cho p>3.
Mã lỗi
QuantumServiceError mang theo error từ response:
error |
HTTP | Ý nghĩa |
|---|---|---|
invalid_or_missing_token |
401 | Thiếu hoặc sai API token |
invalid_request |
400 | Body thiếu qasm hoặc shots không hợp lệ |
invalid_qasm |
400 | Không phải OpenQASM 2.x hợp lệ (cần header OPENQASM 2.x; và ít nhất 1 qreg) |
too_many_qubits |
400 | Vượt giới hạn qubit của free tier |
too_many_gates |
400 | Vượt giới hạn số cổng của free tier |
quota_exceeded |
429 | Vượt hạn mức shot của trial (QuotaExceededError) |
execution_error |
502 | Backend chạy circuit thất bại |
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 computingvista_qservice-0.3.1.tar.gz.
File metadata
- Download URL: computingvista_qservice-0.3.1.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf5f09eafb229bb64e2d3c1bd7711f9ea82df3b90daee07d73ef3bc24df2765b
|
|
| MD5 |
d0ce52c54f061f3109977f7c6c8c6d1d
|
|
| BLAKE2b-256 |
ce72bcfca8ba8c1c0dcb8a968db30ed08f1042a66299052ed6e2d807edfb5209
|
File details
Details for the file computingvista_qservice-0.3.1-py3-none-any.whl.
File metadata
- Download URL: computingvista_qservice-0.3.1-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f515bb53cb0042df0da8dea4d6b500ff94f4dcf4b80e23ff74fe8bd4de27a30
|
|
| MD5 |
b5afe93dc2c249ef58060e54683fbde5
|
|
| BLAKE2b-256 |
f9da7c445ed3dc2eaf8cbdcc3675dab1603d31deb2e7899c38088308b1d025ef
|