This release is a pre-release and may not be stable for production use.
quapp-pennylane
Quapp PennyLane library supporting the Quapp Platform for Quantum Computing with providers, devices, circuit export, invocation, and job fetching utilities.
Overview
quapp-pennylane is a Python library that integrates the Quapp Platform with
PennyLane-based quantum backends and simulators. It provides common abstractions
for providers and devices, helpers for circuit construction and export, robust job
submission and result fetching flows, and consistent job-scoped logging across
all components.
Features
- Provider & device factories — PennyLane-compatible factories for local
simulators (e.g.,
default.qubit) and vendor-backed hardware (Rigetti QVM, AWS Braket, IBM Quantum). - Circuit export —
PennylaneCircuitExportTaskwith a_PennylaneDrawableCircuitadapter that satisfies theCircuitExportTask.draw()contract usingqml.draw_mpl. - Job execution —
QAppPennylaneDevicedrives the full execution pipeline: tape construction, device selection, QNode creation, probability histogram generation, and timing metrics. - Rigetti QVM support — dynamic device-name derivation for N-qubit QVM
topologies (
Nq-qvm,Nq-pyqvm) alongside fixed 9-qubit variants. - Structured logging — job-scoped, instance-bound loggers emit structured key=value fields at every major step for traceability and debugging.
- Compatibility shims —
quapp_pennylane/__init__.pypatches API breaks betweenpennylane-rigetti==0.36.0and PennyLane 0.37–0.42+ at import time (see Compatibility below).
Installation
pip install quapp-pennylane
Requirements
| Dependency | Version |
|---|---|
| Python | ≥ 3.10 |
| quapp-common | 0.0.11.dev7 |
| pennylane | 0.37.0 |
| PennyLane-Rigetti | 0.36.0 |
| PennyLane-Lightning | 0.37.0 |
| pydantic | ≥ 1.7.2, < 2.0.0 |
| autoray | 0.6.11 |
Project Structure
quapp_pennylane/
├── __init__.py # Compatibility shims (loaded at import)
├── async_tasks/
│ └── pennylane_circuit_export_task.py # PennylaneCircuitExportTask + adapter
├── component/
│ └── backend/
│ └── pennylane_invocation.py
├── factory/
│ ├── pennylane_device_factory.py
│ ├── pennylane_handler_factory.py
│ └── pennylane_provider_factory.py
├── handler/
│ └── invocation_handler.py
└── model/
├── device/
│ ├── qapp_pennylane_device.py # Core execution device
│ ├── aws_braket_device.py
│ └── ibm_quantum_device.py
└── provider/
├── qapp_pennylane_provider.py
├── aws_braket_provider.py
├── ibm_cloud_provider.py
└── ibm_quantum_provider.py
Compatibility
quapp_pennylane/__init__.py applies the following shims at import time so that
pennylane-rigetti==0.36.0 works against PennyLane 0.37–0.42+:
| Symbol | Change | Shim |
|---|---|---|
measurements.Expectation |
Renamed to ExpectationMP in PennyLane 0.37+ |
Alias Expectation → ExpectationMP |
operation.Tensor |
Removed in PennyLane 0.40+; replaced by ops.Prod |
Alias Tensor → Prod for isinstance checks |
pennylane.QubitDevice |
Moved to pennylane.devices in PennyLane ~0.40+ |
Re-export at top-level namespace |
pydantic.BaseModel.__config__ |
Removed in Pydantic v2; qcs-api-client<0.22.0 reads self.__config__.env_prefix |
Inject a stub __config__ with env_prefix='' onto BaseModel |
pydantic is pinned to >=1.7.2,<2.0.0 in pyproject.toml to make the v1
requirement of qcs-api-client<0.22.0 explicit and prevent pip from resolving v2.
Recent Changes
0.0.5.dev6
-
feat(error): Thêm
quapp_pennylane/error_rules.py— 9 rule phân loại lỗi đặc thù PennyLane, đăng ký vào classifier củaquapp-commonkhi package được import. Nhờ đó lỗi PennyLane cócategory/code/ hướng xử lý cụ thể trong Job Log thay vì rơi về fallback chungCOMPILATION_FAILED:PENNYLANE_DEVICE_NOT_AVAILABLE— device không có trongqml.plugin_devices(thường do thiếu plugin hoặc viết sai tên device);PENNYLANE_INVALID_QUANTUM_FUNCTION,PENNYLANE_WIRE_ERROR,PENNYLANE_QUEUING_ERROR,PENNYLANE_MEASUREMENT_SHAPE_ERROR— lỗi trong circuit do user viết (USER_CODE);PENNYLANE_OPERATION_UNSUPPORTED,PENNYLANE_TAPE_ERROR,PENNYLANE_DEVICE_ERROR— giới hạn của SDK/device (SDK_RUNTIME);PENNYLANE_DEVICE_CONFIG_INVALID—DeviceErrorvề shots/wire, phân loại làINVALID_INPUTvì user sửa được.
Rule match theo tên class dạng string, nên
quapp-commonkhông phải import PennyLane — bắt buộc, vì lib này kéo theopennylane-rigettivàpyquilvới ràng buộc version rất chặt. -
fix(device):
QAppPennylaneDevice._get_shots()dùnggetattr(job_result, 'shots')trên một dict nên luôn trảNone— shots không bao giờ tới được Job Log dù_create_job()đã tính đúng. Nay đọc bằng.get()cho dict. -
fix(device):
_create_job()đọcparts[1]cho device Rigetti QVM mà không kiểm tra độ dài, nên spec thiếu phần sau/gâyIndexError: list index out of range. Nay raiseValueErrornói rõ spec phải có dạngrigetti.qvm/<device_type>. -
build:
quapp-commontừ==0.0.11.dev7(exact pin, không córegister_rules) thành>=0.0.14.dev1. -
test: Thêm
tests/test_error_rules.py— 14 case, dựng exception thật từ PennyLane 0.37 để test vỡ khi PennyLane đổi tên exception.
Ghi chú version: nhảy từ
0.0.4.dev6(bản develop đang giữ saurevert/pennylane-to-0.0.4.dev6) lên0.0.5.dev6vì0.0.5.dev1–dev5đã publish, và templatejs-pennylane/qs-pennylanepinquapp-pennylane>=0.0.5.dev2nên không thể lùi về dòng0.0.4.
0.0.5.dev2
- fix(export): Fix
_PennylaneDrawableCircuit.draw()—qml.draw_mplrequires aQNode, not a bare callable; now captures the circuit into aQuantumTape, derives wires, creates adefault.qubitdevice, and wraps in aQNodebefore rendering withqml.draw_mpl. - build: Bump version to
0.0.5.dev2.
0.0.5.dev1
- feat(device): Add structured key=value log fields to
QAppPennylaneDeviceat every execution stage — initialization, tape diagnostics, device resolution, QNode setup, execution timing, histogram generation, and finalization. - feat(device): Default shots fallback —
shots=Noneorshots=0inCircuitRunningOptionfalls back to 1024 with a warning instead of raising. - feat(export): Introduce
_PennylaneDrawableCircuitadapter inPennylaneCircuitExportTaskto wrap PennyLane circuits for theCircuitExportTask.draw()contract usingqml.draw_mpl. - feat(export): Emit Python runtime information and duration timing in
_transpile_circuit. - fix(compat): Patch
pydantic.BaseModel.__config__at import time for Pydantic v2 environments —qcs-api-client<0.22.0accessesself.__config__.env_prefix(a Pydantic v1 inner Config class removed in v2). - fix(deps): Pin
pydantic>=1.7.2,<2.0.0inpyproject.tomlto prevent pip from resolving Pydantic v2. - fix(compat): Extend compatibility shims for
pennylane-rigetti==0.36.0against PennyLane 0.37–0.42+:measurements.Expectation,operation.Tensor, andpennylane.QubitDevice. - build: Bump version to
0.0.5.dev1.
For detailed API references, refer to the in-code documentation or contact the maintainers at corp@citynow.vn.
Metadata
Release files for quapp-pennylane 0.0.5.dev9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quapp_pennylane-0.0.5.dev9.tar.gz | 31.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quapp_pennylane-0.0.5.dev9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.6 kB
Release files / quapp_pennylane-0.0.5.dev9.tar.gz
| Download URL | quapp_pennylane-0.0.5.dev9.tar.gz |
|---|---|
| Size | 31.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4785b320c6eeade3773cb911d6b0d5941dfd104cf20648d1c52bbd20425b4fae
|
|
BLAKE2b-256 checksum How to use checksums |
ed487e823e8cc922f7f2a570f39c8c0cc942b5a7f7c312061a57012b8693f257
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / quapp_pennylane-0.0.5.dev9-py3-none-any.whl
| Download URL | quapp_pennylane-0.0.5.dev9-py3-none-any.whl |
|---|---|
| Size | 28.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
838447ffe2e2d44505beea0a2631efb358c427da2baf7635656184ed8f83c5d6
|
|
BLAKE2b-256 checksum How to use checksums |
f652a913f32a88a9d376cdf50e352751ab064cb834c2a378f2ba0f7052e22a4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|